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

Method build

battlecode-engine/src/world.rs:1365–1375  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)?;

Callers 4

run.pyFile · 0.45
run.pyFile · 0.45
applyMethod · 0.45
examplefuncsplayerFunction · 0.45

Calls 5

ok_if_can_buildMethod · 0.80
my_unit_mutMethod · 0.80
worker_actMethod · 0.80
worker_build_healthMethod · 0.80
be_builtMethod · 0.80

Tested by

no test coverage detected