From 95bdd6a62c6a783e521392b543195037ff3510f1 Mon Sep 17 00:00:00 2001 From: zyr17 Date: Sun, 3 Sep 2023 15:42:41 +0800 Subject: [PATCH] feat: implement The Bell --- server/card/equipment/weapon/__init__.py | 3 +- server/card/equipment/weapon/base.py | 22 ++++++- .../card/equipment/weapon/other_claymore.py | 59 +++++++++++++++++++ server/status/team_status/__init__.py | 3 +- server/status/team_status/weapons.py | 16 +++++ 5 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 server/card/equipment/weapon/other_claymore.py create mode 100644 server/status/team_status/weapons.py diff --git a/server/card/equipment/weapon/__init__.py b/server/card/equipment/weapon/__init__.py index 0360daf7..408641a6 100644 --- a/server/card/equipment/weapon/__init__.py +++ b/server/card/equipment/weapon/__init__.py @@ -1,4 +1,5 @@ from .vanilla import VanillaWeapon +from .other_claymore import Claymores -Weapons = VanillaWeapon | VanillaWeapon +Weapons = VanillaWeapon | Claymores diff --git a/server/card/equipment/weapon/base.py b/server/card/equipment/weapon/base.py index 6e30d537..c35f5c4b 100644 --- a/server/card/equipment/weapon/base.py +++ b/server/card/equipment/weapon/base.py @@ -2,7 +2,7 @@ from ....modifiable_values import DamageIncreaseValue -from ....event import MoveObjectEventArguments +from ....event import MoveObjectEventArguments, RoundPrepareEventArguments from ....struct import ObjectPosition, Cost @@ -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 [] diff --git a/server/card/equipment/weapon/other_claymore.py b/server/card/equipment/weapon/other_claymore.py new file mode 100644 index 00000000..40e065ea --- /dev/null +++ b/server/card/equipment/weapon/other_claymore.py @@ -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 diff --git a/server/status/team_status/__init__.py b/server/status/team_status/__init__.py index 9b1e8a0b..d19d1d9e 100644 --- a/server/status/team_status/__init__.py +++ b/server/status/team_status/__init__.py @@ -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 ) diff --git a/server/status/team_status/weapons.py b/server/status/team_status/weapons.py new file mode 100644 index 00000000..d6e3821c --- /dev/null +++ b/server/status/team_status/weapons.py @@ -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