Builds a given blueprint, increasing its health by the worker's build amount. If raised to maximum health, the blueprint becomes a completed structure. NoSuchUnit - either unit does not exist (within the vision range). TeamNotAllowed - either unit is not on the current player's team. UnitNotOnMap - the worker is not on the map. InappropriateUnitType - the unit is not a worker, or the blueprint is
(&mut self, worker_id: UnitID, blueprint_id: UnitID)
| 1363 | /// * OutOfRange - the worker is not adjacent to the blueprint. |
| 1364 | /// * StructureAlreadyBuilt - the blueprint has already been completed. |
| 1365 | pub fn build(&mut self, worker_id: UnitID, blueprint_id: UnitID) |
| 1366 | -> Result<(), GameError> { |
| 1367 | self.ok_if_can_build(worker_id, blueprint_id)?; |
| 1368 | let build_health = { |
| 1369 | let worker = self.my_unit_mut(worker_id).unwrap(); |
| 1370 | worker.worker_act(); |
| 1371 | worker.worker_build_health().unwrap() |
| 1372 | }; |
| 1373 | self.my_unit_mut(blueprint_id).unwrap().be_built(build_health); |
| 1374 | Ok(()) |
| 1375 | } |
| 1376 | |
| 1377 | fn ok_if_can_repair(&self, worker_id: UnitID, structure_id: UnitID) -> Result<(), GameError> { |
| 1378 | let worker = self.my_unit(worker_id)?; |
no test coverage detected