Skip to content

Commit

Permalink
feat: add desc for objects
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Aug 26, 2023
1 parent 37cfa8d commit f24a7e9
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 2 deletions.
7 changes: 7 additions & 0 deletions server/card/equipment/artifact/version_3_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class SmallElementalArtifact(ArtifactBase):
"Witch's Scorching Hat", # pyro
]

desc: str = (
'When the character uses a Skill or equips a Talent: Spend 1 less'
'XXX Die. (Once per Round)'
)
version: Literal["4.0"] = "4.0"
usage: int = 1
cost: DiceCost = DiceCost(any_dice_number=2)
Expand All @@ -43,6 +47,9 @@ def __init__(self, *argv, **kwargs):
self.element = ElementType.HYDRO
elif self.name == "Witch's Scorching Hat":
self.element = ElementType.PYRO
self.desc = self.desc.replace(
"XXX", self.element.value.capitalize()
)

def event_handler_ROUND_PREPARE(self, event: RoundPrepareEventArguments) \
-> list[ActionBase]:
Expand Down
1 change: 1 addition & 0 deletions server/card/event/others.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class Strategize(CardBase):
name: Literal['Strategize']
desc: str = '''Draw 2 cards.'''
version: Literal['3.3'] = '3.3'
cost: DiceCost = DiceCost(
same_dice_number = 1
Expand Down
5 changes: 5 additions & 0 deletions server/card/support/companions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class CompanionBase(SupportBase):

class Rana(CompanionBase):
name: Literal['Rana'] = 'Rana'
desc: str = (
'After your character uses an Elemental Skill: '
'Create 1 Elemental Die of the same Type as your next off-field '
'character. (Once per Round)'
)
version: Literal['3.7'] = '3.7'
cost: DiceCost = DiceCost(same_dice_number = 2)
usage: int = 1
Expand Down
1 change: 1 addition & 0 deletions server/charactor/charactor_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CharactorBase(ObjectBase):
Base class of charactors.
"""
name: str
desc: str
version: str
type: Literal[ObjectType.CHARACTOR] = ObjectType.CHARACTOR
position: ObjectPosition = ObjectPosition(
Expand Down
2 changes: 2 additions & 0 deletions server/charactor/mob.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Mob(CharactorBase):
'DendroMob',
'AnemoMob',
]
desc: str = 'A _NAME_.'
version = '1.0.0'
element: ElementType
hp: int = 10
Expand Down Expand Up @@ -78,3 +79,4 @@ def __init__(self, **kwargs):
charge = 2
)
self.skills = [normal_attack, elemental_skill, elemental_burst]
self.desc = self.desc.replace('_NAME_', self.name)
1 change: 1 addition & 0 deletions server/charactor/physical_mob.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class PhysicalMob(CharactorBase):
Their elemeny type is only used to decide dice color when using skills.
"""
name: Literal['PhysicalMob']
desc: str = 'A PhysicalMob.'
version = '1.0.0'
element: ElementType
hp: int = 10
Expand Down
22 changes: 22 additions & 0 deletions server/object_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class SkillBase(ObjectBase):
Base class of skills.
"""
name: str
desc: str
type: Literal[ObjectType.SKILL] = ObjectType.SKILL
damage_type: DamageElementalType
damage: int
Expand Down Expand Up @@ -136,6 +137,7 @@ class PhysicalNormalAttackBase(SkillBase):
"""
Base class of physical normal attacks.
"""
desc: str = """Deals 2 Physical DMG."""
skill_type: Literal[SkillType.NORMAL_ATTACK] = SkillType.NORMAL_ATTACK
damage_type: DamageElementalType = DamageElementalType.PHYSICAL
damage: int = 2
Expand All @@ -154,11 +156,17 @@ class ElementalNormalAttackBase(SkillBase):
"""
Base class of elemental normal attacks.
"""
desc: str = """Deals 1 XXX DMG."""
skill_type: Literal[SkillType.NORMAL_ATTACK] = SkillType.NORMAL_ATTACK
damage_type: DamageElementalType
damage: int = 1
cost_label: int = DiceCostLabels.NORMAL_ATTACK.value

def __init__(self, *argv, **kwargs):
super().__init__(*argv, **kwargs)
self.desc = self.desc.replace(
'XXX', self.damage_type.value.lower().capitalize())

@staticmethod
def get_cost(element: ElementType) -> DiceCost:
return DiceCost(
Expand All @@ -172,11 +180,17 @@ class ElementalSkillBase(SkillBase):
"""
Base class of elemental skills.
"""
desc: str = """Deals 3 XXX DMG."""
skill_type: Literal[SkillType.ELEMENTAL_SKILL] = SkillType.ELEMENTAL_SKILL
damage_type: DamageElementalType
damage: int = 3
cost_label: int = DiceCostLabels.ELEMENTAL_SKILL.value

def __init__(self, *argv, **kwargs):
super().__init__(*argv, **kwargs)
self.desc = self.desc.replace(
'XXX', self.damage_type.value.lower().capitalize())

@staticmethod
def get_cost(element: ElementType) -> DiceCost:
return DiceCost(
Expand All @@ -189,6 +203,7 @@ class ElementalBurstBase(SkillBase):
"""
Base class of elemental bursts.
"""
desc: str = """Deals %d XXX DMG."""
skill_type: Literal[SkillType.ELEMENTAL_BURST] = SkillType.ELEMENTAL_BURST
damage_type: DamageElementalType
charge: int
Expand All @@ -201,6 +216,12 @@ def get_cost(element: ElementType, number: int) -> DiceCost:
elemental_dice_number = number,
)

def __init__(self, *argv, **kwargs):
super().__init__(*argv, **kwargs)
self.desc = self.desc.replace(
'XXX', self.damage_type.value.lower().capitalize())
self.desc = self.desc.replace('%d', str(self.damage))

def is_valid(self, hp: int, charge: int) -> bool:
"""
Check if the skill can be used.
Expand All @@ -224,6 +245,7 @@ class CardBase(ObjectBase):
Base class of all real cards.
"""
name: str
desc: str
type: Literal[ObjectType.CARD, ObjectType.WEAPON, ObjectType.ARTIFACT,
ObjectType.TALENT, ObjectType.SUMMON,
ObjectType.SUPPORT] = ObjectType.CARD
Expand Down
1 change: 1 addition & 0 deletions server/status/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class StatusBase(ObjectBase):
Base class of status.
"""
name: str
desc: str
version: str
show_usage: bool = True
usage: int
Expand Down
5 changes: 5 additions & 0 deletions server/status/charactor_status/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class Frozen(RoundCharactorStatus):
Frozen.
"""
name: Literal['Frozen'] = 'Frozen'
desc: str = (
'Charactor cannot use skills. (Lasts until the end of this Round) '
'When this charactor receives Pyro DMG or Physical DMG, '
'removes this effect and increases DMG taken by 2.'
)
version: Literal['3.3'] = '3.3'
usage: int = 1
max_usage: int = 1
Expand Down
4 changes: 4 additions & 0 deletions server/status/team_status/old_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class CatalyzingField(UsageTeamStatus):
Catalyzing field.
"""
name: Literal['CatalyzingField'] = 'CatalyzingField'
desc: str = (
'When you deal Electro DMG or Pyro DMG to an opposing active '
'charactor, DMG dealt +1.'
)
version: Literal['3.3']
usage: int = 3
max_usage: int = 3
Expand Down
13 changes: 13 additions & 0 deletions server/status/team_status/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class CatalyzingField(UsageTeamStatus):
Catalyzing field.
"""
name: Literal['CatalyzingField'] = 'CatalyzingField'
desc: str = (
'When you deal Electro DMG or Pyro DMG to an opposing active '
'charactor, DMG dealt +1.'
)
version: Literal['3.4'] = '3.4'
usage: int = 2
max_usage: int = 2
Expand All @@ -24,6 +28,7 @@ def value_modifier_DAMAGE_INCREASE(
mode: Literal['TEST', 'REAL']) -> DamageIncreaseValue:
"""
Increase damage for dendro or electro damages, and decrease usage.
TODO only active charactor will count!
"""
if value.target_player_id == self.position.player_id:
# attack self, not activate
Expand Down Expand Up @@ -53,6 +58,10 @@ class DendroCore(UsageTeamStatus):
Dendro core.
"""
name: Literal['DendroCore'] = 'DendroCore'
desc: str = (
'When you deal Pyro DMG or Electro DMG to an opposing active '
'charactor, DMG dealt +2.'
)
version: Literal['3.3'] = '3.3'
usage: int = 1
max_usage: int = 1
Expand Down Expand Up @@ -88,6 +97,10 @@ class Crystallize(UsageTeamStatus):
Crystallize.
"""
name: Literal['Crystallize'] = 'Crystallize'
desc: str = (
'Grants 1 Shield point to your active charactor. '
'(Can stack. Max 2 Points.)'
)
version: Literal['3.3'] = '3.3'
usage: int = 1
max_usage: int = 2
Expand Down
1 change: 1 addition & 0 deletions server/summon/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class BurningFlame(AttackerSummonBase):
name: Literal['Burning Flame'] = 'Burning Flame'
desc: str = '''End Phase: Deal 1 Pyro DMG. (Can stack. Max 2 stacks.)'''
version: Literal['3.3'] = '3.3'
usage: int = 1
max_usage: int = 2
Expand Down
4 changes: 2 additions & 2 deletions tests/server/test_elemental_reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,14 @@ def test_frozen_and_pyro():
assert match.match_state != MatchState.ERROR


def test_burning_fire():
def test_burning_flame():
"""
agent 0 goes first, sw 2, 1 pyro to p1c2, sw 0, 1 dendro to p1c2, end,
1 dendro to p1c2, end, 1 dendro to p1c2, 1 dendro to p1c2, sw 2,
1 pyro to p1c2, sw 0, 1 dendro to p1c2, end, 1 dendro to p1c2,
sw 2, 1 pyro to p1c2, end.
agent 1 sw2, end, end, end, end.
result: 18 damage and 2 burning fire.
result: 18 damage and 2 burning flame.
"""
agent_0 = InteractionAgent(
player_id = 0,
Expand Down

0 comments on commit f24a7e9

Please sign in to comment.