(&self, worker_id: UnitID, blueprint_id: UnitID)
| 1327 | } |
| 1328 | |
| 1329 | fn ok_if_can_build(&self, worker_id: UnitID, blueprint_id: UnitID) |
| 1330 | -> Result<(), GameError> { |
| 1331 | let worker = self.my_unit(worker_id)?; |
| 1332 | let blueprint = self.my_unit(blueprint_id)?; |
| 1333 | // The worker must be on the map. |
| 1334 | worker.ok_if_on_map()?; |
| 1335 | // The worker must be able to act. |
| 1336 | worker.ok_if_can_worker_act()?; |
| 1337 | // The worker must be adjacent to the blueprint. |
| 1338 | worker.ok_if_within_ability_range(blueprint.location())?; |
| 1339 | // The blueprint must be incomplete. |
| 1340 | if blueprint.structure_is_built()? { |
| 1341 | Err(GameError::StructureAlreadyBuilt)?; |
| 1342 | } |
| 1343 | Ok(()) |
| 1344 | } |
| 1345 | |
| 1346 | /// Whether the worker can build a blueprint with the given ID. The worker |
| 1347 | /// and the blueprint must be adjacent to each other. The worker cannot |
no test coverage detected