diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-06-25 11:08:08 -0500 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-07-03 22:01:22 -0400 |
| commit | 908e517210d536cc31b84abcd1bf711dc01a60f4 (patch) | |
| tree | bcb28e84a312fd56b489d9b65d1df7ebcfcf1913 /go | |
| parent | c831f2908c0a50344293d0d39ca4daabbca35434 (diff) | |
| download | muhqs-game-908e517210d536cc31b84abcd1bf711dc01a60f4.tar.gz muhqs-game-908e517210d536cc31b84abcd1bf711dc01a60f4.zip | |
move hand card removal to the play action's costs
Diffstat (limited to 'go')
| -rw-r--r-- | go/game/action.go | 7 | ||||
| -rw-r--r-- | go/game/state.go | 3 |
2 files changed, 4 insertions, 6 deletions
diff --git a/go/game/action.go b/go/game/action.go index 154d530b..f0dc5ca8 100644 --- a/go/game/action.go +++ b/go/game/action.go @@ -248,12 +248,13 @@ var ( equipmentPlayActionTarget = TargetDesc{"available spawn tile", "?"} ) -func NewPlayActionCostFunc(player *Player, cost int) ActionCostFunc { +func NewPlayActionCostFunc(player *Player, cost int, card *Card) ActionCostFunc { return func(*LocalState) bool { if player.Resource < cost { return false } player.Resource -= cost + player.Hand.RemoveCard(card) return true } } @@ -275,7 +276,7 @@ func NewPlayAction(p *Player, c *Card, args ...interface{}) *PlayAction { s := p.gameState if a.costFunc == nil { - a.costFunc = NewPlayActionCostFunc(p, c.PlayCosts.Costs(s)) + a.costFunc = NewPlayActionCostFunc(p, c.PlayCosts.Costs(s), c) } if c.IsPermanent() { @@ -298,7 +299,7 @@ func NewPlayAction(p *Player, c *Card, args ...interface{}) *PlayAction { } func NewPlayActionVariadicCosts(p *Player, c *Card, variadicCosts int) *PlayAction { - a := NewPlayAction(p, c, NewPlayActionCostFunc(p, c.PlayCosts.Costs(p.gameState, variadicCosts))) + a := NewPlayAction(p, c, NewPlayActionCostFunc(p, c.PlayCosts.Costs(p.gameState, variadicCosts), c)) a.ChoosenVariadicCost = variadicCosts return a } diff --git a/go/game/state.go b/go/game/state.go index 261fcb2a..f6fdd2d0 100644 --- a/go/game/state.go +++ b/go/game/state.go @@ -441,9 +441,6 @@ func (s *LocalState) declareAction(a Action) { } if err == nil { - if pa, ok := a.(*PlayAction); ok { - pa.Source().(*Player).Hand.RemoveCard(pa.Card) - } s.pushAction(a) } |
