MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / ok_if_can_produce_robot

Method ok_if_can_produce_robot

battlecode-engine/src/world.rs:1848–1857  ·  view source on GitHub ↗
(&self, factory_id: UnitID, robot_type: UnitType)

Source from the content-addressed store, hash-verified

1846 // ************************************************************************
1847
1848 fn ok_if_can_produce_robot(&self, factory_id: UnitID, robot_type: UnitType)
1849 -> Result<(), GameError> {
1850 let factory = self.my_unit(factory_id)?;
1851 factory.ok_if_can_produce_robot(robot_type)?;
1852 let cost = robot_type.factory_cost().expect("unit type is ok");
1853 if self.karbonite() < cost {
1854 Err(GameError::InsufficientKarbonite)?;
1855 }
1856 Ok(())
1857 }
1858
1859 /// Whether the factory can produce a robot of the given type. The factory
1860 /// must not currently be producing a robot, and the team must have

Callers 2

can_produce_robotMethod · 0.45
produce_robotMethod · 0.45

Calls 3

my_unitMethod · 0.80
factory_costMethod · 0.80
karboniteMethod · 0.45

Tested by

no test coverage detected