From b82e6069c9dc93eff6e539a8cccd73e69ecde38e Mon Sep 17 00:00:00 2001 From: ewy Date: Tue, 15 Sep 2026 13:41:27 +0200 Subject: update --- engine/action.go | 49 +++++++++++++++++++++++++++++++++++++++++-------- engine/game.go | 19 +++++++++++++++++++ engine/pool/pool.go | 4 ++-- 3 files changed, 62 insertions(+), 10 deletions(-) (limited to 'engine') diff --git a/engine/action.go b/engine/action.go index 2a73982..38749c7 100644 --- a/engine/action.go +++ b/engine/action.go @@ -43,20 +43,53 @@ type DesignateDamage struct { SourceCard *Card } -func (d *DesignateDamage) Actor() *Player { - return d.Defender +func (d *DesignateDamage) Then(g *Game) { } -func (d *DesignateDamage) Instigator() *Player { - return d.Attacker + +type PlayCard struct { + *BaseAction } -func (d *DesignateDamage) Then(g *Game) { +func (u *PlayCard) Then(g *Game) { + g.Actions = Interactions(&PlayCard{}, &UseVigor{}) } -func (d *DesignateDamage) Source() IsCard { - return d.SourceCard +type PlayAllOutCard struct { + *BaseAction } -type PlayCard struct { +func (p *PlayAllOutCard) Then(g *Game) { + g.Actions = Interactions(&EndTurn{}) +} + +type ShuffleDeck struct { + *BaseAction +} + +func (s *ShuffleDeck) Then(g *Game) { + g.Actions = Interactions(&DrawCard{}) +} + +type DrawCard struct { *BaseAction } + +func (d *DrawCard) Then(g *Game) { + g.Actions = Interactions(&PlayCard{}, &PlayAllOutCard{}, &UseVigor{}) +} + +type UseVigor struct { + *BaseAction +} + +func (u *UseVigor) Then(g *Game) { + g.Actions = Interactions(&PlayCard{}, &UseVigor{}) +} + +type EndTurn struct { + *BaseAction +} + +func (e *EndTurn) Then(g *Game) { + g.NextTurn() +} diff --git a/engine/game.go b/engine/game.go index 0ed93e2..19880f0 100644 --- a/engine/game.go +++ b/engine/game.go @@ -13,6 +13,8 @@ type Game struct { Stack []IsCard Actions map[InteractionID]Action + + CurrentPlayer *Player } func (g *Game) propagate() { @@ -28,6 +30,7 @@ func NewGame() *Game { g.Yin = NewPlayer(g) g.Yang = NewPlayer(g) g.propagate() + g.NextTurn() return g } @@ -45,3 +48,19 @@ func (g *Game) Winner() *Player { } return nil } + +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, + }, + }) +} diff --git a/engine/pool/pool.go b/engine/pool/pool.go index 2179a12..5443baa 100644 --- a/engine/pool/pool.go +++ b/engine/pool/pool.go @@ -4,8 +4,8 @@ const Infinite = -1 const Empty = 0 type Pool struct { - OverflowsTo *Pool - SubtractsTo *Pool + OverflowsTo *Pool `json:"-"` + SubtractsTo *Pool `json:"-"` Max int Value int } -- cgit v1.3.1