Add MayChooseRoll
This commit is contained in:
parent
ffeb985cab
commit
a87e493425
2 changed files with 13 additions and 1 deletions
|
@ -350,12 +350,18 @@ func (g *serverGame) listing(playerName []byte) *bgammon.GameListing {
|
|||
} else {
|
||||
playerCount = g.playerCount()
|
||||
}
|
||||
|
||||
name := string(g.name)
|
||||
if g.Acey {
|
||||
name = "(Acey-deucey) " + name
|
||||
}
|
||||
|
||||
return &bgammon.GameListing{
|
||||
ID: g.id,
|
||||
Points: g.Points,
|
||||
Password: len(g.password) != 0,
|
||||
Players: playerCount,
|
||||
Name: string(g.name),
|
||||
Name: name,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,12 @@ func (g *GameState) MayRoll() bool {
|
|||
}
|
||||
}
|
||||
|
||||
// MayChooseRoll returns whether the player may send the 'ok' command, supplying
|
||||
// the chosen roll. This command only applies to acey-deucey games.
|
||||
func (g *GameState) MayChooseRoll() bool {
|
||||
return g.Acey && g.Turn != 0 && g.Turn == g.PlayerNumber && ((g.Roll1 == 1 && g.Roll2 == 2) || (g.Roll1 == 2 && g.Roll2 == 1))
|
||||
}
|
||||
|
||||
// MayOK returns whether the player may send the 'ok' command.
|
||||
func (g *GameState) MayOK() bool {
|
||||
if g.Spectating || g.Winner != 0 {
|
||||
|
|
Loading…
Reference in a new issue