package engine type BaseAction struct { User *Player BaseSource IsCard Description string } func (b *BaseAction) Actor(g *Game) *Player { u := b.User if u == nil { u = g.CurrentPlayer } return u } func (b *BaseAction) Source() IsCard { return b.BaseSource } func (b *BaseAction) Then(g *Game) { } type Action interface { Actor(g *Game) *Player Source() IsCard Then(g *Game) } func Interactions(a ...Action) []Action { return a } type DamageDecision bool var ( Aura DamageDecision = true Life DamageDecision = false ) type DesignateDamage struct { Attacker *Player Defender *Player SourceCard *Card } func (d *DesignateDamage) Then(g *Game) { } type ShuffleDeck struct { *BaseAction } func (s *ShuffleDeck) Then(g *Game) { 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 { *BaseAction } func (d *DrawCard) Then(g *Game) { 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 DrawCardAction(g *Game) Action { return &DrawCard{ BaseAction: &BaseAction{ Description: "Draw a card from your draw pile", }, } } 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() }