From 00dc8df0de0eebcd20bff2e3f8898370b137842e Mon Sep 17 00:00:00 2001 From: RndName Date: Sat, 7 May 2022 18:08:26 +0200 Subject: [PATCH] Fix income not correctly calculated - Fix the Income class to correctly count the income with the recent ground object refactoring - Adjust the Factory income from 10 to 2.5 as we now have 4 units instead of 1 as with v5.2 closes #2207 --- game/config.py | 2 +- game/income.py | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/game/config.py b/game/config.py index 39cf8d1e..2a55fc37 100644 --- a/game/config.py +++ b/game/config.py @@ -11,7 +11,7 @@ REWARDS = { "farp": 1, # TODO: Should generate no cash once they generate units. # https://github.com/dcs-liberation/dcs_liberation/issues/1036 - "factory": 10, + "factory": 2.5, "oil": 10, "derrick": 8, "village": 0.25, diff --git a/game/income.py b/game/income.py index bcbe2aa0..6112fa68 100644 --- a/game/income.py +++ b/game/income.py @@ -30,25 +30,21 @@ class Income: self.control_points = [] self.buildings = [] - names = set() for cp in game.theater.control_points_for(player): if cp.income_per_turn: self.control_points.append(cp) - for tgo in cp.ground_objects: - names.add(tgo.obj_name) - for name in names: - count = 0 - tgos = game.theater.find_ground_objects_by_obj_name(name) - category = tgos[0].category - if category not in REWARDS: - continue - for tgo in tgos: - if not tgo.is_dead: - count += 1 - self.buildings.append( - BuildingIncome(name, category, count, REWARDS[category]) - ) + for tgo in cp.ground_objects: + if tgo.category not in REWARDS: + continue + self.buildings.append( + BuildingIncome( + tgo.obj_name, + tgo.category, + len(list(tgo.statics)), + REWARDS[tgo.category], + ) + ) self.from_bases = sum(cp.income_per_turn for cp in self.control_points) self.total_buildings = sum(b.income for b in self.buildings)