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

Method produce_robot

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

Starts producing the robot of the given type. NoSuchUnit - the factory does not exist (inside the vision range). TeamNotAllowed - the factory is not on the current player's team. InappropriateUnitType - the unit is not a factory, or the unit type is not a robot. StructureNotYetBuilt - the factory has not yet been completed. FactoryBusy - the factory is already producing a unit. InsufficientKarbon

(&mut self, factory_id: UnitID, robot_type: UnitType)

Source from the content-addressed store, hash-verified

1874 /// * InsufficientKarbonite - your team does not have enough Karbonite to
1875 /// produce the given robot.
1876 pub fn produce_robot(&mut self, factory_id: UnitID, robot_type: UnitType)
1877 -> Result<(), GameError> {
1878 self.ok_if_can_produce_robot(factory_id, robot_type)?;
1879 self.my_team_mut().karbonite -= robot_type.factory_cost().expect("unit type is ok");
1880 let factory = self.my_unit_mut(factory_id).expect("factory exists");
1881 factory.produce_robot(robot_type);
1882 Ok(())
1883 }
1884
1885 /// Process the end of the turn for factories. If a factory added a unit
1886 /// to its garrison, also mark that unit down in the game world.

Callers 1

applyMethod · 0.45

Calls 4

my_team_mutMethod · 0.80
factory_costMethod · 0.80
my_unit_mutMethod · 0.80

Tested by

no test coverage detected