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)
| 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 ***************************** |
no test coverage detected