diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-06-25 11:08:08 -0500 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:21 +0200 |
| commit | e8355ce66286c76deb7a2b1dc1d98131b12f234b (patch) | |
| tree | d99cbc7d8355865bd9f53dbb1cfe8c400b8490b1 | |
| parent | 14bf696fa3328f9bac1d0b3e3c4a9940ad695702 (diff) | |
| download | muhqs-game-e8355ce66286c76deb7a2b1dc1d98131b12f234b.tar.gz muhqs-game-e8355ce66286c76deb7a2b1dc1d98131b12f234b.zip | |
move hand card removal to the play action's costs
| -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) } |
