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

Method process_factory_round

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

Ends a round for this factory. If the factory is currently producing a robot, decreases the number of rounds left. If the number of rounds is 0 and the factory can load a unit into the garrison, loads the unit and returns the unit type and resets the factory. If the factory cannot load a unit, does nothing. Assumes the unit is a factory.

(&mut self)

Source from the content-addressed store, hash-verified

1084 ///
1085 /// Assumes the unit is a factory.
1086 pub(crate) fn process_factory_round(&mut self) -> Option<UnitType> {
1087 if self.factory_rounds_left.is_none() {
1088 return None;
1089 }
1090
1091 let rounds_left = self.factory_rounds_left.unwrap() - 1;
1092 if rounds_left != 0 {
1093 self.factory_rounds_left = Some(rounds_left);
1094 return None;
1095 }
1096
1097 if self.ok_if_can_load().is_err() {
1098 return None;
1099 }
1100
1101 let unit_type = self.factory_unit_type.unwrap();
1102 self.factory_rounds_left = None;
1103 self.factory_unit_type = None;
1104 Some(unit_type)
1105 }
1106
1107 // ************************************************************************
1108 // *************************** ROCKET METHODS *****************************

Callers 1

process_factoriesMethod · 0.80

Calls 1

ok_if_can_loadMethod · 0.45

Tested by

no test coverage detected