[][src]Trait weasel::space::SpaceRules

pub trait SpaceRules<R: BattleRules> {
    type Position: Eq + Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>;
    type SpaceSeed: Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>;
    type SpaceAlteration: Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>;
    type SpaceModel;
    fn generate_model(&self, seed: &Option<Self::SpaceSeed>) -> Self::SpaceModel;

    fn check_move<'a>(
        &self,
        _model: &Self::SpaceModel,
        _claim: PositionClaim<'a, R>,
        _position: &Self::Position
    ) -> WeaselResult<(), R> { ... }
fn move_entity<'a>(
        &self,
        _model: &mut Self::SpaceModel,
        _claim: PositionClaim<'a, R>,
        _position: Option<&Self::Position>,
        _metrics: &mut WriteMetrics<'_, R>
    ) { ... }
fn translate_entity(
        &self,
        _model: &Self::SpaceModel,
        _new_model: &mut Self::SpaceModel,
        _entity: &mut dyn Entity<R>,
        _event_queue: &mut Option<EventQueue<R>>,
        _metrics: &mut WriteMetrics<'_, R>
    ) { ... }
fn alter_space(
        &self,
        _entities: &Entities<R>,
        _rounds: &Rounds<R>,
        _model: &mut Self::SpaceModel,
        _alteration: &Self::SpaceAlteration,
        _event_queue: &mut Option<EventQueue<R>>,
        _metrics: &mut WriteMetrics<'_, R>
    ) { ... } }

Rules to govern the space dimension in a game.

This rules are used to determine if an entity can occupy a given position and to keep a model containing all entities' positions.

Associated Types

Loading content...

Required methods

fn generate_model(&self, seed: &Option<Self::SpaceSeed>) -> Self::SpaceModel

Generates a SpaceModel starting from a SpaceSeed.

Loading content...

Provided methods

fn check_move<'a>(
    &self,
    _model: &Self::SpaceModel,
    _claim: PositionClaim<'a, R>,
    _position: &Self::Position
) -> WeaselResult<(), R>

Checks if the given entity can occupy a new position.

The claim tells in which context the entity is trying to acquire the position.

The provided implementation accepts every move.

fn move_entity<'a>(
    &self,
    _model: &mut Self::SpaceModel,
    _claim: PositionClaim<'a, R>,
    _position: Option<&Self::Position>,
    _metrics: &mut WriteMetrics<'_, R>
)

Moves an entity into a new position.

Position's correctness will be validated beforehand with check_move, unless it is None. An empty position means that the entity is disappearing from the battle.
The claim tells in which context the entity is trying to acquire the position.

The provided implementation does nothing.

fn translate_entity(
    &self,
    _model: &Self::SpaceModel,
    _new_model: &mut Self::SpaceModel,
    _entity: &mut dyn Entity<R>,
    _event_queue: &mut Option<EventQueue<R>>,
    _metrics: &mut WriteMetrics<'_, R>
)

Translates an entity from one space model to another one.

This method must apply the necessary changes to the entity's position and to the new model so that positions consistency is preserved.

The provided implementation does nothing.

fn alter_space(
    &self,
    _entities: &Entities<R>,
    _rounds: &Rounds<R>,
    _model: &mut Self::SpaceModel,
    _alteration: &Self::SpaceAlteration,
    _event_queue: &mut Option<EventQueue<R>>,
    _metrics: &mut WriteMetrics<'_, R>
)

Changes the current space model, starting from the information contained in alteration.

Consequences of this change should be applied by registering events inside event_queue.

The provided implementation does nothing.

Loading content...

Implementors

impl<R: BattleRules> SpaceRules<R> for EmptySpaceRules[src]

type Position = ()

type SpaceSeed = ()

type SpaceModel = ()

type SpaceAlteration = ()

Loading content...