MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / ok_if_can_build

Method ok_if_can_build

battlecode-engine/src/world.rs:1329–1344  ·  view source on GitHub ↗
(&self, worker_id: UnitID, blueprint_id: UnitID)

Source from the content-addressed store, hash-verified

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

Callers 2

can_buildMethod · 0.80
buildMethod · 0.80

Calls 6

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

Tested by

no test coverage detected