summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/action.go49
-rw-r--r--engine/game.go19
-rw-r--r--engine/pool/pool.go4
3 files changed, 62 insertions, 10 deletions
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
}