Skip to content

Commit

Permalink
feat: implement The Bell
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Sep 3, 2023
1 parent a24fe94 commit 95bdd6a
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 3 deletions.
3 changes: 2 additions & 1 deletion server/card/equipment/weapon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .vanilla import VanillaWeapon
from .other_claymore import Claymores


Weapons = VanillaWeapon | VanillaWeapon
Weapons = VanillaWeapon | Claymores
22 changes: 21 additions & 1 deletion server/card/equipment/weapon/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from ....modifiable_values import DamageIncreaseValue

from ....event import MoveObjectEventArguments
from ....event import MoveObjectEventArguments, RoundPrepareEventArguments

from ....struct import ObjectPosition, Cost

Expand Down Expand Up @@ -116,3 +116,23 @@ def value_modifier_DAMAGE_INCREASE(
# modify damage
value.damage += self.damage_increase
return value


class RoundEffectWeaponBase(WeaponBase):
"""
Weapons that has round effects. Refresh their usage when equipped and
at round preparing stage.
Instead of setting usage, set max_usage_per_round.
"""
usage: int = 0
max_usage_per_round: int

def equip(self, match: Any) -> List[Actions]:
self.usage = self.max_usage_per_round
return []

def event_handler_ROUND_PREPARE(
self, event: RoundPrepareEventArguments, match: Any
):
self.usage = self.max_usage_per_round
return []
59 changes: 59 additions & 0 deletions server/card/equipment/weapon/other_claymore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@


from typing import Any, List, Literal

from ....action import CreateObjectAction

from ....event import SkillEndEventArguments

from .base import RoundEffectWeaponBase

from ....struct import Cost, ObjectPosition

from ....consts import CostLabels, ObjectPositionType, ObjectType, WeaponType


class TheBell(RoundEffectWeaponBase):
name: Literal['The Bell']
desc: str = (
'The character deals +1 DMG. '
'After the character uses a skill: Gives 1 Shield point to your '
'active character. (Once per Round, stacks up to 2 points)'
)
type: Literal[ObjectType.WEAPON] = ObjectType.WEAPON
version: Literal['3.7'] = '3.7'
cost_label: int = CostLabels.CARD.value | CostLabels.WEAPON.value
weapon_type: WeaponType = WeaponType.CLAYMORE

cost: Cost = Cost(same_dice_number = 3)
max_usage_per_round: int = 1

def event_handler_SKILL_END(
self, event: SkillEndEventArguments, match: Any
) -> List[CreateObjectAction]:
"""
If self charactor use any skill, and have usage, create Rebellious
Shield.
"""
if not self.position.check_position_valid(
event.action.position, match, player_idx_same = True,
charactor_idx_same = True, target_area = ObjectPositionType.SKILL
):
# not self charactor use skill
return []
if self.usage == 0:
# no usage
return []
self.usage -= 1
return [CreateObjectAction(
object_name = 'Rebellious Shield',
object_position = ObjectPosition(
player_idx = self.position.player_idx,
area = ObjectPositionType.TEAM_STATUS,
id = -1
),
object_arguments = {}
)]


Claymores = TheBell | TheBell
3 changes: 2 additions & 1 deletion server/status/team_status/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from .dendro_charactors import DendroTeamStatus
from .geo_charactors import GeoTeamStatus
from .event_cards import EventCardTeamStatus
from .weapons import WeaponTeamStatus

from .old_version import OldVersionTeamStatus


TeamStatus = (
SystemTeamStatus | HydroCharactorTeamStatus | DendroTeamStatus
| GeoTeamStatus | EventCardTeamStatus
| GeoTeamStatus | EventCardTeamStatus | WeaponTeamStatus
# finally, old version status
| OldVersionTeamStatus
)
16 changes: 16 additions & 0 deletions server/status/team_status/weapons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from typing import Literal
from .base import ShieldTeamStatus


class RebelliousShield(ShieldTeamStatus):
name: Literal['Rebellious Shield'] = 'Rebellious Shield'
desc: str = (
'Grants 1 Shield point to defend your active charactor. '
'(Can stack. Max 2 Points.)'
)
version: Literal['3.7'] = '3.7'
usage: int = 1
max_usage: int = 2


WeaponTeamStatus = RebelliousShield | RebelliousShield

0 comments on commit 95bdd6a

Please sign in to comment.