1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
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()
}
|