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-01-27 16:43:49 +0100
commite049500b213c85c9d1556e01717226a191d2dce8 (patch)
treee9bbf082dc4b4360ae4c5d5ba0dbe1378c530955 /go/game
parent98d0bd3d83f450228477142543b05a2ba5216449 (diff)
downloadmuhqs-game-e049500b213c85c9d1556e01717226a191d2dce8.tar.gz
muhqs-game-e049500b213c85c9d1556e01717226a191d2dce8.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
}