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: u64This 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
impl FightingUnit
Sourcefn alive(&self) -> bool
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.
Sourcefn die_if_dead(&mut self)
fn die_if_dead(&mut self)
If the unit is alive but has health <= 0,
make unit.alive() return false from now on.
fn max_health(&self, info: &FightInfo) -> u64
fn attack_range(&self, info: &FightInfo) -> u64
fn armor(&self, info: &FightInfo) -> u64
fn damage_per_attack(&self, enemy_armor: u64, info: &FightInfo) -> u64
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
fn max_movements(&self, info: &FightInfo) -> u64
fn max_attacks(&self, info: &FightInfo) -> u64
Sourcefn movement(
&mut self,
position: Coord,
movements: &mut Movement,
info: &FightInfo,
)
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.
Sourcefn movement_heal(
&mut self,
healing_amount: u64,
movements: &mut Movement,
info: &FightInfo,
)
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.
Sourcefn movement_damage(
&mut self,
damage_amount: u64,
movements: &mut Movement,
info: &FightInfo,
)
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.
fn movement_message( &mut self, position: Coord, health: Option<i64>, movements: &mut Movement, info: &FightInfo, )
Sourcefn 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
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).
Sourceasync fn pick_target(&self, fight: &Fight) -> Option<(usize, Coord)>
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.
Sourcefn can_attack(&self, other: &FightingUnit, info: &FightInfo) -> bool
fn can_attack(&self, other: &FightingUnit, info: &FightInfo) -> bool
Returns true if this unit could attack other based on its range.