diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-03-26 18:59:22 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:10 +0200 |
| commit | 305897c542b034ab2b08f880436afb4e066c88de (patch) | |
| tree | 23a3986d99ed4f4d09a42c987513d4271a1f7684 | |
| parent | 2ad43658e3fdd7bda4cf568f1c60281ec1534bda (diff) | |
| download | muhqs-game-305897c542b034ab2b08f880436afb4e066c88de.tar.gz muhqs-game-305897c542b034ab2b08f880436afb4e066c88de.zip | |
implment upkeep costs using ResourceCosts
| -rw-r--r-- | go/game/action.go | 2 | ||||
| -rw-r--r-- | go/game/card.go | 9 | ||||
| -rw-r--r-- | go/game/player.go | 2 | ||||
| -rw-r--r-- | go/game/unit.go | 10 |
4 files changed, 10 insertions, 13 deletions
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() { |
