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

Method get_unit_mut

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

Gets a mutable version of this unit from space or the current planet. NoSuchUnit - the unit does not exist.

(&mut self, id: UnitID)

Source from the content-addressed store, hash-verified

830 ///
831 /// * NoSuchUnit - the unit does not exist.
832 fn get_unit_mut(&mut self, id: UnitID) -> Result<&mut Unit, GameError> {
833 if self.get_planet(Planet::Earth).units.contains_key(&id) {
834 Ok(self.get_planet_mut(Planet::Earth).units.get_mut(&id).expect("key exists"))
835 } else if self.get_planet(Planet::Mars).units.contains_key(&id) {
836 Ok(self.get_planet_mut(Planet::Mars).units.get_mut(&id).expect("key exists"))
837 } else if self.get_team(Team::Red).units_in_space.contains_key(&id) {
838 Ok(self.get_team_mut(Team::Red).units_in_space.get_mut(&id).expect("key exists"))
839 } else if self.get_team(Team::Blue).units_in_space.contains_key(&id) {
840 Ok(self.get_team_mut(Team::Blue).units_in_space.get_mut(&id).expect("key exists"))
841 } else {
842 Err(GameError::NoSuchUnit)?
843 }
844 }
845
846 // ************************************************************************
847 // **************** UNIT CREATION / DESTRUCTION METHODS *******************

Callers 10

test_sensing_with_filterFunction · 0.80
test_rocket_successFunction · 0.80
test_rocket_failureFunction · 0.80
test_rocket_loadFunction · 0.80
test_rocket_unloadFunction · 0.80
test_factory_productionFunction · 0.80
test_repairFunction · 0.80

Calls 4

get_planetMethod · 0.80
get_planet_mutMethod · 0.80
get_teamMethod · 0.80
get_team_mutMethod · 0.80

Tested by 10

test_sensing_with_filterFunction · 0.64
test_rocket_successFunction · 0.64
test_rocket_failureFunction · 0.64
test_rocket_loadFunction · 0.64
test_rocket_unloadFunction · 0.64
test_factory_productionFunction · 0.64
test_repairFunction · 0.64