108108_RELIC_SUFFIX_RE = re .compile (r"(\d+)$" )
109109
110110
111-
112111# ===================================================================
113112# Public API
114113# ===================================================================
@@ -133,8 +132,7 @@ def _build_game_data(raw: dict[str, Any]) -> dict[str, Any]:
133132 ``gpTables``, ``relicData``.
134133 """
135134 logger .debug (
136- "Raw game data keys: %s | units=%d equipment=%d "
137- "statProgression=%d skill=%d relicTierDefinition=%d" ,
135+ "Raw game data keys: %s | units=%d equipment=%d statProgression=%d skill=%d relicTierDefinition=%d" ,
138136 sorted (raw .keys ()),
139137 len (raw .get ("units" , [])),
140138 len (raw .get ("equipment" , [])),
@@ -193,16 +191,13 @@ def _build_stat_tables(raw_progressions: list[dict[str, Any]]) -> dict[str, dict
193191 tables : dict [str , dict [str , int | float ]] = {}
194192
195193 # Extract only the stattable items from the raw progression collection
196- stat_progression_tables = [table for table in raw_progressions if
197- table .get ('id' , "" ).startswith ('stattable_' )]
194+ stat_progression_tables = [table for table in raw_progressions if table .get ("id" , "" ).startswith ("stattable_" )]
198195
199196 for table in stat_progression_tables :
200197 table_id = table .get ("id" , "" )
201198 table_data : dict [str , int | float ] = {}
202199 for stat in table .get ("stat" , {}).get ("stat" , []):
203- table_data [str (stat .get ("unitStatId" , "" ))] = _num (
204- stat .get ("unscaledDecimalValue" , 0 )
205- )
200+ table_data [str (stat .get ("unitStatId" , "" ))] = _num (stat .get ("unscaledDecimalValue" , 0 ))
206201 tables [table_id ] = table_data
207202 return tables
208203
@@ -252,10 +247,7 @@ def _build_unit_data(
252247 total_units = 0
253248
254249 # Filter for only obtainable units at rarity 1
255- base_unit_list = [
256- unit for unit in raw_units
257- if unit .get ("obtainable" , False ) and unit .get ("obtainableTime" ) == "0"
258- ]
250+ base_unit_list = [unit for unit in raw_units if unit .get ("obtainable" , False ) and unit .get ("obtainableTime" ) == "0" ]
259251
260252 for unit in base_unit_list :
261253 rarity = unit .get ("rarity" , 1 )
@@ -280,13 +272,9 @@ def _build_unit_data(
280272 primary_stat = unit .get ("primaryUnitStat" , 2 )
281273
282274 if combat_type == 1 :
283- data [base_id ] = _build_character (
284- base_id , unit , primary_stat , stat_prog_map , stat_tables , skills_map
285- )
275+ data [base_id ] = _build_character (base_id , unit , primary_stat , stat_prog_map , stat_tables , skills_map )
286276 else :
287- data [base_id ] = _build_ship (
288- base_id , unit , primary_stat , stat_prog_map , stat_tables , skills_map
289- )
277+ data [base_id ] = _build_ship (base_id , unit , primary_stat , stat_prog_map , stat_tables , skills_map )
290278 return data
291279
292280
@@ -304,9 +292,7 @@ def _build_character(
304292 tier_num = str (gt .get ("tier" , 1 ))
305293 tier_stats : dict [str , int | float ] = {}
306294 for s in gt .get ("baseStat" , {}).get ("stat" , []):
307- tier_stats [str (s .get ("unitStatId" , "" ))] = _num (
308- s .get ("unscaledDecimalValue" , 0 )
309- )
295+ tier_stats [str (s .get ("unitStatId" , "" ))] = _num (s .get ("unscaledDecimalValue" , 0 ))
310296 gear_lvl [tier_num ] = {
311297 "gear" : gt .get ("equipmentSet" , []),
312298 "stats" : tier_stats ,
@@ -354,9 +340,7 @@ def _build_ship(
354340 # Base stats
355341 stats : dict [str , int | float ] = {}
356342 for s in unit .get ("baseStat" , {}).get ("stat" , []):
357- stats [str (s .get ("unitStatId" , "" ))] = _num (
358- s .get ("unscaledDecimalValue" , 0 )
359- )
343+ stats [str (s .get ("unitStatId" , "" ))] = _num (s .get ("unscaledDecimalValue" , 0 ))
360344
361345 # Growth modifiers per rarity
362346 growth : dict [str , dict [str , int | float ]] = {}
@@ -375,9 +359,7 @@ def _build_ship(
375359 crew : list [str ] = []
376360 for member in unit .get ("crew" , []):
377361 crew .append (member .get ("unitId" , "" ))
378- crew_skill_refs = _resolve_skills (
379- member .get ("skillReference" , []), skills_map
380- )
362+ crew_skill_refs = _resolve_skills (member .get ("skillReference" , []), skills_map )
381363 skill_refs .extend (crew_skill_refs )
382364
383365 return {
@@ -401,16 +383,15 @@ def _build_gear_data(raw_equipment: list[dict[str, Any]]) -> dict[str, dict[str,
401383 if len (stat_list ) > 0 :
402384 stats : dict [str , int | float ] = {}
403385 for stat in stat_list :
404- stats [str (stat .get ("unitStatId" , "" ))] = _num (
405- stat .get ("unscaledDecimalValue" , 0 )
406- )
386+ stats [str (stat .get ("unitStatId" , "" ))] = _num (stat .get ("unscaledDecimalValue" , 0 ))
407387 data [gear_id ] = {"stats" : stats }
408388 else :
409389 no_stats += 1
410390 if not data :
411391 logger .warning (
412392 "Gear data is empty: %d equipment items received, %d had no statList" ,
413- len (raw_equipment ), no_stats ,
393+ len (raw_equipment ),
394+ no_stats ,
414395 )
415396 return data
416397
@@ -520,9 +501,7 @@ def _build_relic_data(
520501 relic_id = relic .get ("id" , "" )
521502 stats : dict [str , int | float ] = {}
522503 for s in relic .get ("stat" , {}).get ("stat" , []):
523- stats [str (s .get ("unitStatId" , "" ))] = _num (
524- s .get ("unscaledDecimalValue" , 0 )
525- )
504+ stats [str (s .get ("unitStatId" , "" ))] = _num (s .get ("unscaledDecimalValue" , 0 ))
526505 gms = dict (stat_tables .get (relic .get ("relicStatTable" , "" ), {}))
527506 data [relic_id ] = {"stats" : stats , "gms" : gms }
528507 return data
@@ -612,9 +591,7 @@ def _mod_gp_rows(rows: list[dict[str, Any]]) -> dict[str, dict[str, dict[str, fl
612591 if len (parts ) < 4 :
613592 continue
614593 pips , level , tier = parts [0 ], parts [1 ], parts [2 ]
615- out .setdefault (pips , {}).setdefault (level , {})[tier ] = _num (
616- r .get ("value" , 0 )
617- )
594+ out .setdefault (pips , {}).setdefault (level , {})[tier ] = _num (r .get ("value" , 0 ))
618595 return out
619596
620597
@@ -655,7 +632,6 @@ def _gear_piece_gp_rows(rows: list[dict[str, Any]]) -> dict[str, dict[str, float
655632 return out
656633
657634
658-
659635def _ability_special_gp (rows : list [dict [str , Any ]]) -> dict [str , float ]:
660636 """Parse ability-special table for GP (flat key→value)."""
661637 return {r .get ("key" , "" ): _num (r .get ("value" , 0 )) for r in rows }
@@ -691,9 +667,7 @@ def _num(value: Any) -> int | float:
691667 return 0
692668
693669
694- def _resolve_skills (
695- refs : list [dict [str , Any ]], skills_map : dict [str , dict [str , Any ]]
696- ) -> list [dict [str , Any ]]:
670+ def _resolve_skills (refs : list [dict [str , Any ]], skills_map : dict [str , dict [str , Any ]]) -> list [dict [str , Any ]]:
697671 """Map ``skillReferenceList`` entries to resolved skill dicts."""
698672 out : list [dict [str , Any ]] = []
699673 for ref in refs :
0 commit comments