Skip to content

Commit

Permalink
feat: implement yoimiya
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Sep 7, 2023
1 parent 62878a3 commit 54925a6
Show file tree
Hide file tree
Showing 7 changed files with 330 additions and 8 deletions.
4 changes: 3 additions & 1 deletion server/charactor/old_version/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from .collei_3_3 import FloralSidewinder_3_3
from .maguu_kenki_3_3 import MaguuKenki_3_3
from .yoimiya_3_3 import Yoimiya_3_3
from .yoimiya_3_4 import Yoimiya_3_4


OldTalents = FloralSidewinder_3_3 | FloralSidewinder_3_3
OldCharactors = MaguuKenki_3_3 | MaguuKenki_3_3
OldCharactors = Yoimiya_3_4 | MaguuKenki_3_3 | Yoimiya_3_3
27 changes: 27 additions & 0 deletions server/charactor/old_version/yoimiya_3_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from typing import List, Literal
from ...consts import DieColor
from ...struct import Cost
from ..pyro.yoimiya import Yoimiya as Y_3_8
from ..pyro.yoimiya import RyuukinSaxifrage as RS_3_8
from ..pyro.yoimiya import FireworkFlareUp, NiwabiFireDance


class RyuukinSaxifrage(RS_3_8):
cost: Cost = Cost(
elemental_dice_color = DieColor.PYRO,
elemental_dice_number = 3,
charge = 2
)


class Yoimiya_3_3(Y_3_8):
version: Literal['3.3']
max_charge: int = 2
skills: List[FireworkFlareUp | NiwabiFireDance | RyuukinSaxifrage] = []

def _init_skills(self) -> None:
self.skills = [
FireworkFlareUp(),
NiwabiFireDance(),
RyuukinSaxifrage()
]
27 changes: 27 additions & 0 deletions server/charactor/old_version/yoimiya_3_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from typing import List, Literal
from ...consts import DieColor
from ...struct import Cost
from ..pyro.yoimiya import Yoimiya as Y_3_8
from ..pyro.yoimiya import RyuukinSaxifrage as RS_3_8
from ..pyro.yoimiya import FireworkFlareUp, NiwabiFireDance


class RyuukinSaxifrage(RS_3_8):
damage: int = 4
cost: Cost = Cost(
elemental_dice_color = DieColor.PYRO,
elemental_dice_number = 4,
charge = 3
)


class Yoimiya_3_4(Y_3_8):
version: Literal['3.4']
skills: List[FireworkFlareUp | NiwabiFireDance | RyuukinSaxifrage] = []

def _init_skills(self) -> None:
self.skills = [
FireworkFlareUp(),
NiwabiFireDance(),
RyuukinSaxifrage()
]
7 changes: 5 additions & 2 deletions server/charactor/pyro/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from .fatui_pyro_agent import FatuiPyroAgent, PaidinFull
from .klee import Klee, PoundingSurprise
from .bennett import Bennett, GrandExpectation
from .yoimiya import Yoimiya, NaganoharaMeteorSwarm


PyroCharactors = FatuiPyroAgent | Klee | Bennett
PyroCharactors = FatuiPyroAgent | Klee | Bennett | Yoimiya
# SummonsOfPyroCharactors =
PyroCharactorTalents = PaidinFull | PoundingSurprise | GrandExpectation
PyroCharactorTalents = (
PaidinFull | PoundingSurprise | GrandExpectation | NaganoharaMeteorSwarm
)
128 changes: 128 additions & 0 deletions server/charactor/pyro/yoimiya.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
from typing import Any, List, Literal

from ...action import Actions, CreateObjectAction
from ...struct import Cost, ObjectPosition

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


# Charactor status. DO NOT define here, define in server/status/characor_status
# Here is just example.


# Skills


class FireworkFlareUp(PhysicalNormalAttackBase):
name: Literal['Firework Flare-Up'] = 'Firework Flare-Up'
cost: Cost = PhysicalNormalAttackBase.get_cost(ElementType.PYRO)


class NiwabiFireDance(ElementalSkillBase):
name: Literal['Niwabi Fire-Dance'] = 'Niwabi Fire-Dance'
desc: str = (
'This character gains Niwabi Enshou. '
'(This Skill does not grant Energy)'
)
damage: int = 0
damage_type: DamageElementalType = DamageElementalType.PIERCING
cost: Cost = Cost(
elemental_dice_color = DieColor.PYRO,
elemental_dice_number = 1
)

def get_actions(self, match: Any) -> List[CreateObjectAction]:
"""
only create object
"""
return [
CreateObjectAction(
object_name = 'Niwabi Enshou',
object_position = self.position.set_area(
ObjectPositionType.CHARACTOR_STATUS),
object_arguments = {}
)
]


class RyuukinSaxifrage(ElementalBurstBase):
name: Literal['Ryuukin Saxifrage'] = 'Ryuukin Saxifrage'
desc: str = '''Deals 3 Pyro DMG, creates 1 Aurous Blaze.'''
damage: int = 3
damage_type: DamageElementalType = DamageElementalType.PYRO
cost: Cost = Cost(
elemental_dice_color = DieColor.PYRO,
elemental_dice_number = 3,
charge = 3
)

def get_actions(self, match: Any) -> List[Actions]:
"""
Attack and create object
"""
position = ObjectPosition(
player_idx = self.position.player_idx,
area = ObjectPositionType.TEAM_STATUS,
id = -1
)
return super().get_actions(match) + [
CreateObjectAction(
object_name = 'Aurous Blaze',
object_position = position,
object_arguments = {}
)
]


# Talents


class NaganoharaMeteorSwarm(SkillTalent):
name: Literal['Naganohara Meteor Swarm']
desc: str = (
'Combat Action: When your active character is Yoimiya, equip this '
'card. After Yoimiya equips this card, immediately use Niwabi '
'Fire-Dance once. After your Yoimiya, who has this card equipped, '
'triggers Niwabi Enshou: Deal 1 additional Pyro DMG.'
)
version: Literal['3.3'] = '3.3'
charactor_name: Literal['Yoimiya'] = 'Yoimiya'
cost: Cost = Cost(
elemental_dice_color = DieColor.PYRO,
elemental_dice_number = 2,
)
skill: NiwabiFireDance = NiwabiFireDance()


# charactor base


class Yoimiya(CharactorBase):
name: Literal['Yoimiya'] # Do not set default value for charactor name
version: Literal['3.8'] = '3.8'
desc: str = '''"Frolicking Flames" Yoimiya'''
element: ElementType = ElementType.PYRO
max_hp: int = 10
max_charge: int = 3
skills: List[
FireworkFlareUp | NiwabiFireDance | RyuukinSaxifrage
] = []
faction: List[FactionType] = [
FactionType.INAZUMA
]
weapon_type: WeaponType = WeaponType.BOW
talent: NaganoharaMeteorSwarm | None = None

def _init_skills(self) -> None:
self.skills = [
FireworkFlareUp(),
NiwabiFireDance(),
RyuukinSaxifrage()
]
99 changes: 95 additions & 4 deletions server/status/charactor_status/pyro_charactors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
from typing import Any, Literal
from typing import Any, List, Literal

from ...struct import Cost

from ...action import MakeDamageAction, RemoveObjectAction

from ...event import MakeDamageEventArguments, SkillEndEventArguments

from ...consts import (
DamageElementalType, DieColor, ObjectPositionType, SkillType
DamageElementalType, DamageType, DieColor, ObjectPositionType, SkillType
)

from ...modifiable_values import (
CostValue, DamageElementEnhanceValue, DamageIncreaseValue
CostValue, DamageElementEnhanceValue, DamageIncreaseValue, DamageValue
)
from .base import (
DefendCharactorStatus, ElementalInfusionCharactorStatus,
Expand Down Expand Up @@ -124,4 +130,89 @@ def value_modifier_COST(
return value


PyroCharactorStatus = Stealth | ExplosiveSpark
class NiwabiEnshou(ElementalInfusionCharactorStatus, UsageCharactorStatus):
name: Literal['Niwabi Enshou'] = 'Niwabi Enshou'
desc: str = (
'The character to which this is attached has their Normal Attacks '
'deal +1 DMG, and their Physical DMG dealt converted to Pyro DMG.'
)
version: Literal['3.3'] = '3.3'
usage: int = 2
max_usage: int = 2
infused_elemental_type: DamageElementalType = DamageElementalType.PYRO

effect_triggered: bool = False

def value_modifier_DAMAGE_INCREASE(
self, value: DamageIncreaseValue, match: Any,
mode: Literal['TEST', 'REAL']
) -> DamageIncreaseValue:
"""
If corresponding charactor use normal attack, increase damage by 1,
and mark effect triggered.
"""
assert mode == 'REAL'
if not value.is_corresponding_charactor_use_damage_skill(
self.position, match, SkillType.NORMAL_ATTACK
):
# not this charactor use normal attack, not modify
return value
# this charactor use normal attack, modify
self.usage -= 1
self.effect_triggered = True
value.damage += 1
return value

def event_handler_MAKE_DAMAGE(
self, event: MakeDamageEventArguments, match: Any
) -> List[RemoveObjectAction]:
"""
do not remove immediately here, as may trigger additional attack at
skill end.
"""
return []

def event_handler_SKILL_END(
self, event: SkillEndEventArguments, match: Any
) -> List[MakeDamageAction | RemoveObjectAction]:
"""
If effect triggered, and have talent on yoimiya, make 1 pyro damage.
If usage is zero, then remove self.
"""
ret: List[MakeDamageAction | RemoveObjectAction] = []
if self.position.player_idx != event.action.position.player_idx:
# not self player use skill
self.effect_triggered = False
return list(self.check_should_remove())
charactor = match.player_tables[self.position.player_idx].charactors[
self.position.charactor_idx]
if (
charactor.name == 'Yoimiya'
and event.action.skill_type == SkillType.NORMAL_ATTACK
and self.effect_triggered
and charactor.talent is not None
):
# yoimiya use normal attack and self effect triggered
# and has talent, attack 1 pyro damage
target = match.player_tables[
1 - self.position.player_idx].get_active_charactor()
ret.append(MakeDamageAction(
source_player_idx = self.position.player_idx,
target_player_idx = 1 - self.position.player_idx,
damage_value_list = [
DamageValue(
position = self.position,
damage_type = DamageType.DAMAGE,
target_position = target.position,
damage = 1,
damage_elemental_type = DamageElementalType.PYRO,
cost = Cost(),
)
]
))
# reset mark
self.effect_triggered = False
return ret + self.check_should_remove()


PyroCharactorStatus = Stealth | ExplosiveSpark | NiwabiEnshou
46 changes: 45 additions & 1 deletion server/status/team_status/pyro_charactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,48 @@ def event_handler_SKILL_END(
)]


PyroTeamStatus = SparksNSplash | InspirationField
class AurousBlaze(RoundTeamStatus):
name: Literal['Aurous Blaze'] = 'Aurous Blaze'
desc: str = (
'After your character other than Yoimiya uses a Skill: '
'Deal 1 Pyro DMG.'
)
version: Literal['3.3'] = '3.3'
usage: int = 2
max_usage: int = 2

def event_handler_SKILL_END(
self, event: SkillEndEventArguments, match: Any
) -> List[MakeDamageAction]:
"""
if skill used by self player but not yoimiya, make damage to opponent
active charactor.
"""
assert self.usage >= 0
if self.position.player_idx != event.action.position.player_idx:
# not self player use skill
return []
charactor = match.player_tables[
self.position.player_idx].get_active_charactor()
if charactor.name == 'Yoimiya':
# yoimiya use skill
return []
target = match.player_tables[
1 - self.position.player_idx].get_active_charactor()
return [MakeDamageAction(
source_player_idx = self.position.player_idx,
target_player_idx = 1 - self.position.player_idx,
damage_value_list = [
DamageValue(
position = self.position,
damage_type = DamageType.DAMAGE,
target_position = target.position,
damage = 1,
damage_elemental_type = DamageElementalType.PYRO,
cost = Cost(),
)
]
)]


PyroTeamStatus = SparksNSplash | InspirationField | AurousBlaze

0 comments on commit 54925a6

Please sign in to comment.