[][src]Trait weasel::actor::ActorRules

pub trait ActorRules<R: BattleRules> {
    type Ability: Id + 'static;
    type AbilitiesSeed: Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>;
    type Activation: Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>;
    type AbilitiesAlteration: Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>;
    fn generate_abilities(
        &self,
        _seed: &Option<Self::AbilitiesSeed>,
        _entropy: &mut Entropy<R>,
        _metrics: &mut WriteMetrics<'_, R>
    ) -> Box<dyn Iterator<Item = Self::Ability>> { ... }
fn activable(
        &self,
        _state: &BattleState<R>,
        _action: Action<'_, R>
    ) -> WeaselResult<(), R> { ... }
fn activate(
        &self,
        _state: &BattleState<R>,
        _action: Action<'_, R>,
        _event_queue: &mut Option<EventQueue<R>>,
        _entropy: &mut Entropy<R>,
        _metrics: &mut WriteMetrics<'_, R>
    ) { ... }
fn alter_abilities(
        &self,
        _actor: &mut dyn Actor<R>,
        _alteration: &Self::AbilitiesAlteration,
        _entropy: &mut Entropy<R>,
        _metrics: &mut WriteMetrics<'_, R>
    ) { ... }
fn on_turn_start(
        &self,
        _state: &BattleState<R>,
        _actor: &dyn Actor<R>,
        _event_queue: &mut Option<EventQueue<R>>,
        _entropy: &mut Entropy<R>,
        _metrics: &mut WriteMetrics<'_, R>
    ) { ... }
fn on_turn_end(
        &self,
        _state: &BattleState<R>,
        _actor: &dyn Actor<R>,
        _event_queue: &mut Option<EventQueue<R>>,
        _entropy: &mut Entropy<R>,
        _metrics: &mut WriteMetrics<'_, R>
    ) { ... } }

Set of rules that handle how abilities are represented and how they can alter the state of the world when activated.

Associated Types

Loading content...

Provided methods

fn generate_abilities(
    &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>

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>
)

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>
)

Alters one or more abilities starting from the given alteration object.

The provided implementation does nothing.

fn on_turn_start(
    &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 turn begins.

The provided implementation does nothing.

fn on_turn_end(
    &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 turn ends.

The provided implementation does nothing.

Loading content...

Implementors

Loading content...