MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / unit_mut

Method unit_mut

battlecode-engine/src/world.rs:460–468  ·  view source on GitHub ↗

The single unit with this ID. Use this method to get detailed statistics on a unit: heat, cooldowns, and properties of special abilities like units garrisoned in a rocket. NoSuchUnit - the unit does not exist (inside the vision range).

(&mut self, id: UnitID)

Source from the content-addressed store, hash-verified

458 ///
459 /// * NoSuchUnit - the unit does not exist (inside the vision range).
460 fn unit_mut(&mut self, id: UnitID) -> Result<&mut Unit, GameError> {
461 if self.my_planet().units.contains_key(&id) {
462 Ok(self.my_planet_mut().units.get_mut(&id).unwrap())
463 } else if self.my_team().units_in_space.contains_key(&id) {
464 Ok(self.my_team_mut().units_in_space.get_mut(&id).unwrap())
465 } else {
466 Err(GameError::NoSuchUnit)?
467 }
468 }
469
470 /// The single unit with this ID. Use this method to get detailed
471 /// statistics on a unit: heat, cooldowns, and properties of special

Callers 2

destroy_unitMethod · 0.80
damage_unitMethod · 0.80

Calls 4

my_planetMethod · 0.80
my_planet_mutMethod · 0.80
my_teamMethod · 0.80
my_team_mutMethod · 0.80

Tested by

no test coverage detected