Adjust income based on control point type.

* Navies and off map spawns generate no income
* FOBs generate 10 instead of 20

Fixes https://github.com/Khopa/dcs_liberation/issues/662
This commit is contained in:
Dan Albert
2020-12-26 15:06:57 -08:00
parent e861e5b3d6
commit d634fd3236
4 changed files with 69 additions and 39 deletions

View File

@@ -4,7 +4,6 @@ from dataclasses import dataclass
from typing import TYPE_CHECKING
from game.db import REWARDS
from game.theater import ControlPoint
if TYPE_CHECKING:
from game import Game
@@ -22,12 +21,6 @@ class BuildingIncome:
return self.number * self.income_per_building
@dataclass(frozen=True)
class ControlPointIncome:
control_point: ControlPoint
income: int
class Income:
def __init__(self, game: Game, player: bool) -> None:
if player:
@@ -37,12 +30,10 @@ class Income:
self.control_points = []
self.buildings = []
self.income_per_base = 20
names = set()
for cp in game.theater.control_points_for(player):
self.control_points.append(
ControlPointIncome(cp, self.income_per_base))
if cp.income_per_turn:
self.control_points.append(cp)
for tgo in cp.ground_objects:
names.add(tgo.obj_name)
@@ -58,7 +49,7 @@ class Income:
self.buildings.append(BuildingIncome(name, category, count,
REWARDS[category]))
self.from_bases = sum(cp.income for cp in self.control_points)
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)
self.total = ((self.total_buildings + self.from_bases) *
self.multiplier)

View File

@@ -478,6 +478,10 @@ class ControlPoint(MissionTarget, ABC):
else:
return 0
@property
def income_per_turn(self) -> int:
return 0
class Airfield(ControlPoint):
@@ -542,6 +546,10 @@ class Airfield(ControlPoint):
def can_deploy_ground_units(self) -> bool:
return True
@property
def income_per_turn(self) -> int:
return 20
class NavalControlPoint(ControlPoint, ABC):
@@ -741,3 +749,7 @@ class Fob(ControlPoint):
@property
def can_deploy_ground_units(self) -> bool:
return True
@property
def income_per_turn(self) -> int:
return 10