aboutsummaryrefslogtreecommitdiff
path: root/go/game
diff options
context:
space:
mode:
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
}