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

Method ok_if_can_produce_robot

battlecode-engine/src/unit.rs:1060–1070  ·  view source on GitHub ↗

Returns OK if the factory can produce a robot of this type. InappropriateUnitType - the unit is not a factory or the unit type is not a robot. StructureNotYetBuilt - the structure has not yet been built. FactoryBusy - the factory is already producing a unit.

(&self, unit_type: UnitType)

Source from the content-addressed store, hash-verified

1058 /// * StructureNotYetBuilt - the structure has not yet been built.
1059 /// * FactoryBusy - the factory is already producing a unit.
1060 pub(crate) fn ok_if_can_produce_robot(&self, unit_type: UnitType) -> Result<(), GameError> {
1061 self.ok_if_unit_type(Factory)?;
1062 self.ok_if_structure_built()?;
1063 if !unit_type.is_robot() {
1064 Err(GameError::InappropriateUnitType)?;
1065 }
1066 if self.factory_unit_type.is_some() {
1067 Err(GameError::FactoryBusy)?;
1068 }
1069 Ok(())
1070 }
1071
1072 /// Starts producing a robot of this type.
1073 /// Assumes the unit can produce a robot.

Callers

nothing calls this directly

Calls 3

ok_if_unit_typeMethod · 0.80
ok_if_structure_builtMethod · 0.80
is_robotMethod · 0.80

Tested by

no test coverage detected