diff options
| author | Ewy <ewy@ewy.one> | 2026-09-21 21:40:05 +0200 |
|---|---|---|
| committer | Ewy <ewy@ewy.one> | 2026-09-21 21:40:05 +0200 |
| commit | 83b2f2e9922f46fe46fd5330e6b38c66d1483ade (patch) | |
| tree | 21a6a4402fe99e2afabb67f2cc0d41d0c0ea85be /engine/game.go | |
| parent | 1f8364b145dbd0ff9ff7583f50aeb7498967b0f9 (diff) | |
(wip)
Diffstat (limited to 'engine/game.go')
| -rw-r--r-- | engine/game.go | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/engine/game.go b/engine/game.go index 5130864..8365869 100644 --- a/engine/game.go +++ b/engine/game.go @@ -4,6 +4,12 @@ import ( "sakura/engine/pool" ) +type Turn struct { + Player *Player + ActionTaken bool + Actions []Action +} + type Game struct { Shadow *pool.Pool Distance *pool.Pool @@ -12,9 +18,11 @@ type Game struct { Stack []IsCard - Actions map[InteractionID]Action + Actions []Action CurrentPlayer *Player + + History []Turn } func (g *Game) propagate() { @@ -25,7 +33,6 @@ func NewGame() *Game { g := &Game{ Shadow: pool.New(0, pool.Infinite), Distance: pool.New(10, 10), - Actions: nil, } g.Yin = NewPlayer(g) g.Yang = NewPlayer(g) @@ -52,15 +59,18 @@ func (g *Game) Winner() *Player { func (g *Game) NextTurn() { current := g.CurrentPlayer.Opponent(g) g.CurrentPlayer = current - g.Actions = Interactions(&ShuffleDeck{ - &BaseAction{ - User: current, - BaseSource: nil, - }, - }, &DrawCard{ - &BaseAction{ - User: current, - BaseSource: nil, - }, + g.History = append(g.History, Turn{ + Player: current, + ActionTaken: false, }) + g.Actions = Interactions(ShuffleDeckAction(g),DrawCardAction(g)), +} + +func (g *Game) CurrentTurn() Turn { + 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) } |
