Replicates a worker in the given direction. Subtracts the cost of the worker from the team's resource pool. NoSuchUnit - the worker does not exist (within the vision range). TeamNotAllowed - the worker is not on the current player's team. InappropriateUnitType - the unit is not a worker. Overheated - the worker is not ready to replicate again. InsufficientKarbonite - your team does not have enoug
(&mut self, worker_id: UnitID, direction: Direction)
| 1452 | /// * LocationNotEmpty - the location in the target direction is already |
| 1453 | /// occupied. |
| 1454 | pub fn replicate(&mut self, worker_id: UnitID, direction: Direction) |
| 1455 | -> Result<(), GameError> { |
| 1456 | self.ok_if_can_replicate(worker_id, direction)?; |
| 1457 | self.my_unit_mut(worker_id)?.worker_act(); |
| 1458 | self.my_unit_mut(worker_id)?.replicate(); |
| 1459 | let (team, location) = { |
| 1460 | let worker = self.my_unit(worker_id)?; |
| 1461 | (worker.team(), worker.location().map_location()?.add(direction)) |
| 1462 | }; |
| 1463 | self.create_unit(team, location, UnitType::Worker)?; |
| 1464 | self.my_team_mut().karbonite -= UnitType::Worker.replicate_cost()?; |
| 1465 | Ok(()) |
| 1466 | } |
| 1467 | |
| 1468 | // ************************************************************************ |
| 1469 | // *************************** KNIGHT METHODS ***************************** |
no test coverage detected