[][src]Struct weasel::character::RegenerateStatistics

pub struct RegenerateStatistics<R: BattleRules> { /* fields omitted */ }

An event to regenerate the statistics of a character.

A new set of statistics is created from a seed.

  • Statistics already present in the character won't be modified.
  • Statistics that the character didn't have before will be added.
  • Current character's statistics that are not present in the new set will be removed from the character.

Examples

use weasel::{
    battle_rules, rules::empty::*, Battle, BattleController, BattleRules, CreateCreature,
    CreateTeam, EntityId, EventKind, EventTrigger, RegenerateStatistics, Server,
};

battle_rules! {}

let battle = Battle::builder(CustomRules::new()).build();
let mut server = Server::builder(battle).build();

let team_id = 1;
CreateTeam::trigger(&mut server, team_id).fire().unwrap();
let creature_id = 1;
let position = ();
CreateCreature::trigger(&mut server, creature_id, team_id, position)
    .fire()
    .unwrap();

RegenerateStatistics::trigger(&mut server, EntityId::Creature(creature_id))
    .fire()
    .unwrap();
assert_eq!(
    server.battle().history().events().iter().last().unwrap().kind(),
    EventKind::RegenerateStatistics
);

Implementations

impl<R: BattleRules> RegenerateStatistics<R>[src]

pub fn trigger<P: EventProcessor<R>>(
    processor: &mut P,
    id: EntityId<R>
) -> RegenerateStatisticsTrigger<'_, R, P>
[src]

Returns a trigger for this event.

pub fn id(&self) -> &EntityId<R>[src]

Returns the character's entity id.

pub fn seed(&self) -> &Option<StatisticsSeed<R>>[src]

Returns the seed to regenerate the character's statistics.

Trait Implementations

impl<R: BattleRules> Clone for RegenerateStatistics<R>[src]

impl<R: BattleRules> Debug for RegenerateStatistics<R>[src]

impl<'de, R: BattleRules> Deserialize<'de> for RegenerateStatistics<R> where
    EntityId<R>: Deserialize<'de>,
    Option<StatisticsSeed<R>>: Deserialize<'de>, 
[src]

impl<R: BattleRules + 'static> Event<R> for RegenerateStatistics<R>[src]

impl<R: BattleRules> Serialize for RegenerateStatistics<R> where
    EntityId<R>: Serialize,
    Option<StatisticsSeed<R>>: Serialize
[src]

Auto Trait Implementations

impl<R> RefUnwindSafe for RegenerateStatistics<R> where
    <<R as BattleRules>::CR as CharacterRules<R>>::CreatureId: RefUnwindSafe,
    <<R as BattleRules>::CR as CharacterRules<R>>::ObjectId: RefUnwindSafe,
    <<R as BattleRules>::CR as CharacterRules<R>>::StatisticsSeed: RefUnwindSafe

impl<R> Send for RegenerateStatistics<R> where
    <<R as BattleRules>::CR as CharacterRules<R>>::CreatureId: Send,
    <<R as BattleRules>::CR as CharacterRules<R>>::ObjectId: Send,
    <<R as BattleRules>::CR as CharacterRules<R>>::StatisticsSeed: Send

impl<R> Sync for RegenerateStatistics<R> where
    <<R as BattleRules>::CR as CharacterRules<R>>::CreatureId: Sync,
    <<R as BattleRules>::CR as CharacterRules<R>>::ObjectId: Sync,
    <<R as BattleRules>::CR as CharacterRules<R>>::StatisticsSeed: Sync

impl<R> Unpin for RegenerateStatistics<R> where
    <<R as BattleRules>::CR as CharacterRules<R>>::CreatureId: Unpin,
    <<R as BattleRules>::CR as CharacterRules<R>>::ObjectId: Unpin,
    <<R as BattleRules>::CR as CharacterRules<R>>::StatisticsSeed: Unpin

impl<R> UnwindSafe for RegenerateStatistics<R> where
    <<R as BattleRules>::CR as CharacterRules<R>>::CreatureId: UnwindSafe,
    <<R as BattleRules>::CR as CharacterRules<R>>::ObjectId: UnwindSafe,
    <<R as BattleRules>::CR as CharacterRules<R>>::StatisticsSeed: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,