Skip to content

Commit

Permalink
feat: implement fatui pyro agent
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Sep 5, 2023
1 parent 189772d commit fc9b23f
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 3 deletions.
7 changes: 5 additions & 2 deletions server/charactor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,25 @@
from .geo import (
GeoCharactorTalents, GeoCharactors, SummonsOfGeoCharactors
)
from .pyro import (
PyroCharactorTalents, PyroCharactors, # SummonsOfPyroCharactors
)
from .old_version import (
OldTalents
)


Charactors = (
Mob | PhysicalMob | MobMage | ElectroCharactors | HydroCharactors
| DendroCharactors | GeoCharactors
| DendroCharactors | GeoCharactors | PyroCharactors
)
SummonsOfCharactors = (
SummonsOfElectroCharactors | SummonsOfHydroCharactors
| SummonsOfDendroCharactors | SummonsOfGeoCharactors
)
CharactorTalents = (
ElectroCharactorTalents | HydroCharactorTalents | DendroCharactorTalents
| GeoCharactorTalents
| GeoCharactorTalents | PyroCharactorTalents
# finally old talents
| OldTalents
)
6 changes: 6 additions & 0 deletions server/charactor/pyro/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .fatui_pyro_agent import FatuiPyroAgent, PaidinFull


PyroCharactors = FatuiPyroAgent | FatuiPyroAgent
# SummonsOfPyroCharactors =
PyroCharactorTalents = PaidinFull | PaidinFull
150 changes: 150 additions & 0 deletions server/charactor/pyro/fatui_pyro_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
from typing import Any, List, Literal

from ...event import CreateObjectEventArguments, GameStartEventArguments
from ...action import Actions, ChangeObjectUsageAction, CreateObjectAction
from ...struct import Cost

from ...consts import (
DamageElementalType, DieColor, ElementType, FactionType,
ObjectPositionType, WeaponType
)
from ..charactor_base import (
ElementalBurstBase, ElementalSkillBase,
PhysicalNormalAttackBase, PassiveSkillBase, CharactorBase, SkillTalent
)


# Skills


class Prowl(ElementalSkillBase):
name: Literal['Prowl'] = 'Prowl'
desc: str = '''Deals 1 Pyro DMG. This character gains Stealth.'''
damage: int = 1
damage_type: DamageElementalType = DamageElementalType.PYRO
cost: Cost = Cost(
elemental_dice_color = DieColor.PYRO,
elemental_dice_number = 3
)

def get_actions(self, match: Any) -> List[Actions]:
"""
Attack and create object
"""
return super().get_actions(match) + [
CreateObjectAction(
object_name = 'Stealth',
object_position = self.position.set_area(
ObjectPositionType.CHARACTOR_STATUS),
object_arguments = {}
)
]


class StealthMaster(PassiveSkillBase):
name: Literal['Stealth Master'] = 'Stealth Master'
desc: str = (
'(Passive) When the battle begins, this character gains Stealth.'
)

def event_handler_GAME_START(
self, event: GameStartEventArguments, match: Any
) -> List[CreateObjectAction]:
"""
When game begin, gain stealth
"""
return [
CreateObjectAction(
object_name = 'Stealth',
object_position = self.position.set_area(
ObjectPositionType.CHARACTOR_STATUS),
object_arguments = {}
)
]


# Talents


class PaidinFull(SkillTalent):
name: Literal['Paid in Full']
desc: str = (
'Combat Action: When your active character is Fatui Pyro Agent, '
'equip this card. After Fatui Pyro Agent equips this card, '
'immediately use Prowl once. When your Fatui Pyro Agent, who has '
'this card equipped, creates a Stealth, it will have the following '
'effect: Starting Usage(s) +1, the Physical DMG the character deals '
'will be converted to Pyro DMG.'
)
version: Literal['3.3'] = '3.3'
charactor_name: Literal['Fatui Pyro Agent'] = 'Fatui Pyro Agent'
cost: Cost = Cost(
elemental_dice_color = DieColor.PYRO,
elemental_dice_number = 3
)
skill: Prowl = Prowl()

def event_handler_CREATE_OBJECT(
self, event: CreateObjectEventArguments, match: Any
) -> List[ChangeObjectUsageAction]:
"""
When create object, check if it is stealth
"""
if self.position.area != ObjectPositionType.CHARACTOR:
# not equipped, do nothing
return []
if not self.position.check_position_valid(
event.action.object_position, match, player_idx_same = True,
charactor_idx_same = True,
target_area = ObjectPositionType.CHARACTOR_STATUS
):
# not self create charactor status, do nothing
return []
if event.action.object_name != 'Stealth':
# not stealth, do nothing
return []
charactor = match.player_tables[
self.position.player_idx].charactors[self.position.charactor_idx]
status = charactor.status[event.create_idx]
assert status.name == 'Stealth'
# add 1 usage
return [ChangeObjectUsageAction(
object_position = status.position,
change_type = 'DELTA',
change_usage = 1
)]

# charactor base


class FatuiPyroAgent(CharactorBase):
name: Literal['Fatui Pyro Agent']
version: Literal['3.3'] = '3.3'
desc: str = '''"Blade of Settlement" Agent'''
element: ElementType = ElementType.PYRO
max_hp: int = 10
max_charge: int = 2
skills: List[
PhysicalNormalAttackBase | Prowl | ElementalBurstBase | StealthMaster
] = []
faction: List[FactionType] = [
FactionType.FATUI
]
weapon_type: WeaponType = WeaponType.OTHER
talent: PaidinFull | None = None

def _init_skills(self) -> None:
self.skills = [
PhysicalNormalAttackBase(
name = 'Thrust',
cost = PhysicalNormalAttackBase.get_cost(self.element),
),
Prowl(),
ElementalBurstBase(
name = 'Blade Ablaze',
damage = 5,
damage_type = DamageElementalType.PYRO,
cost = ElementalBurstBase.get_cost(self.element, 3, 2),
),
StealthMaster()
]
3 changes: 2 additions & 1 deletion server/status/charactor_status/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .system import SystemCharactorStatus
from .pyro_charactors import PyroCharactorStatus
from .dendro_charactors import DendroCharactorStatus
from .geo_charactors import GeoCharactorStatus
from .foods import FoodStatus
Expand All @@ -7,7 +8,7 @@


CharactorStatus = (
DendroCharactorStatus | GeoCharactorStatus
PyroCharactorStatus | DendroCharactorStatus | GeoCharactorStatus
| SystemCharactorStatus | FoodStatus | ArtifactCharactorStatus
| EventCardCharactorStatus
)
69 changes: 69 additions & 0 deletions server/status/charactor_status/pyro_charactors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from typing import Any, Literal

from ...consts import DamageElementalType

from ...modifiable_values import DamageElementEnhanceValue, DamageIncreaseValue
from .base import DefendCharactorStatus


class Stealth(DefendCharactorStatus):
name: Literal['Stealth'] = 'Stealth'
desc: str = (
'The character to which this is attached takes -1 DMG and '
'deals +1 DMG. Usage(s): 2'
)
version: Literal['3.3'] = '3.3'
usage: int = 2
max_usage: int = 2
min_damage_to_trigger: int = 1
max_in_one_time: int = 1

def value_modifier_DAMAGE_ELEMENT_ENHANCE(
self, value: DamageElementEnhanceValue, match: Any,
mode: Literal['TEST', 'REAL']
) -> DamageElementEnhanceValue:
"""
When self use skill, and has talent, change physical to pyro
"""
assert mode == 'REAL'
if not value.is_corresponding_charactor_use_damage_skill(
self.position, match, None
):
# not corresponding charactor use skill, do nothing
return value
if self.usage <= 0: # pragma: no cover
# no usage, do nothing
return value
charactor = match.player_tables[
self.position.player_idx].charactors[self.position.charactor_idx]
if charactor.talent is None:
# no talent, do nothing
return value
# change physical to pyro
if value.damage_elemental_type == DamageElementalType.PHYSICAL:
value.damage_elemental_type = DamageElementalType.PYRO
return value

def value_modifier_DAMAGE_INCREASE(
self, value: DamageIncreaseValue, match: Any,
mode: Literal['TEST', 'REAL']
) -> DamageIncreaseValue:
"""
When self use skill, increase damage by 1
"""
assert mode == 'REAL'
if not value.is_corresponding_charactor_use_damage_skill(
self.position, match, None
):
# not corresponding charactor use damage skill, do nothing
return value
if self.usage <= 0: # pragma: no cover
# no usage, do nothing
return value
# increase damage by 1
value.damage += 1
self.usage -= 1
return value


PyroCharactorStatus = Stealth | Stealth

0 comments on commit fc9b23f

Please sign in to comment.