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

Commit

Permalink
ADD - Parse special EX
Browse files Browse the repository at this point in the history
Signed-off-by: RaenonX <[email protected]>
  • Loading branch information
RaenonX committed Jan 22, 2021
1 parent c4559ed commit b1cf8d3
Show file tree
Hide file tree
Showing 36 changed files with 616 additions and 232 deletions.
4 changes: 4 additions & 0 deletions .data/custom/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
"id": "ENUM_COND_TARGET_DEF_DOWN",
"text": "目標減益: 降防"
},
{
"id": "ENUM_COND_TARGET_ATK_OR_DEF_DOWN",
"text": "目標減益: 降攻/降防"
},
{
"id": "ENUM_COND_TARGET_BUFFED",
"text": "目標有 Buff"
Expand Down
6 changes: 5 additions & 1 deletion .data/custom/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@
},
{
"id": "ENUM_COND_TARGET_DEF_DOWN",
"text": "Target State: Def Down"
"text": "Target State: DEF Down"
},
{
"id": "ENUM_COND_TARGET_ATK_OR_DEF_DOWN",
"text": "Target State: ATK/DEF Down"
},
{
"id": "ENUM_COND_TARGET_BUFFED",
Expand Down
4 changes: 4 additions & 0 deletions .data/custom/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
"id": "ENUM_COND_TARGET_DEF_DOWN",
"text": "目標減益: 降防"
},
{
"id": "ENUM_COND_TARGET_ATK_OR_DEF_DOWN",
"text": "目標減益: 降攻/降防"
},
{
"id": "ENUM_COND_TARGET_BUFFED",
"text": "目標有 Buff"
Expand Down
1 change: 1 addition & 0 deletions dlparse/enums/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .ability_variant import AbilityVariantType
from .action import AbilityTargetAction
from .action_component import ActionCommandType, ActionConditionType
from .action_debuff_type import ActionDebuffType
from .buff_parameter import BuffParameter
from .bullet import FireStockPattern
from .cancel_action import SkillCancelAction
Expand Down
9 changes: 6 additions & 3 deletions dlparse/enums/ability_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ class AbilityCondition(Enum):
NONE = 0

EFF_SELF_HP_GTE = 1
EFF_IS_DRAGON = 5
EFF_IN_DRAGON = 5
TRG_RECEIVED_BUFF_DEF = 8
TRG_SHAPESHIFTED_TO_DRAGON = 12
TRG_SELF_HP_LTE = 14
TRG_QUEST_START = 15
EFF_TARGET_OVERDRIVE = 16
EFF_ENERGIZED = 18
TRG_ENERGIZED = 19
TRG_HIT_WITH_AFFLICTION = 30
EFF_TARGET_AFFLICTED = 20
TRG_GOT_HIT_WITH_AFFLICTION = 30
TRG_SHAPESHIFTED_TO_DRAGON_2 = 31
EFF_SELF_HP_LT = 37
EFF_SELF_SPECIFICALLY_BUFFED = 48
EFF_SELF_BUFFED_ACTION_COND = 48
EFF_TARGET_DEBUFFED = 50
TRG_SHAPESHIFT_COMPLETED = 51
EFF_SELF_HP_GTE_2 = 60
EFF_SELF_HP_LT_2 = 61
Expand Down
44 changes: 34 additions & 10 deletions dlparse/enums/ability_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ class AbilityVariantType(Enum):
"""Variant not used."""

STATUS_UP = 1
"""Raise a certain status."""
"""Buff a certain status."""

RESISTANCE_UP = 2
"""Raise the resistance toward a certain affliction."""
"""Buff the resistance toward a certain affliction."""

SKILL_DMG_UP = 6
"""Raise the character's skill damage. If the variant is inside an ex ability entry, the effect is team-wide."""
DAMAGE_UP = 6
"""Buff the target action damage. If the variant is inside an ex ability entry, the effect is team-wide."""

CRT_RATE_UP = 7
"""Raise the character's CRT rate. If the variant is inside an ex ability entry, the effect is team-wide."""
"""Buff the character's CRT rate. If the variant is inside an ex ability entry, the effect is team-wide."""

RP_UP = 8
"""
Expand All @@ -42,25 +42,43 @@ class AbilityVariantType(Enum):
"""

OD_GAUGE_DMG_UP = 9
"""Raise the damage toward the OD gauge. If the variant is inside an ex ability entry, the effect is team-wide."""
"""Buff the damage toward the OD gauge. If the variant is inside an ex ability entry, the effect is team-wide."""

CHANGE_STATE = 14
"""Calls the hit attribute (at str field) or the action condition (ID at ID-A field) if the condition holds."""
"""Call the hit attribute (at str field) or the action condition (ID at ID-A field) if the condition holds."""

SP_CHARGE = 17
"""Charge the SP gauges."""

BUFF_TIME_UP = 18
"""
Extend the buff time.
If the variant is inside an ex ability entry, the effect is team-wide.
This only applies to the buffs that are directly applied to the user.
Zoned buff like Gala Euden S1 (`10150403`) will not be affected by this.
"""

AFFLICTION_PUNISHER = 20
"""Buff the damage dealt to the target if the target is afflicted by a certain affliction."""

PLAYER_EXP_UP = 21
"""Raises the player EXP gain upon clearing a quest."""
"""Buff the player EXP gain upon clearing a quest."""

ACTION_GRANT = 25
"""Grant a action condition to a specific action."""

CRT_DMG_UP = 26
"""Buff the character's CRT damage. If the variant is inside an ex ability entry, the effect is team-wide."""

DRAGON_DMG_UP = 36
"""Buff the dragon damage."""

GAUGE_STATUS = 40
"""Grants different effects according to the user's gauge status."""
"""Grant different effects according to the user's gauge status."""

HIT_ATTR_SHIFT = 42
"""Shifts the hit attributes."""
"""Shift the hit attributes."""

OTHER_ABILITY = 43
"""Link to another ability (at ID-A field)."""
Expand All @@ -71,9 +89,15 @@ class AbilityVariantType(Enum):
DMG_UP_ON_COMBO = 54
"""Damage up by user combo count."""

ELEM_DMG_UP = 57
"""Buff the elemental damage."""

REMOVE_ALL_STOCK_BULLETS = 60
"""Remove all stock bullets."""

ADDITIONAL_HEAL_ON_REVIVE = 66
"""Receives additional healing based on the receiver's max HP."""

@classmethod
def _missing_(cls, _):
return AbilityVariantType.UNKNOWN
24 changes: 24 additions & 0 deletions dlparse/enums/action_debuff_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Debuff type enum."""
from enum import Enum

__all__ = ("ActionDebuffType",)


class ActionDebuffType(Enum):
"""
Enums of the debuff types.
This is used by the ability condition fields, where if the condition type is ``DEBUFF`` (``50``),
the condition value will be this.
The enum definition can be found in ``Gluon.CharacterBuff.ActionDefDebuff`` in the metadata.
"""

UNKNOWN = -1

DEF_DOWN = 3
ATK_OR_DEF_DOWN = 21

@classmethod
def _missing_(cls, _):
return ActionDebuffType.UNKNOWN
4 changes: 2 additions & 2 deletions dlparse/enums/buff_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BuffParameter(Enum):
Note that the "targeted" here means that the extension is only effective to the buff that targets the players,
such as ATK up buffs.
The duration of the zoned buffs like the one built by Gala Euden (10150403) will **not** be affected by this.
The duration of the zoned buffs like the one built by Gala Euden S1 (101504031) will **not** be affected by this.
"""
# endregion

Expand Down Expand Up @@ -258,7 +258,7 @@ class BuffParameter(Enum):

# region Status
DEF_DOWN_PUNISHER = 740
DEF_OR_ATK_DOWN_PUNISHER = 741
ATK_OR_DEF_DOWN_PUNISHER = 741
OD_STATE_PUNISHER = 742
BK_STATE_PUNISHER = 743
# endregion
Expand Down
17 changes: 15 additions & 2 deletions dlparse/enums/condition/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .items import Condition
# Relative import to avoid circular import
from ..ability_condition import AbilityCondition
from ..action_debuff_type import ActionDebuffType
from ..condition_base import ConditionCheckResultMixin
from ..element import Element
from ..status import Status
Expand All @@ -19,6 +20,7 @@ class ConditionCheckResult(ConditionCheckResultMixin, Enum):
PASS = auto()

MULTIPLE_TARGET_ELEMENT = auto()
MULTIPLE_TARGET_DEBUFF = auto()
MULTIPLE_HP_CONDITION = auto()
MULTIPLE_HP_STATUS = auto()
MULTIPLE_COMBO_COUNT = auto()
Expand All @@ -41,7 +43,8 @@ class ConditionCheckResult(ConditionCheckResultMixin, Enum):
MULTIPLE_MISC = auto()

INTERNAL_NOT_AFFLICTION_ONLY = auto()
INTERNAL_NOT_TARGET_ELEMENTAL = auto()
INTERNAL_NOT_TARGET_ELEMENT = auto()
INTERNAL_NOT_TARGET_DEBUFF = auto()
INTERNAL_NOT_HP_STATUS = auto()
INTERNAL_NOT_HP_CONDITION = auto()
INTERNAL_NOT_COMBO_COUNT = auto()
Expand Down Expand Up @@ -227,7 +230,7 @@ class ConditionCategories:
# region 1xx - Target
target_status = ConditionCategory[Status](
{
# Abnormal statuses
# Afflictions
Condition.TARGET_POISONED: Status.POISON,
Condition.TARGET_BURNED: Status.BURN,
Condition.TARGET_FROZEN: Status.FREEZE,
Expand Down Expand Up @@ -266,6 +269,15 @@ class ConditionCategories:
"Target - element",
ConditionCheckResult.MULTIPLE_TARGET_ELEMENT
)
target_debuff = ConditionCategory[ActionDebuffType](
{
Condition.TARGET_ATK_OR_DEF_DOWN: ActionDebuffType.ATK_OR_DEF_DOWN,
Condition.TARGET_DEF_DOWN: ActionDebuffType.DEF_DOWN,
},
ConditionMaxCount.SINGLE,
"Target - debuff",
ConditionCheckResult.MULTIPLE_TARGET_DEBUFF
)
# endregion

# region 2xx - Self status (general)
Expand Down Expand Up @@ -505,6 +517,7 @@ class ConditionCategories:
trigger = ConditionCategoryGroup(
{
Condition.ON_SELF_BUFFED_DEF,
Condition.ON_SELF_REVIVED,
Condition.ON_SELF_HP_LTE_30,
Condition.ON_HIT_BY_POISON,
Condition.ON_HIT_BY_BURN,
Expand Down
42 changes: 32 additions & 10 deletions dlparse/enums/condition/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

from dlparse.enums.condition_base import ConditionCompositeBase
from dlparse.errors import ConditionValidationFailedError
from dlparse.utils import remove_duplicates_preserve_order
from .category import ConditionCategories as CondCat, ConditionCheckResult
from .items import Condition
from .validate import validate_conditions
# Relative import to avoid circular import
from ..action_debuff_type import ActionDebuffType
from ..element import Element
from ..status import Status

Expand All @@ -23,9 +26,6 @@ class ConditionComposite(ConditionCompositeBase[Condition]):
"""Composite class of various attacking conditions."""

allowed_not_categorize_conds: ClassVar[set[Condition]] = {
# Target state
Condition.TARGET_OD_STATE,
Condition.TARGET_BK_STATE,
# Special self status
Condition.SELF_ENERGIZED,
Condition.SELF_SHAPESHIFT_COMPLETED,
Expand All @@ -46,6 +46,8 @@ class ConditionComposite(ConditionCompositeBase[Condition]):
target_element_converted: Element = field(init=False)
target_in_od: bool = field(init=False)
target_in_bk: bool = field(init=False)
target_debuff: Optional[Condition] = field(init=False)
target_debuff_converted: ActionDebuffType = field(init=False)
# endregion

# region Self status
Expand Down Expand Up @@ -108,7 +110,11 @@ def _init_validate_target(self):

# Check `self.target_element`
if self.target_element and self.target_element not in CondCat.target_element:
raise ConditionValidationFailedError(ConditionCheckResult.INTERNAL_NOT_TARGET_ELEMENTAL)
raise ConditionValidationFailedError(ConditionCheckResult.INTERNAL_NOT_TARGET_ELEMENT)

# Check `self.target_debuff`
if self.target_debuff and self.target_debuff not in CondCat.target_debuff:
raise ConditionValidationFailedError(ConditionCheckResult.INTERNAL_NOT_TARGET_DEBUFF)

def _init_validate_self_general(self):
# Check `self.hp_status`
Expand Down Expand Up @@ -200,6 +206,7 @@ def __post_init__(self, conditions: Optional[Union[Iterable[Condition], Conditio
self.target_element = CondCat.target_element.extract(conditions)
self.target_in_od = Condition.TARGET_OD_STATE in conditions
self.target_in_bk = Condition.TARGET_BK_STATE in conditions
self.target_debuff = CondCat.target_debuff.extract(conditions)

self.hp_status = CondCat.self_hp_status.extract(conditions)
self.hp_condition = CondCat.self_hp_cond.extract(conditions)
Expand Down Expand Up @@ -230,6 +237,7 @@ def __post_init__(self, conditions: Optional[Union[Iterable[Condition], Conditio
CondCat.target_status.convert(condition) for condition in self.afflictions_condition
}
self.target_element_converted = CondCat.target_element.convert(self.target_element, on_missing=None)
self.target_debuff_converted = CondCat.target_debuff.convert(self.target_debuff, on_missing=None)

self.hp_status_converted = CondCat.self_hp_status.convert(self.hp_status, on_missing=1)
self.combo_count_converted = CondCat.self_combo_count.convert(self.combo_count, on_missing=0)
Expand Down Expand Up @@ -261,6 +269,15 @@ def _cond_sorted_target(self) -> tuple[Condition]:
if self.target_element:
ret += (self.target_element,)

if self.target_in_od:
ret += (Condition.TARGET_OD_STATE,)

if self.target_in_bk:
ret += (Condition.TARGET_BK_STATE,)

if self.target_debuff:
ret += (self.target_debuff,)

return ret

def _cond_sorted_self_general(self) -> tuple[Condition]:
Expand Down Expand Up @@ -367,11 +384,16 @@ def conditions_sorted(self) -> tuple[Condition, ...]:
- [Skill] Mark explosion
- [Other] Trigger
"""
return (self._cond_sorted_target()
+ self._cond_sorted_self_general()
+ self._cond_sorted_self_special()
+ self._cond_sorted_skill()
+ self._cond_sorted_others())
# ``Condition.TARGET_DEF_DOWN`` is categorized into both target status and debuff.
# Sorted conditions may yield this condition twice. Therefore removing the duplicates.

conditions: tuple[Condition, ...] = (self._cond_sorted_target()
+ self._cond_sorted_self_general()
+ self._cond_sorted_self_special()
+ self._cond_sorted_skill()
+ self._cond_sorted_others())

return remove_duplicates_preserve_order(conditions)

def get_boost_rate_by_buff(self, hit_attr: "HitAttrEntry", asset_buff_count: "BuffCountAsset"):
"""Get the damage boost rate of ``hit_attr`` under the given condition."""
Expand All @@ -388,7 +410,7 @@ def __iter__(self):
def __bool__(self):
return bool(self.conditions_sorted)

def __add__(self, other):
def __add__(self, other: Optional["ConditionComposite"]):
if other is None:
return self

Expand Down
1 change: 1 addition & 0 deletions dlparse/enums/condition/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Condition(Enum):
# region Abnormal
TARGET_AFFLICTED = 191
TARGET_DEF_DOWN = 192
TARGET_ATK_OR_DEF_DOWN = 195
TARGET_BUFFED = 193
TARGET_DEBUFFED = 194
# endregion
Expand Down
Loading

0 comments on commit b1cf8d3

Please sign in to comment.