This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: RaenonX <[email protected]>
- Loading branch information
Showing
17 changed files
with
210 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""Enums for different mode of a quest.""" | ||
from enum import Enum | ||
|
||
__all__ = ("QuestMode",) | ||
|
||
|
||
class QuestMode(Enum): | ||
""" | ||
Enum for the quest mode. | ||
The number corresponds to the field ``_QuestPlayModeType`` in quest data asset. | ||
The definition can be found in ``Gluon.QuestPlayModeType`` of the application metadata. | ||
""" | ||
|
||
NONE = 0 | ||
NORMAL = 1 | ||
SOLO = 2 | ||
MULTI = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Models for a quest data.""" | ||
from dataclasses import InitVar, dataclass, field | ||
from typing import TYPE_CHECKING | ||
|
||
from dlparse.enums import Element, QuestMode | ||
|
||
if TYPE_CHECKING: | ||
from dlparse.mono.asset import QuestDataEntry | ||
from dlparse.mono.manager import AssetManager | ||
|
||
__all__ = ("QuestData",) | ||
|
||
|
||
@dataclass | ||
class QuestData: | ||
"""A transformed quest data.""" | ||
|
||
asset_manager: InitVar["AssetManager"] | ||
|
||
quest_data: "QuestDataEntry" | ||
|
||
quest_mode: QuestMode = field(init=False) | ||
elements: list[Element] = field(init=False) | ||
elements_limit: list[Element] = field(init=False) | ||
|
||
max_clear_time_sec: int = field(init=False) | ||
max_revive_allowed: int = field(init=False) | ||
area_1_name: str = field(init=False) | ||
spawn_enemy_param_ids: list[int] = field(init=False) | ||
|
||
def __post_init__(self, asset_manager: "AssetManager"): | ||
# Quest basic properties | ||
self.quest_mode = self.quest_data.quest_mode | ||
self.elements = [ | ||
Element(elem) for elem | ||
in (self.quest_data.element_1, self.quest_data.element_2) | ||
if elem.is_valid | ||
] | ||
self.elements_limit = [ | ||
Element(elem) for elem | ||
in (self.quest_data.element_1_limit, self.quest_data.element_2_limit) | ||
if elem.is_valid | ||
] | ||
|
||
self.max_clear_time_sec = self.quest_data.max_time_sec | ||
self.max_revive_allowed = self.quest_data.max_revive | ||
|
||
# Quest dungeon area | ||
self.area_1_name = self.quest_data.area_1_name | ||
dungeon_plan = asset_manager.asset_dungeon_planner.get_data_by_id(self.area_1_name) | ||
|
||
# --- ``variation_idx`` is 1-based index | ||
|
||
self.spawn_enemy_param_ids = dungeon_plan.enemy_param_ids[self.quest_data.variation_idx - 1] | ||
if not self.spawn_enemy_param_ids: | ||
# In Legend Ciella quest, variation type is 4 while the only enemy parameter related is located at 0 | ||
# This will attempt to take the data at variation 0 | ||
self.spawn_enemy_param_ids = dungeon_plan.enemy_param_ids[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Various transformers to "transform" the data.""" | ||
from .ability import AbilityTransformer | ||
from .enemy import EnemyTransformer | ||
from .quest import QuestTransformer | ||
from .skill import SkillHitData, SkillTransformer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Quest data transformer.""" | ||
from typing import TYPE_CHECKING | ||
|
||
from dlparse.model import QuestData | ||
|
||
if TYPE_CHECKING: | ||
from dlparse.mono.manager import AssetManager | ||
|
||
__all__ = ("QuestTransformer",) | ||
|
||
|
||
class QuestTransformer: | ||
"""Class to transform a quest data.""" | ||
|
||
# pylint: disable=too-few-public-methods | ||
|
||
def __init__(self, asset_manager: "AssetManager"): | ||
self._asset_manager: "AssetManager" = asset_manager | ||
|
||
def transform_quest_data(self, quest_id: int) -> QuestData: | ||
"""Transform ``enemy_param_id`` to an enemy info.""" | ||
quest_data = self._asset_manager.asset_quest_data.get_data_by_id(quest_id) | ||
|
||
return QuestData(self._asset_manager, quest_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from dlparse.enums import Element, QuestMode | ||
from dlparse.transformer import QuestTransformer | ||
|
||
|
||
def test_lilith_enchroaching_shadow_expert_solo(transformer_quest: QuestTransformer): | ||
# Lilith's Encroaching Shadow (Expert) - Solo | ||
# https://dl.raenonx.cc/quest/13#pos-4 | ||
quest_data = transformer_quest.transform_quest_data(228050102) | ||
|
||
assert quest_data.quest_mode == QuestMode.MULTI | ||
assert quest_data.elements == [Element.SHADOW] | ||
assert quest_data.elements_limit == [] | ||
assert quest_data.max_clear_time_sec == 600 | ||
assert quest_data.max_revive_allowed == 1 | ||
assert quest_data.area_1_name == "DIABOLOS_05_0101_01" | ||
assert quest_data.spawn_enemy_param_ids == [228050201] | ||
|
||
|
||
def test_lilith_enchroaching_shadow_master_solo(transformer_quest: QuestTransformer): | ||
# Lilith's Encroaching Shadow (Expert) - Solo | ||
# https://dl.raenonx.cc/quest/13#pos-4 | ||
quest_data = transformer_quest.transform_quest_data(228051103) | ||
|
||
assert quest_data.quest_mode == QuestMode.SOLO | ||
assert quest_data.elements == [Element.SHADOW, Element.FLAME] | ||
assert quest_data.elements_limit == [Element.LIGHT, Element.WATER] | ||
assert quest_data.max_clear_time_sec == 600 | ||
assert quest_data.max_revive_allowed == 0 | ||
assert quest_data.area_1_name == "DIABOLOS_05_0111_02" | ||
assert quest_data.spawn_enemy_param_ids == [228051301] | ||
|
||
|
||
def test_legend_ciella_solo(transformer_quest: QuestTransformer): | ||
# Legend Ciella - Solo | ||
quest_data = transformer_quest.transform_quest_data(225031101) | ||
|
||
assert quest_data.quest_mode == QuestMode.SOLO | ||
assert quest_data.elements == [Element.WATER] | ||
assert quest_data.elements_limit == [Element.WIND] | ||
assert quest_data.max_clear_time_sec == 600 | ||
assert quest_data.max_revive_allowed == 0 | ||
assert quest_data.area_1_name == "AGITO_ABS_03_1102_01" | ||
assert quest_data.spawn_enemy_param_ids == [225031401] | ||
|
||
|
||
def test_legend_ciella_coop(transformer_quest: QuestTransformer): | ||
# Legend Ciella - Coop | ||
quest_data = transformer_quest.transform_quest_data(225030101) | ||
|
||
assert quest_data.quest_mode == QuestMode.MULTI | ||
assert quest_data.elements == [Element.WATER] | ||
assert quest_data.elements_limit == [Element.WIND] | ||
assert quest_data.max_clear_time_sec == 480 | ||
assert quest_data.max_revive_allowed == 0 | ||
assert quest_data.area_1_name == "AGITO_ABS_03_0102_01" | ||
assert quest_data.spawn_enemy_param_ids == [225030401] |