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

pub trait ActorRules<R: BattleRules> {
    type Ability: Id + 'static + Serialize + for<'a> Deserialize<'a>;
    type AbilitiesSeed: Clone + Debug + Serialize + for<'a> Deserialize<'a>;
    type Activation: Clone + Debug + Serialize + for<'a> Deserialize<'a>;
    type AbilitiesAlteration: Clone + Debug + 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, _action: Action<R>) -> bool { ... }
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(
        &self,
        _actor: &mut dyn Actor<R>,
        _alteration: &Self::AbilitiesAlteration,
        _entropy: &mut Entropy<R>,
        _metrics: &mut WriteMetrics<R>
    ) { ... }
fn on_round_start(
        &self,
        _actor: &dyn Actor<R>,
        _event_queue: &mut Option<EventQueue<R>>,
        _entropy: &mut Entropy<R>,
        _metrics: &mut WriteMetrics<R>
    ) { ... }
fn on_round_end(
        &self,
        _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

type Ability: Id + 'static + Serialize + for<'a> Deserialize<'a>

See Ability.

type AbilitiesSeed: Clone + Debug + Serialize + for<'a> Deserialize<'a>

type Activation: Clone + Debug + Serialize + for<'a> Deserialize<'a>

type AbilitiesAlteration: Clone + Debug + Serialize + for<'a> Deserialize<'a>

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, _action: Action<R>) -> bool

Returns true if creature can activate ability with the given activation profile. 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>
)

Activate an ability. ability is guaranteed to be known by 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(
    &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,
    _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,
    _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.

Loading content...

Implementors

Loading content...