aboutsummaryrefslogtreecommitdiff
path: root/go/game
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-14 09:52:22 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:50:09 +0200
commit1ac413e1d0ddc39a41374ff9b3375e6de3e1af1c (patch)
tree23f6a6475340ea52026d2dea117e33c28b3a9df1 /go/game
parent97d5079e68624f842938e4c87386752f1cfda649 (diff)
downloadmuhqs-game-1ac413e1d0ddc39a41374ff9b3375e6de3e1af1c.tar.gz
muhqs-game-1ac413e1d0ddc39a41374ff9b3375e6de3e1af1c.zip
improve state bar
Diffstat (limited to 'go/game')
-rw-r--r--go/game/player.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/go/game/player.go b/go/game/player.go
index cb89e1ae..78b4637e 100644
--- a/go/game/player.go
+++ b/go/game/player.go
@@ -52,6 +52,21 @@ func (p *Player) resourceGain() int {
}
}
+func (p *Player) UpkeepGain() int {
+ return p.resourceGain() - p.UpkeepCost()
+}
+
+func (p *Player) UpkeepCost() int {
+ cost := 0
+ for _, u := range p.gameState.Units {
+ if u.Controller() != p {
+ continue
+ }
+ cost += u.Upkeep
+ }
+ return cost
+}
+
func (p *Player) gainResource(gain int) {
p.Resource += gain
}