Skip to content

Commit

Permalink
bandaid fix for CB consumables
Browse files Browse the repository at this point in the history
  • Loading branch information
padtrack committed May 24, 2024
1 parent 98427bc commit 4d1aa45
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion generated/abilities.json

Large diffs are not rendered by default.

36 changes: 22 additions & 14 deletions renderer_data/generators/abilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,40 @@
"distShip",
"artilleryDistCoeff",
}
# ConsumablesConstants.ConsumableIDsMap
ability_type_to_id = {'tacticalTrigger2': 46, 'callFighters': 21, 'smokePlane': 52, 'goDeep': 33,
'weaponReloadBooster': 34, 'planeMinefield': 43, 'subsEnergyFreeze': 37, 'All': 55,
'planeSmokeGenerator': 42, 'submarineLocator': 41, 'trigger4': 16, 'trigger5': 17,
'trigger6': 18, 'trigger7': 27, 'smokeGenerator': 6, 'trigger1': 13, 'trigger2': 14,
'trigger3': 15, 'tacticalTrigger3': 47, 'invulnerable': 19, 'tacticalTrigger1': 45,
'trigger8': 28, 'trigger9': 29, 'tacticalTrigger5': 49, 'tacticalTrigger4': 48,
'reconnaissanceSquad': 51, 'airDefenseDisp': 2, 'torpedoReloader': 11, 'minefield': 44,
'fastRudders': 36, 'buff': 30, 'healForsage': 20, 'hydrophone': 35, 'subsFourthState': 25,
'regenCrew': 8, 'tacticalBuff': 53, 'scout': 1, 'artilleryBoosters': 4, 'groupAuraBuff': 38,
'buffsShift': 31, 'invisibilityExtraBuffConsumable': 40, 'regenerateHealth': 22, 'rls': 12,
'subsOxygenRegen': 23, 'circleWave': 32, 'affectedBuffAura': 39, 'fighter': 9, 'crashCrew': 0,
'Any': 54, 'hangarBoosters': 5, 'Special': 56, 'speedBoosters': 3, 'sonar': 10,
'subsWaveGunBoost': 24, 'tacticalTrigger6': 50, 'depthCharges': 26}


def create_abilities_data():
LOGGER.info("Creating abilities data...")
list_ships = get_data("Ship")
list_ability = get_data("Ability")

clan_battles = {}
ability_entities = {}

for ab in list_ability:
for k, v in vars(ab).items():
if "ClanBattles" in k:
type_id = ability_type_to_id[v.consumableType]
assert type_id not in clan_battles, "Duplicate clan battle consumable types"
clan_battles[type_id] = ab.name

sub = ability_entities.setdefault(ab.name, {})
sub[k] = v # type: ignore

# ConsumablesConstants.ConsumableIDsMap
ability_type_to_id = {'tacticalTrigger2': 46, 'callFighters': 21, 'smokePlane': 52, 'goDeep': 33,
'weaponReloadBooster': 34, 'planeMinefield': 43, 'subsEnergyFreeze': 37, 'All': 55,
'planeSmokeGenerator': 42, 'submarineLocator': 41, 'trigger4': 16, 'trigger5': 17,
'trigger6': 18, 'trigger7': 27, 'smokeGenerator': 6, 'trigger1': 13, 'trigger2': 14,
'trigger3': 15, 'tacticalTrigger3': 47, 'invulnerable': 19, 'tacticalTrigger1': 45,
'trigger8': 28, 'trigger9': 29, 'tacticalTrigger5': 49, 'tacticalTrigger4': 48,
'reconnaissanceSquad': 51, 'airDefenseDisp': 2, 'torpedoReloader': 11, 'minefield': 44,
'fastRudders': 36, 'buff': 30, 'healForsage': 20, 'hydrophone': 35, 'subsFourthState': 25,
'regenCrew': 8, 'tacticalBuff': 53, 'scout': 1, 'artilleryBoosters': 4, 'groupAuraBuff': 38,
'buffsShift': 31, 'invisibilityExtraBuffConsumable': 40, 'regenerateHealth': 22, 'rls': 12,
'subsOxygenRegen': 23, 'circleWave': 32, 'affectedBuffAura': 39, 'fighter': 9, 'crashCrew': 0,
'Any': 54, 'hangarBoosters': 5, 'Special': 56, 'speedBoosters': 3, 'sonar': 10,
'subsWaveGunBoost': 24, 'tacticalTrigger6': 50, 'depthCharges': 26}
_abils = {}

for ship in list_ships:
Expand Down Expand Up @@ -69,6 +75,8 @@ def create_abilities_data():
k: v for k, v in sa.__dict__.items() if k in REQUIRED
}

_abils["clan"] = clan_battles

with open(
os.path.join(os.getcwd(), "generated", "abilities.json"), "w"
) as f:
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/layers/ship.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ def _ship_consumable(

for aid, _ in ac.items():
abilities = self._abilities[params_id]
index = abilities["id_to_index"][aid]
try:
index = abilities["id_to_index"][aid]
except KeyError:
index = self._abilities["clan"][aid]
filename = f"consumable_{index}.png"
c_image = self._renderer.resman.load_image(
filename,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/versions/13_4_0/resources/abilities.json

Large diffs are not rendered by default.

0 comments on commit 4d1aa45

Please sign in to comment.