From d46eb8bca2c26121d71f9122bd9930104734519d Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 26 Mar 2024 18:59:22 +0100 Subject: implment upkeep costs using ResourceCosts --- go/game/action.go | 2 +- go/game/card.go | 9 +++------ go/game/player.go | 2 +- go/game/unit.go | 10 +++++----- 4 files changed, 10 insertions(+), 13 deletions(-) (limited to 'go') diff --git a/go/game/action.go b/go/game/action.go index 4f1479dc..b460a27a 100644 --- a/go/game/action.go +++ b/go/game/action.go @@ -599,7 +599,7 @@ func (a *UpkeepAction) resolve(*State) { continue } - p.Resource -= u.upkeep + p.Resource -= u.UpkeepCost() u.onUpkeep() } } diff --git a/go/game/card.go b/go/game/card.go index 3507f5fd..4f01eb4c 100644 --- a/go/game/card.go +++ b/go/game/card.go @@ -236,12 +236,9 @@ func (card *Card) parseDefinition(definition []byte) { } if pcFound { - switch card.Type { - case CardTypes.Unit: - card.PlayCosts = &ResourceCosts{fixed: card.Values["upkeep"].(int)} - default: - card.PlayCosts = ParseCardResourceCosts(pc, card.getEffects()) - } + card.PlayCosts = ParseCardResourceCosts(pc, card.getEffects()) + } else if card.Type == CardTypes.Unit { + card.PlayCosts = ParseCardResourceCosts(card.Values["upkeep"], card.getEffects()) } card.Impl = getCardImplementation(card) diff --git a/go/game/player.go b/go/game/player.go index efffc295..89423b93 100644 --- a/go/game/player.go +++ b/go/game/player.go @@ -66,7 +66,7 @@ func (p *Player) UpkeepCost() int { if u.Controller() != p { continue } - cost += u.upkeep + cost += u.UpkeepCost() } return cost } diff --git a/go/game/unit.go b/go/game/unit.go index f1e38078..c875fa50 100644 --- a/go/game/unit.go +++ b/go/game/unit.go @@ -10,7 +10,7 @@ type Unit struct { Health int Movement Movement Attack Attack - upkeep int + upkeep *ResourceCosts FullActions []*FullAction FreeActions []*FreeAction // Effects []Effects @@ -29,9 +29,9 @@ func NewUnit(card *Card, tile *Tile, owner *Player) *Unit { movement = parseMovement(movementDesc) } - upkeep, ok := card.Values["upkeep"].(int) - if !ok { - upkeep = 0 + upkeep := card.PlayCosts + if upkeep == nil { + upkeep = &ResourceCosts{fixed: 0} } var attack Attack @@ -66,7 +66,7 @@ func NewUnitFromPath(cardPath string, tile *Tile, owner *Player) *Unit { } func (u *Unit) UpkeepCost() int { - return u.upkeep + return u.upkeep.Costs(u.controller.gameState) } func (u *Unit) resetBaseActions() { -- cgit v1.2.3