Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move data classes to models sub module
- Loading branch information
1 parent
9dabd90
commit 065a0e9
Showing
55 changed files
with
3,406 additions
and
2,994 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
"""Python representations of PlanetSide 2 payloads.""" | ||
|
||
__all__ = [ | ||
'AbilityData', | ||
'AbilityTypeData', | ||
'AchievementData', | ||
'ArmourInfoData', | ||
'CharacterAchievement', | ||
'CharacterData', | ||
'CharacterDirective', | ||
'CurrencyData', | ||
'DirectiveData', | ||
'DirectiveTierData', | ||
'DirectiveTreeCategoryData', | ||
'DirectiveTreeData', | ||
'EffectData', | ||
'EffectTypeData', | ||
'ExperienceData', | ||
'ExperienceRankData', | ||
'FacilityTypeData', | ||
'FactionData', | ||
'FireGroupData', | ||
'FireModeData', | ||
'ItemCategoryData', | ||
'ItemData', | ||
'ItemTypeData', | ||
'LoadoutData', | ||
'MapHexData', | ||
'MapRegionData', | ||
'MarketingBundleData', | ||
'MarketingBundleSingleData', | ||
'MetagameEventData', | ||
'ObjectiveData', | ||
'ObjectiveTypeData', | ||
'OutfitData', | ||
'OutfitMemberData', | ||
'OutfitRankData', | ||
'PlayerStateGroup', | ||
'ProfileData', | ||
'ProjectileData', | ||
'RegionData', | ||
'ResistInfoData', | ||
'ResistTypeData', | ||
'ResourceTypeData', | ||
'RewardData', | ||
'RewardTypeData', | ||
'SkillData', | ||
'SkillCategoryData', | ||
'SkillLineData', | ||
'SkillSetData', | ||
'TitleData', | ||
'VehicleAttachmentData', | ||
'VehicleData', | ||
'WeaponAmmoSlot', | ||
'WeaponData', | ||
'WeaponDatasheet', | ||
'WorldData', | ||
'ZoneData', | ||
'ZoneEffectData', | ||
'ZoneEffectTypeData' | ||
] | ||
|
||
from .ability import AbilityData, AbilityTypeData, ResourceTypeData | ||
from .achievement import AchievementData | ||
from .armour import ArmourInfoData | ||
from .character import (CharacterAchievement, CharacterData, | ||
CharacterDirective, TitleData) | ||
from .currency import CurrencyData | ||
from .depot import MarketingBundleData, MarketingBundleSingleData | ||
from .directive import (DirectiveData, DirectiveTierData, | ||
DirectiveTreeCategoryData, DirectiveTreeData) | ||
from .effect import EffectData, EffectTypeData | ||
from .experience import ExperienceData, ExperienceRankData | ||
from .faction import FactionData | ||
from .fire import FireGroupData, FireModeData | ||
from .item import ItemCategoryData, ItemData, ItemTypeData | ||
from .map import FacilityTypeData, MapHexData, MapRegionData, RegionData | ||
from .metagame import MetagameEventData | ||
from .objective import ObjectiveData, ObjectiveTypeData | ||
from .outfit import OutfitData, OutfitMemberData, OutfitRankData | ||
from .profile import LoadoutData, ProfileData | ||
from .projectile import ProjectileData | ||
from .resist import ResistInfoData, ResistTypeData | ||
from .reward import RewardData, RewardTypeData | ||
from .skill import SkillData, SkillCategoryData, SkillLineData, SkillSetData | ||
from .states import PlayerStateGroup | ||
from .vehicle import VehicleAttachmentData, VehicleData | ||
from .weapon import WeaponAmmoSlot, WeaponData, WeaponDatasheet | ||
from .world import WorldData | ||
from .zone import ZoneData | ||
from .zone_effect import ZoneEffectData, ZoneEffectTypeData |
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,171 @@ | ||
"""Data classes for :mod:`auraxium.ps2.ability`.""" | ||
|
||
import dataclasses | ||
from typing import List, Optional | ||
|
||
from ..base import Ps2Data | ||
from ..types import CensusData | ||
from ..utils import optional | ||
|
||
__all__ = [ | ||
'AbilityData', | ||
'AbilityTypeData', | ||
'ResourceTypeData' | ||
] | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class AbilityData(Ps2Data): | ||
"""Data class for :class:`auraxium.ps2.ability.Ability`. | ||
This class mirrors the payload data returned by the API, you may | ||
use its attributes as keys in filters or queries. | ||
Attributes: | ||
ability_id: The unique ID of this ability. | ||
ability_type_id: The associated ability type for this ability. | ||
expire_msec: The duration of the ability. | ||
first_use_delay_msec: The initial cooldown of the ability. | ||
next_use_delay_msec: The reuse cooldown of the ability. | ||
resource_type_id: The resource type used by the ability. | ||
resource_first_cost: The initial cast cost of the ability. | ||
resource_cost_per_msec: The resource cost per second for | ||
toggled abilities. | ||
distance_max: (Not yet documented) | ||
radius_max: (Not yet documented) | ||
flag_toggle: Whether the ability is toggled. | ||
param*: Type-specific parameters for this ability. Refer to the | ||
corresponding :class:`AbilityType` for details. | ||
string*: Type-specific string values for this ability. Refer to | ||
the corresponding :class:`AbilityType` for details. | ||
""" | ||
|
||
ability_id: int | ||
ability_type_id: int | ||
expire_msec: Optional[int] | ||
first_use_delay_msec: Optional[int] | ||
next_use_delay_msec: Optional[int] | ||
reuse_delay_msec: Optional[int] | ||
resource_type_id: Optional[int] | ||
resource_first_cost: Optional[int] | ||
resource_cost_per_msec: Optional[int] | ||
distance_max: Optional[float] | ||
radius_max: Optional[float] | ||
flag_toggle: Optional[bool] | ||
param1: Optional[str] | ||
param2: Optional[str] | ||
param3: Optional[str] | ||
param4: Optional[str] | ||
param5: Optional[str] | ||
param6: Optional[str] | ||
param7: Optional[str] | ||
param8: Optional[str] | ||
param9: Optional[str] | ||
param10: Optional[str] | ||
param11: Optional[str] | ||
param12: Optional[str] | ||
param13: Optional[str] | ||
param14: Optional[str] | ||
string1: Optional[str] | ||
string2: Optional[str] | ||
string3: Optional[str] | ||
string4: Optional[str] | ||
|
||
@classmethod | ||
def from_census(cls, data: CensusData) -> 'AbilityData': | ||
params: List[Optional[str]] = [ | ||
optional(data, f'param{i+1}', str) for i in range(14)] | ||
strings: List[Optional[str]] = [ | ||
optional(data, f'string{i+1}', str) for i in range(4)] | ||
return cls( | ||
int(data['ability_id']), | ||
int(data['ability_type_id']), | ||
optional(data, 'expire_msec', int), | ||
optional(data, 'first_use_delay_msec', int), | ||
optional(data, 'next_use_delay_msec', int), | ||
optional(data, 'reuse_delay_msec', int), | ||
optional(data, 'resource_type_id', int), | ||
optional(data, 'resource_first_cost', int), | ||
optional(data, 'resource_cost_per_msec', int), | ||
optional(data, 'distance_max', float), | ||
optional(data, 'radius_max', float), | ||
optional(data, 'flag_toggle', bool), | ||
*params, | ||
*strings) | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class AbilityTypeData(Ps2Data): | ||
"""Data class for :class:`auraxium.ps2.ability.AbilityType`. | ||
This class mirrors the payload data returned by the API, you may | ||
use its attributes as keys in filters or queries. | ||
Attributes: | ||
ability_type_id: The unique ID for this ability type. | ||
description: A description of what this ability type is used | ||
for. | ||
param*: Descriptions of what the corresponding parameter is | ||
used for in abilities of this type. | ||
string*: Descriptions of what the corresponding string value is | ||
used for in abilities of this type. | ||
""" | ||
|
||
ability_type_id: int | ||
description: Optional[str] | ||
param1: Optional[str] | ||
param2: Optional[str] | ||
param3: Optional[str] | ||
param4: Optional[str] | ||
param5: Optional[str] | ||
param6: Optional[str] | ||
param7: Optional[str] | ||
param8: Optional[str] | ||
param9: Optional[str] | ||
param10: Optional[str] | ||
param11: Optional[str] | ||
param12: Optional[str] | ||
param13: Optional[str] | ||
param14: Optional[str] | ||
string1: Optional[str] | ||
string2: Optional[str] | ||
string3: Optional[str] | ||
string4: Optional[str] | ||
|
||
@classmethod | ||
def from_census(cls, data: CensusData) -> 'AbilityTypeData': | ||
params: List[Optional[str]] = [ | ||
optional(data, f'param{i+1}', str) for i in range(14)] | ||
strings: List[Optional[str]] = [ | ||
optional(data, f'string{i+1}', str) for i in range(4)] | ||
return cls( | ||
int(data['ability_type_id']), | ||
optional(data, 'description', str), | ||
*params, | ||
*strings) | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class ResourceTypeData(Ps2Data): | ||
"""Data class for :class:`auraxium.ps2.ability.ResourceType`. | ||
This class mirrors the payload data returned by the API, you may | ||
use its attributes as keys in filters or queries. | ||
Attributes: | ||
resource_type_id: The unique ID of this resource type. | ||
description: A description of what this resource type is used | ||
for. | ||
""" | ||
|
||
resource_type_id: int | ||
description: str | ||
|
||
@classmethod | ||
def from_census(cls, data: CensusData) -> 'ResourceTypeData': | ||
return cls( | ||
int(data['resource_type_id']), | ||
str(data['description'])) |
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,62 @@ | ||
"""Data classes for :mod:`auraxium.ps2.achievement`.""" | ||
|
||
import dataclasses | ||
|
||
from ..base import Ps2Data | ||
from ..types import CensusData | ||
from ..utils import LocaleData | ||
|
||
__all__ = [ | ||
'AchievementData' | ||
] | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class AchievementData(Ps2Data): | ||
"""Data class for :class:`auraxium.ps2.achievement.Achievement`. | ||
This class mirrors the payload data returned by the API, you may | ||
use its attributes as keys in filters or queries. | ||
Attributes: | ||
achievement_id: The unique ID of this achievement. | ||
item_id: The item associated with this achievement. An item ID | ||
of ``0`` signifies that this achievement is a ribbon not | ||
tied to any weapon. | ||
objective_group_id: The objective group tied to this | ||
achievement. | ||
reward_id: The reward granted when this achievement is earned. | ||
repeatable: Whether this achievement is repeatable. Ribbons | ||
generally are repeatable, weapon medals are not. | ||
name: The localised name of the achievement. | ||
description: The localised description of achievement. | ||
image_set_id: The image set associated with this achievement. | ||
image_id: The default image for this achievement. | ||
image_path: The image path for this achievement. | ||
""" | ||
|
||
achievement_id: int | ||
item_id: int | ||
objective_group_id: int | ||
reward_id: int | ||
repeatable: bool | ||
name: LocaleData | ||
description: LocaleData | ||
image_set_id: int | ||
image_id: int | ||
image_path: str | ||
|
||
@classmethod | ||
def from_census(cls, data: CensusData) -> 'AchievementData': | ||
return cls( | ||
int(data['achievement_id']), | ||
int(data['item_id']), | ||
int(data['objective_group_id']), | ||
int(data['reward_id']), | ||
bool(int(data['repeatable'])), | ||
LocaleData.from_census(data['name']), | ||
LocaleData.from_census(data['description']), | ||
int(data['image_set_id']), | ||
int(data['image_id']), | ||
str(data['image_path'])) |
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,46 @@ | ||
"""Data classes for :mod:`auraxium.ps2.armour`.""" | ||
|
||
import dataclasses | ||
from typing import Optional | ||
|
||
from ..base import Ps2Data | ||
from ..utils import optional | ||
from ..types import CensusData | ||
|
||
__all__ = [ | ||
'ArmourInfoData' | ||
] | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class ArmourInfoData(Ps2Data): | ||
"""Data class for :class:`auraxium.ps2.armour.ArmorInfo`. | ||
This class mirrors the payload data returned by the API, you may | ||
use its attributes as keys in filters or queries. | ||
Attributes: | ||
armor_info_id: The unique ID of this entry. | ||
armor_facing_id: The enum value the facing direction this entry | ||
provides armour data for. | ||
armor_percent: Damage reduction in percent. | ||
armor_amount: A flat damage absorption applied to the damage | ||
effect; generally unused. | ||
description: A description for this entry. | ||
""" | ||
|
||
armor_info_id: int | ||
armor_facing_id: int | ||
armor_percent: int | ||
armor_amount: Optional[int] | ||
description: str | ||
|
||
@classmethod | ||
def from_census(cls, data: CensusData) -> 'ArmourInfoData': | ||
return cls( | ||
int(data['armor_info_id']), | ||
int(data['armor_facing_id']), | ||
int(data['armor_percent']), | ||
optional(data, 'armor_amount', int), | ||
str(data['description'])) |
Oops, something went wrong.