feat(abilities): update abilities structure for CSEC(V-Union Pokemon)

main
beiyanpiki 11 months ago
parent 9985b5c6e6
commit 79124e1840

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -218,18 +218,15 @@ def get_pokemon_attr(card) -> PokemonAttr:
stage = get_stage(card)
hp = card['details']['hp']
abilities = []
# Before CSEC, a Pokémon only have multi abilities.
if 'featureName' in card['details'] and 'featureText' in card['details']:
ability = (card['details'].get('featureName', None), card['details'].get('featureText', None))
# After CSEC, Raw data change it ability structure
abilities.append(Ability(card['details'].get('featureName', None), card['details'].get('featureText', None)))
# After CSEC, a Pokémon may have multi abilities, raw data change it ability structure,
elif 'cardFeatureItemList' in card['details']:
ability = (card['details']['cardFeatureItemList'][0]['featureName'],
card['details']['cardFeatureItemList'][0]['featureDesc'])
else:
ability = None
if ability is not None:
ability = Ability(ability[0], ability[1])
else:
ability = None
for feat in card['details']['cardFeatureItemList']:
abilities.append(Ability(feat['featureName'], feat['featureDesc']))
ancient_trait = None
weakness_type = card['details'].get('weaknessType', None)
@ -264,7 +261,7 @@ def get_pokemon_attr(card) -> PokemonAttr:
atk = Attack(atk_name, atk_text, atk_cost, atk_damage)
attacks.append(atk)
return PokemonAttr(energy_type, stage, hp, ability, ancient_trait, weakness, resistance, retreat_cost, pokedex,
return PokemonAttr(energy_type, stage, hp, abilities, ancient_trait, weakness, resistance, retreat_cost, pokedex,
attacks)

@ -151,7 +151,7 @@ class PokemonAttr:
energy_type: Energy
stage: Stage
hp: int
ability: Optional[Ability]
ability: List[Ability]
ancient_trait: Optional[AncientTrait]
weakness: Optional[Energy]
resistance: Optional[Resistance]
@ -163,7 +163,7 @@ class PokemonAttr:
energy_type: Energy,
stage: Stage,
hp: int,
ability: Optional[Ability],
ability: List[Ability],
ancient_trait: Optional[AncientTrait],
weakness: Optional[Energy],
resistance: Optional[Resistance],
@ -187,7 +187,7 @@ class PokemonAttr:
'energy_type': self.energy_type.value,
'stage': self.stage.value,
'hp': self.hp,
'ability': self.ability.__json__() if self.ability else None,
'ability': [ability.__json__() for ability in self.ability],
'ancient_trait': self.ancient_trait.value if self.ancient_trait else None,
'weakness': self.weakness.value if self.weakness else None,
'resistance': self.resistance.__json__() if self.resistance else None,
@ -278,7 +278,7 @@ class Card:
f"{self.pokemon_attr.stage.value}|"
f"{self.pokemon_attr.hp}|"
f"{self.pokemon_attr.energy_type.value}|"
f"{self.pokemon_attr.ability.name if self.pokemon_attr.ability else ''}|"
f"{[f'{ability.name}' for ability in self.pokemon_attr.ability]}|"
f"{[f'{attack.name}|{attack.text}|{attack.damage}' for attack in self.pokemon_attr.attacks]}|"
f"{self.pokemon_attr.weakness.value if self.pokemon_attr.weakness else ''}|"
f"{self.pokemon_attr.resistance.resistance_type.value if self.pokemon_attr.resistance else ''}|"

Loading…
Cancel
Save