From 3eacf89dded0121d2a50fb01dec5d8ccbfbbe4ee Mon Sep 17 00:00:00 2001 From: ewy Date: Tue, 22 Sep 2026 15:05:51 +0200 Subject: naive auth --- engine/game.go | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'engine/game.go') diff --git a/engine/game.go b/engine/game.go index 8365869..0735958 100644 --- a/engine/game.go +++ b/engine/game.go @@ -5,22 +5,24 @@ import ( ) type Turn struct { - Player *Player + Player *Player `json:"-"` + PlayerSlot string `json:"Player"` ActionTaken bool - Actions []Action + Actions []Action } type Game struct { Shadow *pool.Pool Distance *pool.Pool - Yin *Player - Yang *Player + Yin *Player `json:"PlayerYin"` + Yang *Player `json:"PlayerYang"` Stack []IsCard Actions []Action - CurrentPlayer *Player + CurrentPlayer *Player `json:"-"` + CurrentPlayerSlot string `json:"CurrentPlayer"` History []Turn } @@ -59,18 +61,45 @@ func (g *Game) Winner() *Player { func (g *Game) NextTurn() { current := g.CurrentPlayer.Opponent(g) g.CurrentPlayer = current + playerRef := "UNKNOWN" + switch current { + case g.Yin: + playerRef = "YIN" + case g.Yang: + playerRef = "YANG" + } g.History = append(g.History, Turn{ - Player: current, + Player: current, ActionTaken: false, + PlayerSlot: playerRef, }) - g.Actions = Interactions(ShuffleDeckAction(g),DrawCardAction(g)), + g.CurrentPlayerSlot = playerRef + g.Actions = Interactions(ShuffleDeckAction(g), DrawCardAction(g)) } func (g *Game) CurrentTurn() Turn { - return g.History[len(g.History) - 1] + return g.History[len(g.History)-1] } func (g *Game) ActionToHistory(a Action) { thisTurn := g.History[len(g.History)-1] thisTurn.Actions = append(thisTurn.Actions, a) } + +func (g *Game) Present(p *Player) Game { + localGame := *g + switch p { + case g.Yin: + localGame.Yang.Hide() + case g.Yang: + localGame.Yin.Hide() + } + var acs []Action + for _, a := range g.Actions { + if a.Actor(g) == p { + acs = append(acs, a) + } + } + localGame.Actions = acs + return localGame +} -- cgit v1.3.1