Anonymous user
Go Fish/Go: Difference between revisions
Improved quality.
(Less idiosyncratic and gofmt'ed.) |
(Improved quality.) |
||
Line 54:
card := gm.deck[0]
gm.deck = gm.deck[1:]
if gm.
fmt.Printf("You drew a %s.\n", card)
}
Line 60:
//Check for books
gm.checkForBooks()
}▼
}▼
func (gm *GoFishGame) endPly() {▼
gameOver := gm.isGameOver()▼
gm.printGameOverMessage()▼
} else if gm.turn == 1 {▼
gm.playerTurn(getPickComputer)▼
} else {▼
gm.playerTurn(getPickUser)▼
}
}
Line 114 ⟶ 100:
func (gm *GoFishGame) isGameOver() bool {
return gm.scores[0]+gm.scores[1] == 13
▲}
// isPlayerTurn returns if its the player's turn to move.
}
Line 167 ⟶ 158:
}
}
}
Line 192 ⟶ 182:
func (gm *GoFishGame) stealCards(purge string, side int) int {
count := 0
var filtered []string
for _, card := range
if purge == card {
count++
Line 218 ⟶ 207:
scores[1] = 0
game := GoFishGame{hands, deck, 0, scores}
for {
if game.isPlayerTurn() {
}
break
}
▲ }
}
</lang>
|