[−][src]Trait weasel::actor::ActorRules
Set of rules that handle how abilities are represented and how they can alter the state of the world when activated.
Associated Types
type Ability: Id + 'static
See Ability.
type AbilitiesSeed: Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>
See AbilitiesSeed.
type Activation: Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>
See Activation.
type AbilitiesAlteration: Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>
See AbilitiesAlteration.
Provided methods
fn generate_abilities(
&self,
_seed: &Option<Self::AbilitiesSeed>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
) -> Box<dyn Iterator<Item = Self::Ability>>
&self,
_seed: &Option<Self::AbilitiesSeed>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
) -> Box<dyn Iterator<Item = Self::Ability>>
Generates all abilities of an actor. Abilities should have unique ids, otherwise only the last entry will be persisted.
The provided implementation generates an empty set of abilities.
fn activable(
&self,
_state: &BattleState<R>,
_action: Action<R>
) -> WeaselResult<(), R>
&self,
_state: &BattleState<R>,
_action: Action<R>
) -> WeaselResult<(), R>
Returns Ok
if action.actor
can activate action.ability
with action.activation
,
otherwise returns an error describing the issue preventing the activation.
The ability is guaranteed to be known by the actor.
The provided implementation accepts any activation.
fn activate(
&self,
_state: &BattleState<R>,
_action: Action<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
&self,
_state: &BattleState<R>,
_action: Action<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
Activates an ability.
action.ability
is guaranteed to be known by action.actor
.
In order to change the state of the world, abilities should insert
event prototypes in event_queue
.
The provided implementation does nothing.
fn alter_abilities(
&self,
_actor: &mut dyn Actor<R>,
_alteration: &Self::AbilitiesAlteration,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
&self,
_actor: &mut dyn Actor<R>,
_alteration: &Self::AbilitiesAlteration,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
Alters one or more abilities starting from the given alteration object.
The provided implementation does nothing.
fn on_round_start(
&self,
_state: &BattleState<R>,
_actor: &dyn Actor<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
&self,
_state: &BattleState<R>,
_actor: &dyn Actor<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
Invoked when a new round begins.
The provided implementation does nothing.
fn on_round_end(
&self,
_state: &BattleState<R>,
_actor: &dyn Actor<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
&self,
_state: &BattleState<R>,
_actor: &dyn Actor<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
Invoked when the current round ends.
The provided implementation does nothing.