Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
ADD - hasUtp and hasCrisis as combo chain props
Browse files Browse the repository at this point in the history
Signed-off-by: RaenonX <[email protected]>
  • Loading branch information
RaenonX committed Jul 10, 2021
1 parent c97c970 commit 1118306
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dlparse/export/entry/normal_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,30 @@ class NormalAttackBranchedChainEntry(JsonExportableEntryBase):

combos: list[NormalAttackComboEntry] = field(init=False)

has_utp: bool = field(init=False)
has_crisis_mods: bool = field(init=False)

def __post_init__(self, branched_combos: list[NormalAttackComboBranch]):
self.combos = [NormalAttackComboEntry(combo) for combo in branched_combos]
self.has_utp = any(combo.utp_gain > 0 for combo in branched_combos)
self.has_crisis_mods = any(any(combo.crisis_mod) for combo in branched_combos)

@classmethod
@property
def json_schema(cls) -> JsonSchema:
return {
"conditions": [int],
"combos": [NormalAttackComboEntry.json_schema],
"hasUtp": bool,
"hasCrisis": bool,
}

def to_json_entry(self) -> dict[str, Any]:
return {
"conditions": [condition.value for condition in self.conditions.conditions_sorted],
"combos": self.combos,
"hasUtp": self.has_utp,
"hasCrisis": self.has_crisis_mods,
}


Expand Down
33 changes: 33 additions & 0 deletions tests/test_export/test_normal_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,36 @@ def test_exported_json(asset_manager: AssetManager):
for entries in entry_dict.values():
for entry in entries:
is_json_schema_match(NormalAttackChainEntry.json_schema, entry.to_json_entry())


def test_branched_chain_has_utp_has_crisis(asset_manager: AssetManager):
# Bellina (10350503)
# - Mode 12: Unique Transform
# - Unique Combo 12
# - Action ID 300300
chain_data = asset_manager.transformer_atk.transform_normal_attack(300300)
chain_data = NormalAttackChainEntry(asset_manager, 12, chain_data).chain_branches[0]
assert chain_data.has_utp
assert chain_data.has_crisis_mods


def test_branched_chain_has_utp_no_crisis(asset_manager: AssetManager):
# Nino (10150305)
# - Mode 95: Unique Transform
# - Unique Combo 67
# - Action ID 101100
chain_data = asset_manager.transformer_atk.transform_normal_attack(101100)
chain_data = NormalAttackChainEntry(asset_manager, 95, chain_data).chain_branches[0]
assert chain_data.has_utp
assert not chain_data.has_crisis_mods


def test_branched_chain_no_utp_no_crisis(asset_manager: AssetManager):
# Gala Mascula (10250203)
# - Mode 93: Normal
# - Unique Combo 65
# - Action ID 202700
chain_data = asset_manager.transformer_atk.transform_normal_attack(202700)
chain_data = NormalAttackChainEntry(asset_manager, 93, chain_data).chain_branches[0]
assert not chain_data.has_utp
assert not chain_data.has_crisis_mods

0 comments on commit 1118306

Please sign in to comment.