Move remnants of db.py to config.py.

This is now just a few prices and income configurations. Both should
probably be defined in YAML but for now this makes the name "db" usable
again.
This commit is contained in:
Dan Albert
2022-02-18 18:22:02 -08:00
parent 9b20a6d053
commit ab6f44cb6f
8 changed files with 42 additions and 71 deletions

View File

@@ -1,3 +1,2 @@
from .game import Game
from . import db
from .version import VERSION

21
game/config.py Normal file
View File

@@ -0,0 +1,21 @@
# This should probably be much higher, but the AI doesn't rollover their budget
# and isn't smart enough to save to repair a critical runway anyway, so it has
# to be cheap enough to repair with a single turn's income.
RUNWAY_REPAIR_COST = 100
REWARDS = {
"power": 4,
"warehouse": 2,
"ware": 2,
"fuel": 2,
"ammo": 2,
"farp": 1,
# TODO: Should generate no cash once they generate units.
# https://github.com/dcs-liberation/dcs_liberation/issues/1036
"factory": 10,
"comms": 10,
"oil": 10,
"derrick": 8,
"village": 0.25,
"allycamp": 0.5,
}

View File

@@ -1,50 +0,0 @@
# mypy can't resolve these if they're wildcard imports for some reason.
# PATCH pydcs data with MODS
"""
---------- BEGINNING OF CONFIGURATION SECTION
"""
"""
All aircraft names in this file should correspond with naming provided in following files:
* https://github.com/pydcs/dcs/blob/master/dcs/planes.py - for planes
* https://github.com/pydcs/dcs/blob/master/dcs/helicopters.py - for helicopters
* https://github.com/pydcs/dcs/blob/master/dcs/vehicles.py - for vehicles (this include all of the ground vehicles)
You can find names at the bottom of the file in following format:
x_map = {
"Name of the unit in game": Identifier,
}
from this example `Identifier` should be used (which may or may not include category of the unit and dot + underscore characters).
For example, player accessible Hornet is called `FA_18C_hornet`, and MANPAD Igla is called `AirDefence.MANPADS_SA_18_Igla_S_Grouse`
"""
# This should probably be much higher, but the AI doesn't rollover their budget
# and isn't smart enough to save to repair a critical runway anyway, so it has
# to be cheap enough to repair with a single turn's income.
RUNWAY_REPAIR_COST = 100
REWARDS = {
"power": 4,
"warehouse": 2,
"ware": 2,
"fuel": 2,
"ammo": 2,
"farp": 1,
# TODO: Should generate no cash once they generate units.
# https://github.com/dcs-liberation/dcs_liberation/issues/1036
"factory": 10,
"comms": 10,
"oil": 10,
"derrick": 8,
"village": 0.25,
"allycamp": 0.5,
}
"""
---------- END OF CONFIGURATION SECTION
"""

View File

@@ -3,7 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING
from game.db import REWARDS
from game.config import REWARDS
if TYPE_CHECKING:
from game import Game

View File

@@ -5,7 +5,7 @@ import random
from dataclasses import dataclass
from typing import Iterator, List, Optional, TYPE_CHECKING, Tuple
from game import db
from game.config import RUNWAY_REPAIR_COST
from game.data.groundunitclass import GroundUnitClass
from game.dcs.groundunittype import GroundUnitType
from game.theater import ControlPoint, MissionTarget
@@ -100,11 +100,11 @@ class ProcurementAi:
def repair_runways(self, budget: float) -> float:
for control_point in self.owned_points:
if budget < db.RUNWAY_REPAIR_COST:
if budget < RUNWAY_REPAIR_COST:
break
if control_point.runway_can_be_repaired:
control_point.begin_runway_repair()
budget -= db.RUNWAY_REPAIR_COST
budget -= RUNWAY_REPAIR_COST
if self.is_player:
self.game.message(
"OPFOR has begun repairing the runway at " f"{control_point}"