Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Win Message #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ThatBlokeJosh
Copy link

I added a super simple victory message when the user reaches 4 kings.

Comment on lines +188 to +196
card := toDeck.Top().String()
cardArr := strings.Split(card, "")
if cardArr[0] == "K" {
kings[card] = true
}
if len(kings) == 4 {
fmt.Println("You Won!")
os.Exit(0)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure your indentation is correct!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that

@@ -179,6 +185,15 @@ func (s *Solitaire) move(to *index) bool {
if s.selected.card == fromDeck.Size()-1 && toDeck.Size() == 0 && fromDeck.Top().Value == 0 || toDeck.Size() > 0 && fromDeck.Top().Value == toDeck.Top().Value+1 && fromDeck.Top().Suit == toDeck.Top().Suit {
s.toggleSelect(s.selected)
toDeck.Add(fromDeck.Pop())
card := toDeck.Top().String()
cardArr := strings.Split(card, "")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to do this, card[0] should give us the same value as cardArr[0], right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is but i didn't want to convert it to a char. But yes it would be better to do it that way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was meant for my personal use because i wanted to get a victory message, i thought i'll try sending you a pull request if you maybe wanted to add it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants