Fold COASTAL_BATTERY into HOSTILE_ARTILLERY, it's the same thing

Same pattern already established for AMMO_CACHE -> SUPPLY_CACHE: a
'Coastal Battery' is just a heavy fixed-emplacement HostileArtillery
under a different name in the game's own text, not a meaningfully
different unit type worth its own enum member. Removed the
TargetType.COASTAL_BATTERY member, added 'CoastalBattery' to
ocr.py's _TYPE_WORD_ALIASES (so 'Coastal Battery#2:' still parses,
now as a HostileArtillery), and a models.py migration entry so any
save file written before this change still loads correctly.

Verified the migration directly (COASTAL_BATTERY -> HOSTILE_ARTILLERY,
existing AMMO_CACHE -> SUPPLY_CACHE unaffected) and updated the one
test that asserted the old type.
This commit is contained in:
2026-08-09 20:06:44 +02:00
parent 57e73c58ea
commit d6694b585b
3 changed files with 13 additions and 8 deletions
+4 -4
View File
@@ -41,10 +41,9 @@ class TargetType(Enum):
FDC = "FDC" # Fire Direction Center, coordinates enemy counter-battery fire
INFANTRY = "Infantry" # hostile ground troops
MECHANIZED = "Mechanized" # hostile armored/vehicle unit
HOSTILE_ARTILLERY = "Hostile Artillery"
HOSTILE_ARTILLERY = "Hostile Artillery" # "Coastal Battery" is just this, see _TYPE_WORD_ALIASES in ocr.py
HOSTILE_TANK = "Hostile Tank"
PILLBOX = "Pillbox" # armoured emplacement, fixed position
COASTAL_BATTERY = "Coastal Battery" # heavy fixed emplacement, reported by listening posts
MARINE_GARRISON = "Marine Garrison" # allied unit, requests fire support (see Target.requested_time)
ENEMY = "Enemy" # ad-hoc installation named directly in the intel text
# ("Enemy Signal Station", "Enemy Field Command"), not one of the
@@ -60,8 +59,9 @@ class TargetType(Enum):
# Renamed/removed enum members, for loading save files written before the
# rename. AMMO_CACHE turned out to be a misreading of the game's actual
# "SupplyCache" name and was dropped in favor of it.
_TARGET_TYPE_MIGRATIONS = {"AMMO_CACHE": "SUPPLY_CACHE"}
# "SupplyCache" name and was dropped in favor of it. COASTAL_BATTERY
# turned out to just be a HOSTILE_ARTILLERY under a different name.
_TARGET_TYPE_MIGRATIONS = {"AMMO_CACHE": "SUPPLY_CACHE", "COASTAL_BATTERY": "HOSTILE_ARTILLERY"}
def _migrate_target_type(name: str) -> TargetType:
+4 -2
View File
@@ -515,8 +515,10 @@ _BARE_CLUE_VALUE_RE = re.compile(
_TYPE_BY_SHORT = {t.short: t for t in TargetType}
# The game's typewriter has used "AmmoCache" for what's now modeled as
# SupplyCache, treat it as the same type rather than dropping the target.
_TYPE_WORD_ALIASES = {"AmmoCache": "SupplyCache"}
# SupplyCache, and "CoastalBattery" for what's just a HostileArtillery
# under a different name, treat both as the same type rather than
# dropping the target or inventing a redundant enum member for it.
_TYPE_WORD_ALIASES = {"AmmoCache": "SupplyCache", "CoastalBattery": "HostileArtillery"}
_REF_NAMED_RE = re.compile(rf"^{_TYPE_ID_FRAGMENT}")