summaryrefslogtreecommitdiff
path: root/engine/action.go
diff options
context:
space:
mode:
authorEwy <ewy@ewy.one>2026-09-21 21:40:05 +0200
committerEwy <ewy@ewy.one>2026-09-21 21:40:05 +0200
commit83b2f2e9922f46fe46fd5330e6b38c66d1483ade (patch)
tree21a6a4402fe99e2afabb67f2cc0d41d0c0ea85be /engine/action.go
parent1f8364b145dbd0ff9ff7583f50aeb7498967b0f9 (diff)
(wip)
Diffstat (limited to 'engine/action.go')
-rw-r--r--engine/action.go83
1 files changed, 48 insertions, 35 deletions
diff --git a/engine/action.go b/engine/action.go
index 38749c7..178c4a0 100644
--- a/engine/action.go
+++ b/engine/action.go
@@ -1,12 +1,17 @@
package engine
type BaseAction struct {
- User *Player
- BaseSource IsCard
+ User *Player
+ BaseSource IsCard
+ Description string
}
-func (b *BaseAction) Actor() *Player {
- return b.User
+func (b *BaseAction) Actor(g *Game) *Player {
+ u := b.User
+ if u == nil {
+ u = g.CurrentPlayer
+ }
+ return u
}
func (b *BaseAction) Source() IsCard {
@@ -17,17 +22,13 @@ func (b *BaseAction) Then(g *Game) {
}
type Action interface {
- Actor() *Player
+ Actor(g *Game) *Player
Source() IsCard
Then(g *Game)
}
-func Interactions(a ...Action) map[InteractionID]Action {
- m := make(map[InteractionID]Action, len(a))
- for i, ac := range a {
- m[InteractionID(i)] = ac
- }
- return m
+func Interactions(a ...Action) []Action {
+ return a
}
type DamageDecision bool
@@ -46,28 +47,24 @@ type DesignateDamage struct {
func (d *DesignateDamage) Then(g *Game) {
}
-type PlayCard struct {
- *BaseAction
-}
-
-func (u *PlayCard) Then(g *Game) {
- g.Actions = Interactions(&PlayCard{}, &UseVigor{})
-}
-
-type PlayAllOutCard struct {
- *BaseAction
-}
-
-func (p *PlayAllOutCard) Then(g *Game) {
- g.Actions = Interactions(&EndTurn{})
-}
-
type ShuffleDeck struct {
*BaseAction
}
func (s *ShuffleDeck) Then(g *Game) {
- g.Actions = Interactions(&DrawCard{})
+ g.Actions = Interactions(&DrawCard{
+ BaseAction: &BaseAction{
+ Description: "Draw a card (or lose 1 life)",
+ },
+ })
+}
+
+func ShuffleDeckAction(g *Game) Action {
+ return &ShuffleDeck{
+ BaseAction: &BaseAction{
+ Description: "Pay 1 life to shuffle your deck",
+ },
+ }
}
type DrawCard struct {
@@ -75,21 +72,37 @@ type DrawCard struct {
}
func (d *DrawCard) Then(g *Game) {
- g.Actions = Interactions(&PlayCard{}, &PlayAllOutCard{}, &UseVigor{})
-}
-
-type UseVigor struct {
- *BaseAction
+ if len(g.CurrentPlayer.DrawPile) < 1 {
+ g.CurrentPlayer.Life.Subtract(1)
+ } else {
+ c := g.Yin.DrawPile.Pop()
+ g.CurrentPlayer.Hand = append(g.CurrentPlayer.Hand, c.Base())
+ }
+ g.Actions = append(VigorActions(g, g.CurrentPlayer), EndTurnAction(g))
}
-func (u *UseVigor) Then(g *Game) {
- g.Actions = Interactions(&PlayCard{}, &UseVigor{})
+func DrawCardAction(g *Game) Action {
+ return &DrawCard{
+ BaseAction: &BaseAction{
+ Description: "Draw a card (or lose 1 life)",
+ },
+ }
}
type EndTurn struct {
*BaseAction
}
+func EndTurnAction(g *Game) Action {
+ return &EndTurn{
+ BaseAction: &BaseAction{
+ User: g.CurrentPlayer,
+ BaseSource: nil,
+ Description: "End your turn",
+ },
+ }
+}
+
func (e *EndTurn) Then(g *Game) {
g.NextTurn()
}