Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Sep 2, 2023
1 parent 8203320 commit 6018486
Show file tree
Hide file tree
Showing 4 changed files with 478 additions and 0 deletions.
113 changes: 113 additions & 0 deletions server/charactor/geo/noelle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
from typing import Any, List, Literal

from ...summon.base import DefendSummonBase

from ...modifiable_values import CombatActionValue, DamageIncreaseValue
from ...event import AfterMakeDamageEventArguments, RoundPrepareEventArguments

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

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


class ...(ElementalSkillBase):
name: Literal[...] = ...
desc: str = ...
damage: int = 1
damage_type: DamageElementalType = DamageElementalType.GEO
cost: Cost = Cost(
elemental_dice_number = 3
elemental_dice_color = DieColor.GEO
)

def get_actions(self, match: Any) -> List[Actions]:
ret = super().get_actions(match)
ret.append(CreateObjectAction(
object_name = 'TODO',
object_position = ObjectPosition(
player_idx = self.position.player_idx,
area = ObjectPositionType.TEAM_STATUS,
id = -1
),
object_args = {}
))
return ret


class ...(ElementalBurstBase):
name: Literal[...] = ...
desc: str = ...
damage: int = 4
damage_type: DamageElementalType = DamageElementalType.GEO
cost: Cost = Cost(
elemental_dice_number = 4
elemental_dice_color = DieColor.GEO
charge = 2
)

def get_actions(self, match: Any) -> List[Actions]:
ret = super().get_actions(match)
ret.append(CreateObjectAction(
object_name = 'TODO',
object_position = ObjectPosition(
player_idx = self.position.player_idx,
area = ObjectPositionType.TEAM_STATUS,
id = -1
),
object_args = {}
))
return ret


class ...(SkillTalent):
name: Literal[...] =...
desc: str = ...
version: Literal['3.3'] = '3.3'
charactor_name: Literal['Noelle'] = 'Noelle'
cost: Cost = Cost(
elemental_dice_number = 3 # TODO
elemental_dice_color = DieColor.GEO
)
skill: ... = ...

def event_handler_AFTER_MAKE_DAMAGE(
self, event: AfterMakeDamageEventArguments, match: Any
) -> List[Actions]:
"""
if self charactor use elemental skill, and have status TODO,
then heal all self charactors 1 HP.
"""


class Noelle(CharactorBase):
name: Literal['Noelle']
version: Literal['3.3'] = '3.3'
desc: str = ...
element: ElementType = ElementType.GEO
max_hp: int = 10
max_charge: int = 2
skills: List[
PhysicalNormalAttackBase
] = []
faction: List[FactionType] = [
FactionType.MONDSTADT
]
weapon_type: WeaponType = WeaponType.CLAYMORE

def _init_skills(self) -> None:
self.skills = [
PhysicalNormalAttackBase(
name = 'TODO',
cost = PhysicalNormalAttackBase.get_cost(
ElementType.GEO,
)
)
]
211 changes: 211 additions & 0 deletions server/charactor/hydro/barbara.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
from typing import Any, List, Literal

from server.action import Actions, MakeDamageAction
from server.event import RoundEndEventArguments

from ...summon.base import AttackerSummonBase

from ...modifiable_values import CombatActionValue, CostValue, DamageIncreaseValue
from ...event import RoundPrepareEventArguments

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

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


class MelodyLoop(AttackerSummonBase):
name: Literal['Melody Loop'] = 'Melody Loop'
desc: str = (
'TODO'
)
version: Literal['3.3'] = '3.3'
damage_elemental_type: DamageElementalType = DamageElementalType.HEAL
damage: int = -1
usage: int = 2
max_usage: int = 2

def event_handler_ROUND_END(
self, event: RoundEndEventArguments, match: Any
) -> List[MakeDamageAction]:
player_idx = self.position.player_idx
assert self.usage > 0
self.usage -= 1
target_table = match.player_tables[player_idx]
ret: List[MakeDamageAction] = []
for charactor in target_table.charactors:
if charactor.is_alive:
ret.append(
MakeDamageAction(
source_player_idx = player_idx,
target_player_idx = 1 - player_idx,
damage_value_list = [
DamageValue(
position = self.position,
damage_type = DamageType.HEAL,
target_position = charactor.position,
damage = self.damage,
damage_elemental_type
= self.damage_elemental_type,
cost = self.cost.copy(),
)
],
charactor_change_rule = 'NONE',
)
)
return ret


class LetTheShowBegin(ElementalSkillBase):
name: Literal['Let the Show Begin'] = 'Let the Show Begin'
desc: str = (
'TODO'
)
damage: int = 1
damage_type: DamageElementalType = DamageElementalType.HYDRO
cost: Cost = Cost(
elemental_dice_number = 3
elemental_dice_color = DieColor.HYDRO
)

def get_actions(self, match: Any) -> List[Actions]:
ret = super().get_actions(match)
ret.append(CreateObjectAction(
object_name = 'Melody Loop',
object_position = ObjectPosition(
player_idx = self.positoin.player_idx,
area = ObjectPositionType.SUMMON,
id = -1
),
object_args = {}
))
return ret



class ShiningMiracle(ElementalBurstBase):
name: Literal['Shining Miracle'] = 'Shining Miracle'
desc: str = (
'TODO'
)
damage: int = -4
damage_type: DamageElementalType = DamageElementalType.HEAL
cost: Cost = Cost(
elemental_dice_number = 3
elemental_dice_color = DieColor.HYDRO,
charge = 3
)

def get_actions(self, match: Any) -> List[Actions]:
ret = super().get_actions(match)
ret = ret[:1]
assert len(ret) == 1
assert ret[0].type == ActionTypes.CHARGE
charactors = match.player_tables[self.position.player_idx].charactors
for charactor in charactors:
if charactor.is_alive:
ret.append(MakeDamageAction(
source_player_idx = self.position.player_idx,
target_player_idx = self.position.player_idx,
damage_value_list = [
DamageValue(
position = self.position,
damage_type = DamageType.HEAL,
target_position = charactor.position,
damage = self.damage,
damage_elemental_type = self.damage_type,
cost = self.cost.copy(),
)
],
charactor_change_rule = 'NONE'
))
return ret


class GloriousSeason(SkillTalent):
name: Literal['Glorious Season'] = 'Glorious Season'
desc: str = (
'TODO'
)
version: Literal['3.3'] = '3.3'
charactor_name: Literal['Barbara'] = 'Barbara'
cost: Cost = Cost(
elemental_dice_number = 4
elemental_dice_color = DieColor.HYDRO,
)
skill: LetTheShowBegin = LetTheShowBegin()
usage: int = 1

def event_handler_ROUND_PREPARE(
self, match: Any, event_args: RoundPrepareEventArguments
) -> List[Actions]:
"""reset usage"""
self.usage = 1
return []

def value_modifier_COST(
self, value: CostValue,
match: Any,
mode: Literal['TEST', 'REAL'],
) -> CostValue:
"""
Once per round, if summon "Melody Loop" is valid in our summon area,
and our do switch, and have cost, then cost -1.
"""
if self.usage <= 0:
# no usage, no effect
return value
if value.cost.label & CostLabels.SWITCH_CHARACTOR == 0:
# not switch charatctor, no effect
return value
summons = match.player_tables[self.position.player_idx].summons
have_summon = False
for summon in summons:
if summon.name == 'Melody Loop':
have_summon = True
break
if not have_summon:
# not have summon, no effect
return value
# decrease 1 any cost
if value.cost.decrease_cost(None):
# decrease success
if mode == 'REAL':
self.usage -= 1
return value


class Barbara(CharactorBase):
name: Literal['Barbara']
version: Literal['3.3'] = '3.3'
desc: str = (
'TODO'
)
element: ElementType = ElementType.HYDRO
max_hp: int = 10
max_charge: int = 3
skills: List[
ElementalNormalAttackBase | NormalAttackBase
] = []
faction: List[FactionType] = [
FactionType.MONDSTADT
]
weapon_type: WeaponType = WeaponType.CATALYST

def _init_skills(self) -> None:
self.skills = [
ElementalNormalAttackBase(
name = 'Whisper of Water'
damage_type = DamageElementalType.HYDRO,
cost = ElementalNormalAttackBase.get_cost(
ElementType.HYDRO
)
)
]
Loading

0 comments on commit 6018486

Please sign in to comment.