Skip to content

Commit

Permalink
refactor: not using SkillActionArguments
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Aug 26, 2023
1 parent 8e21b7f commit fe32ed2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 38 deletions.
21 changes: 2 additions & 19 deletions server/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
DamageIncreaseValue, DamageMultiplyValue, DamageDecreaseValue,
)
from .struct import (
SkillActionArguments, ObjectPosition, DiceCost
ObjectPosition, DiceCost
)
from .elemental_reaction import (
check_elemental_reaction,
Expand Down Expand Up @@ -1155,28 +1155,11 @@ def _respond_use_skill(self, response: UseSkillResponse):
value = cost_value,
mode = 'REAL'
) # TODO: should use original value. need test.
skill_action_args = SkillActionArguments(
player_id = response.player_id,
our_active_charactor_id = self.player_tables[
response.player_id].active_charactor_id,
enemy_active_charactor_id = self.player_tables[
1 - response.player_id].active_charactor_id,
our_charactors = [
i for i, c in enumerate(self.player_tables[
response.player_id].charactors)
if c.is_alive
],
enemy_charactors = [
i for i, c in enumerate(self.player_tables[
1 - response.player_id].charactors)
if c.is_alive
],
)
actions: List[Actions] = [RemoveDiceAction(
player_id = response.player_id,
dice_ids = response.cost_ids,
)]
actions += skill.get_actions(skill_action_args) # TODO add information
actions += skill.get_actions(self) # TODO add information
actions.append(SkillEndAction(
player_id = response.player_id,
charactor_id = request.charactor_id,
Expand Down
16 changes: 8 additions & 8 deletions server/object_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
)
from .modifiable_values import ModifiableValueTypes, DamageValue
from .struct import (
SkillActionArguments, ObjectPosition, DiceCost, CardActionTarget
ObjectPosition, DiceCost, CardActionTarget
)
from .interaction import RequestActionType

Expand Down Expand Up @@ -96,7 +96,7 @@ def is_valid(self, hp: int, charge: int) -> bool:
"""
return True

def get_actions(self, args: SkillActionArguments) -> List[Actions]:
def get_actions(self, match: Any) -> List[Actions]:
"""
The skill is triggered, and get actions of the skill.
By default, it will generate three actions:
Expand All @@ -107,13 +107,13 @@ def get_actions(self, args: SkillActionArguments) -> List[Actions]:
"""
return [
ChargeAction(
player_id = args.player_id,
charactor_id = args.our_active_charactor_id,
player_id = self.position.player_id,
charactor_id = self.position.charactor_id,
charge = 1,
),
MakeDamageAction(
player_id = args.player_id,
target_id = 1 - args.player_id,
player_id = self.position.player_id,
target_id = 1 - self.position.player_id,
damage_value_list = [
DamageValue(
position = self.position,
Expand Down Expand Up @@ -228,12 +228,12 @@ def is_valid(self, hp: int, charge: int) -> bool:
"""
return self.charge <= charge

def get_actions(self, args: SkillActionArguments) -> List[Actions]:
def get_actions(self, match: Any) -> List[Actions]:
"""
When using elemental burst, the charge of the active charactor will be
reduced by `self.charge`.
"""
actions = super().get_actions(args)
actions = super().get_actions(match)
for action in actions:
if isinstance(action, ChargeAction):
action.charge = -self.charge
Expand Down
11 changes: 0 additions & 11 deletions server/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,6 @@ class DamageValue(BaseModel):
target_charactor_id: int = -1


class SkillActionArguments(BaseModel):
"""
Arguments used in getting skill actions.
"""
player_id: int
our_active_charactor_id: int
enemy_active_charactor_id: int
our_charactors: List[int]
enemy_charactors: List[int]


class CardActionTarget(BaseModel):
"""
The target of a card action.
Expand Down

0 comments on commit fe32ed2

Please sign in to comment.