36 lines
886 B
Go
36 lines
886 B
Go
|
package game
|
||
|
|
||
|
type action uint8
|
||
|
|
||
|
const (
|
||
|
actStart action = iota // start of match
|
||
|
|
||
|
actShoot // fired, note prev indicates whether the shell was live
|
||
|
actGameEnd // end of game but not round
|
||
|
actBeerGameEnd // used a beer to end the game
|
||
|
actChallengerWins // challenger wins the round
|
||
|
actDealerWins // dealer wins the match
|
||
|
|
||
|
// current player uses an item
|
||
|
actLens
|
||
|
actCig
|
||
|
actBeer // note prev indicates whether the shell was live
|
||
|
actCuff
|
||
|
actKnife
|
||
|
|
||
|
actDealerConcedes // dealer concedes
|
||
|
actChallengerConcedes // challenger concedes
|
||
|
)
|
||
|
|
||
|
//go:generate go run golang.org/x/tools/cmd/stringer@v0.17.0 -type=action -trimprefix=act
|
||
|
|
||
|
// gameStart returns whether the action indicates the start of a game.
|
||
|
func (a action) gameStart() bool {
|
||
|
switch a {
|
||
|
case actStart, actGameEnd, actBeerGameEnd, actChallengerWins:
|
||
|
return true
|
||
|
default:
|
||
|
return false
|
||
|
}
|
||
|
}
|