From 4b044a3523c3e03a861bdb003459c2d1d048c676 Mon Sep 17 00:00:00 2001 From: Branden J Brown Date: Sun, 21 Jan 2024 00:33:39 -0600 Subject: [PATCH] add method to peek the current shell --- game/game.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/game/game.go b/game/game.go index 642b813..e48b9c3 100644 --- a/game/game.go +++ b/game/game.go @@ -102,6 +102,15 @@ func (g *Game) PopShell() bool { 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. func (g *Game) Empty() bool { return len(g.Shells) == 0