add method to peek the current shell

This commit is contained in:
Branden J Brown 2024-01-21 00:33:39 -06:00
parent 449d90bc98
commit 4b044a3523
1 changed files with 9 additions and 0 deletions

View File

@ -102,6 +102,15 @@ func (g *Game) PopShell() bool {
return *g.Prev return *g.Prev
} }
// Peek returns the current turn's shell if it is revealed for the player with
// the given ID, or nil otherwise.
func (g *Game) Peek(id player.ID) *bool {
if id != g.CurrentPlayer().ID || !g.Reveal {
return nil
}
return &g.Shells[0]
}
// Empty returns whether the shotgun is empty. // Empty returns whether the shotgun is empty.
func (g *Game) Empty() bool { func (g *Game) Empty() bool {
return len(g.Shells) == 0 return len(g.Shells) == 0