Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename DurableTrait to BuffTrait #113

Merged
merged 1 commit into from
Dec 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions simaple/simulate/component/complex_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
from simaple.simulate.component.base import ReducerState, reducer_method, view_method
from simaple.simulate.component.entity import Cooldown, Lasting
from simaple.simulate.component.skill import SkillComponent
from simaple.simulate.component.trait.impl import (
DurableTrait,
InvalidatableCooldownTrait,
)
from simaple.simulate.component.trait.impl import BuffTrait, InvalidatableCooldownTrait
from simaple.simulate.component.view import Running
from simaple.simulate.global_property import Dynamics

Expand All @@ -18,7 +15,7 @@ class SynergyState(ReducerState):
dynamics: Dynamics


class SynergySkillComponent(SkillComponent, DurableTrait, InvalidatableCooldownTrait):
class SynergySkillComponent(SkillComponent, BuffTrait, InvalidatableCooldownTrait):
name: str
damage: float
hit: float
Expand Down Expand Up @@ -54,7 +51,7 @@ def use(self, _: None, state: SynergyState):

@reducer_method
def elapse(self, time: float, state: SynergyState):
return self.elapse_durable_trait(time, state)
return self.elapse_buff_trait(time, state)

@view_method
def validity(self, state: SynergyState):
Expand All @@ -69,7 +66,7 @@ def buff(self, state: SynergyState) -> Optional[Stat]:

@view_method
def running(self, state: SynergyState) -> Running:
return self.running_in_durable_trait(state)
return self.running_in_buff_trait(state)

def _get_lasting_duration(self, state: SynergyState) -> float:
return self.lasting_duration
16 changes: 8 additions & 8 deletions simaple/simulate/component/skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)
from simaple.simulate.component.entity import Cooldown, Lasting, Periodic, Stack
from simaple.simulate.component.trait.impl import (
DurableTrait,
BuffTrait,
InvalidatableCooldownTrait,
PeriodicWithSimpleDamageTrait,
UseSimpleAttackTrait,
Expand Down Expand Up @@ -114,7 +114,7 @@ class BuffSkillState(ReducerState):
dynamics: Dynamics


class BuffSkillComponent(SkillComponent, DurableTrait, InvalidatableCooldownTrait):
class BuffSkillComponent(SkillComponent, BuffTrait, InvalidatableCooldownTrait):
stat: Stat
cooldown_duration: float
delay: float
Expand All @@ -129,11 +129,11 @@ def get_default_state(self):

@reducer_method
def use(self, _: None, state: BuffSkillState):
return self.use_durable_trait(state)
return self.use_buff_trait(state)

@reducer_method
def elapse(self, time: float, state: BuffSkillState):
return self.elapse_durable_trait(time, state)
return self.elapse_buff_trait(time, state)

@view_method
def validity(self, state: BuffSkillState):
Expand All @@ -148,7 +148,7 @@ def buff(self, state: BuffSkillState) -> Optional[Stat]:

@view_method
def running(self, state: BuffSkillState) -> Running:
return self.running_in_durable_trait(state)
return self.running_in_buff_trait(state)

def _get_lasting_duration(self, state: BuffSkillState) -> float:
return self.lasting_duration
Expand All @@ -162,7 +162,7 @@ class StackableBuffSkillState(ReducerState):


class StackableBuffSkillComponent(
SkillComponent, DurableTrait, InvalidatableCooldownTrait
SkillComponent, BuffTrait, InvalidatableCooldownTrait
):
stat: Stat
cooldown_duration: float
Expand All @@ -189,15 +189,15 @@ def use(
state.stack.reset()
state.stack.increase()

return self.use_durable_trait(state)
return self.use_buff_trait(state)

@reducer_method
def elapse(
self,
time: float,
state: StackableBuffSkillState,
):
return self.elapse_durable_trait(time, state)
return self.elapse_buff_trait(time, state)

@view_method
def validity(self, state: StackableBuffSkillState):
Expand Down
8 changes: 4 additions & 4 deletions simaple/simulate/component/specific/magician.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from simaple.simulate.component.base import ReducerState, reducer_method, view_method
from simaple.simulate.component.entity import Cooldown, Lasting
from simaple.simulate.component.skill import SkillComponent
from simaple.simulate.component.trait.impl import CooldownValidityTrait, DurableTrait
from simaple.simulate.component.trait.impl import BuffTrait, CooldownValidityTrait
from simaple.simulate.component.view import Running
from simaple.simulate.global_property import Dynamics

Expand All @@ -15,7 +15,7 @@ class InfinityState(ReducerState):
dynamics: Dynamics


class Infinity(SkillComponent, DurableTrait, CooldownValidityTrait):
class Infinity(SkillComponent, BuffTrait, CooldownValidityTrait):
cooldown_duration: float
delay: float
lasting_duration: float
Expand All @@ -33,11 +33,11 @@ def get_default_state(self):

@reducer_method
def use(self, _: None, state: InfinityState):
return self.use_durable_trait(state)
return self.use_buff_trait(state)

@reducer_method
def elapse(self, time: float, state: InfinityState):
return self.elapse_durable_trait(time, state)
return self.elapse_buff_trait(time, state)

@view_method
def validity(self, state: InfinityState):
Expand Down
8 changes: 4 additions & 4 deletions simaple/simulate/component/specific/mechanic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from simaple.simulate.component.keydown_skill import Keydown
from simaple.simulate.component.skill import Cooldown, Lasting, Periodic, SkillComponent
from simaple.simulate.component.trait.impl import (
BuffTrait,
CooldownValidityTrait,
DurableTrait,
PeriodicWithSimpleDamageTrait,
UsePeriodicDamageTrait,
)
Expand Down Expand Up @@ -58,7 +58,7 @@ class RobotSetupBuffState(ReducerState):
dynamics: Dynamics


class RobotSetupBuff(SkillComponent, DurableTrait, CooldownValidityTrait):
class RobotSetupBuff(SkillComponent, BuffTrait, CooldownValidityTrait):
stat: Stat
cooldown_duration: float
delay: float
Expand All @@ -77,11 +77,11 @@ def use(
_: None,
state: RobotSetupBuffState,
):
return self.use_durable_trait(state)
return self.use_buff_trait(state)

@reducer_method
def elapse(self, time: float, state: RobotSetupBuffState):
return self.elapse_durable_trait(time, state)
return self.elapse_buff_trait(time, state)

@view_method
def validity(self, state: RobotSetupBuffState):
Expand Down
8 changes: 4 additions & 4 deletions simaple/simulate/component/specific/pirate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from simaple.core.base import Stat
from simaple.simulate.component.base import ReducerState, reducer_method, view_method
from simaple.simulate.component.skill import Cooldown, Lasting, SkillComponent
from simaple.simulate.component.trait.impl import CooldownValidityTrait, DurableTrait
from simaple.simulate.component.trait.impl import BuffTrait, CooldownValidityTrait
from simaple.simulate.component.view import Running
from simaple.simulate.global_property import Dynamics

Expand All @@ -14,7 +14,7 @@ class PenalizedBuffSkillState(ReducerState):
dynamics: Dynamics


class PenalizedBuffSkill(SkillComponent, CooldownValidityTrait, DurableTrait):
class PenalizedBuffSkill(SkillComponent, CooldownValidityTrait, BuffTrait):
advantage: Stat
disadvantage: Stat
cooldown_duration: float
Expand All @@ -29,11 +29,11 @@ def get_default_state(self):

@reducer_method
def use(self, _: None, state: PenalizedBuffSkillState):
return self.use_durable_trait(state)
return self.use_buff_trait(state)

@reducer_method
def elapse(self, time: float, state: PenalizedBuffSkillState):
return self.elapse_durable_trait(time, state)
return self.elapse_buff_trait(time, state)

@view_method
def validity(self, state: PenalizedBuffSkillState):
Expand Down
8 changes: 4 additions & 4 deletions simaple/simulate/component/trait/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ def use_multiple_damage(
] + [self.event_provider.delayed(delay)]


class DurableTrait(
class BuffTrait(
CooldownTrait, LastingTrait, EventProviderTrait, DelayTrait, NamedTrait
):
def use_durable_trait(
def use_buff_trait(
self,
state: CooldownDynamicsLastingGeneric,
) -> tuple[CooldownDynamicsLastingGeneric, list[Event]]:
Expand All @@ -119,7 +119,7 @@ def use_durable_trait(

return state, [self.event_provider.delayed(self._get_delay())]

def elapse_durable_trait(
def elapse_buff_trait(
self,
time: float,
state: CooldownDynamicsLastingGeneric,
Expand All @@ -133,7 +133,7 @@ def elapse_durable_trait(
self.event_provider.elapsed(time),
]

def running_in_durable_trait(self, state: LastingProtocol) -> Running:
def running_in_buff_trait(self, state: LastingProtocol) -> Running:
return Running(
name=self._get_name(),
time_left=state.lasting.time_left,
Expand Down
11 changes: 4 additions & 7 deletions simaple/simulate/component/triggable_buff_skill.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from simaple.simulate.component.base import ReducerState, reducer_method, view_method
from simaple.simulate.component.entity import Cooldown, Lasting
from simaple.simulate.component.skill import SkillComponent
from simaple.simulate.component.trait.impl import (
DurableTrait,
InvalidatableCooldownTrait,
)
from simaple.simulate.component.trait.impl import BuffTrait, InvalidatableCooldownTrait
from simaple.simulate.component.view import Running
from simaple.simulate.global_property import Dynamics

Expand All @@ -16,7 +13,7 @@ class TriggableBuffState(ReducerState):
dynamics: Dynamics


class TriggableBuffSkill(SkillComponent, DurableTrait, InvalidatableCooldownTrait):
class TriggableBuffSkill(SkillComponent, BuffTrait, InvalidatableCooldownTrait):
trigger_cooldown_duration: float
trigger_damage: float
trigger_hit: float
Expand All @@ -34,7 +31,7 @@ def get_default_state(self):

@reducer_method
def use(self, _: None, state: TriggableBuffState):
return self.use_durable_trait(state)
return self.use_buff_trait(state)

@reducer_method
def elapse(
Expand Down Expand Up @@ -75,7 +72,7 @@ def validity(self, state: TriggableBuffState):

@view_method
def running(self, state: TriggableBuffState) -> Running:
return self.running_in_durable_trait(state)
return self.running_in_buff_trait(state)

def _get_lasting_duration(self, state: TriggableBuffState) -> float:
return self.lasting_duration