rts-commander / backend /constants.py
Luigi's picture
deploy(web): full clean snapshot with app code and assets
12d64f8
"""
Gameplay constants for RTS game (costs, power, thresholds, capacities).
Separated for readability and reuse.
"""
from enum import Enum
class UnitType(str, Enum):
INFANTRY = "infantry"
TANK = "tank"
HARVESTER = "harvester"
HELICOPTER = "helicopter"
ARTILLERY = "artillery"
class BuildingType(str, Enum):
HQ = "hq"
BARRACKS = "barracks"
WAR_FACTORY = "war_factory"
REFINERY = "refinery"
POWER_PLANT = "power_plant"
DEFENSE_TURRET = "defense_turret"
# Red Alert Costs (aligned with UI labels)
UNIT_COSTS = {
UnitType.INFANTRY: 100,
UnitType.TANK: 500,
UnitType.ARTILLERY: 600,
UnitType.HELICOPTER: 800,
UnitType.HARVESTER: 200,
}
BUILDING_COSTS = {
BuildingType.HQ: 0,
BuildingType.BARRACKS: 500,
BuildingType.WAR_FACTORY: 800,
BuildingType.REFINERY: 600,
BuildingType.POWER_PLANT: 300,
BuildingType.DEFENSE_TURRET: 400,
}
# Power System - RED ALERT style
POWER_PRODUCTION = {
BuildingType.POWER_PLANT: 100, # Each power plant generates +100 power
BuildingType.HQ: 50, # HQ provides some base power
}
POWER_CONSUMPTION = {
BuildingType.BARRACKS: 20, # Barracks consumes -20 power
BuildingType.WAR_FACTORY: 30, # War Factory consumes -30 power
BuildingType.REFINERY: 10, # Refinery consumes -10 power
BuildingType.DEFENSE_TURRET: 15, # Defense turret consumes -15 power
}
LOW_POWER_THRESHOLD = 0.8 # If power < 80% of consumption, production slows down
LOW_POWER_PRODUCTION_FACTOR = 0.5 # Production speed at 50% when low power
# Harvester constants (Red Alert style)
HARVESTER_CAPACITY = 200
HARVEST_AMOUNT_PER_ORE = 50
HARVEST_AMOUNT_PER_GEM = 100
# Building placement constraints
# Max distance from HQ (in tiles) where new buildings can be placed
HQ_BUILD_RADIUS_TILES = 12
# Gameplay rule: allow multiple buildings of the same type (Barracks, War Factory, etc.)
# If set to False, players can construct only one building per type
ALLOW_MULTIPLE_SAME_BUILDING = True