Struct FightingUnit

Source
struct FightingUnit {
    unit_type: UnitType,
    owner: PlayerInMatchup,
    position: Coord,
    force_bonus: bool,
    health: Option<i64>,
    current_target: Option<(usize, Coord)>,
    last_targets: Vec<usize>,
    movements_this_round: u64,
    extra_attack: u64,
}

Fields§

§unit_type: UnitType§owner: PlayerInMatchup§position: Coord§force_bonus: bool§health: Option<i64>

if None, the unit is dead.

§current_target: Option<(usize, Coord)>

unit index and its position when this target was decided.

§last_targets: Vec<usize>

The units which were attacked in the previous attack phase, in order, if any.

§movements_this_round: u64§extra_attack: u64

This is added to the attack damage the attack would usually inflict. For rodians, it is incremented by a config-defined value every time they attack an enemy.

Implementations§

Source§

impl FightingUnit

Source

fn alive(&self) -> bool

true iff health is Some(_). Units can have negative health, but they can only die at certain points. Truly dead units have a health value of None.

Source

fn die_if_dead(&mut self)

If the unit is alive but has health <= 0, make unit.alive() return false from now on.

Source

fn max_health(&self, info: &FightInfo) -> u64

Source

fn attack_range(&self, info: &FightInfo) -> u64

Source

fn armor(&self, info: &FightInfo) -> u64

Source

fn damage_per_attack(&self, enemy_armor: u64, info: &FightInfo) -> u64

Source

fn damage_per_attack_int( self_unit_type: UnitType, self_extra_attack: u64, self_force_bonus: bool, self_owner: PlayerInMatchup, enemy_armor: u64, info: &FightInfo, ) -> u64

Source

fn max_movements(&self, info: &FightInfo) -> u64

Source

fn max_attacks(&self, info: &FightInfo) -> u64

Source

fn movement( &mut self, position: Coord, movements: &mut Movement, info: &FightInfo, )

Move to the given position. Does not check if the position can actually be reached.

Source

fn movement_heal( &mut self, healing_amount: u64, movements: &mut Movement, info: &FightInfo, )

Heals this unit by the given amount. The unit cannot heal above its max_health() value.

Source

fn movement_damage( &mut self, damage_amount: u64, movements: &mut Movement, info: &FightInfo, )

Inflicts the given amount of damage on the unit. The unit can fall to or below zero health without dying, see dying.

Source

fn movement_message( &mut self, position: Coord, health: Option<i64>, movements: &mut Movement, info: &FightInfo, )

Source

fn attack<'a, 'b>( &'a mut self, raw_damage: Option<i64>, _info: &'a FightInfo, pfx: Prefix, ) -> impl FnOnce(&'b mut FightingUnit, &'b mut Attack, &'b FightInfo) + 'static

If raw_damage.is_none(), damage is applied based on the two units’ stats. If raw_damage.is_some(), the provided damage is applied regardless of the two units’ stats (used for healing).

Source

async fn pick_target(&self, fight: &Fight) -> Option<(usize, Coord)>

Picks the next target to move to / attack. May be None if there are no units left.

Source

fn can_attack(&self, other: &FightingUnit, info: &FightInfo) -> bool

Returns true if this unit could attack other based on its range.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V