MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / ok_if_can_repair

Method ok_if_can_repair

battlecode-engine/src/world.rs:1377–1389  ·  view source on GitHub ↗
(&self, worker_id: UnitID, structure_id: UnitID)

Source from the content-addressed store, hash-verified

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)?;
1379 let structure = self.my_unit(structure_id)?;
1380 worker.ok_if_on_map()?;
1381 worker.ok_if_can_worker_act()?;
1382 if !worker.location().is_adjacent_to(structure.location()) {
1383 Err(GameError::OutOfRange)?;
1384 }
1385 if !structure.structure_is_built()? {
1386 Err(GameError::StructureNotYetBuilt)?;
1387 }
1388 Ok(())
1389 }
1390
1391 /// Whether the given worker can repair the given strucutre. Tests that the worker
1392 /// is able to execute a worker action, that the structure is built, and that the

Callers 2

can_repairMethod · 0.80
repairMethod · 0.80

Calls 6

my_unitMethod · 0.80
ok_if_on_mapMethod · 0.80
ok_if_can_worker_actMethod · 0.80
is_adjacent_toMethod · 0.80
locationMethod · 0.80
structure_is_builtMethod · 0.80

Tested by

no test coverage detected