From b82e6069c9dc93eff6e539a8cccd73e69ecde38e Mon Sep 17 00:00:00 2001 From: ewy Date: Tue, 15 Sep 2026 13:41:27 +0200 Subject: update --- .idea/.gitignore | 8 +++++ .idea/inspectionProfiles/Project_Default.xml | 10 ++++++ .idea/modules.xml | 8 +++++ .idea/sakura.iml | 17 ++++++++++ .idea/vcs.xml | 6 ++++ engine/action.go | 49 +++++++++++++++++++++++----- engine/game.go | 19 +++++++++++ engine/pool/pool.go | 4 +-- server/web/index.gohtml | 4 ++- 9 files changed, 114 insertions(+), 11 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/sakura.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..e157b11 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c21cfee --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/sakura.iml b/.idea/sakura.iml new file mode 100644 index 0000000..ab77839 --- /dev/null +++ b/.idea/sakura.iml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file 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 } diff --git a/server/web/index.gohtml b/server/web/index.gohtml index bf60372..d7a90b4 100644 --- a/server/web/index.gohtml +++ b/server/web/index.gohtml @@ -11,7 +11,9 @@