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

Method ok_if_can_worker_act

battlecode-engine/src/unit.rs:675–683  ·  view source on GitHub ↗

Ok if the worker can perform a worker action (building, blueprinting, harvesting, or replicating). InappropriateUnitType - the unit is not a worker. Overheated - the worker is not ready to perform a worker action.

(&self)

Source from the content-addressed store, hash-verified

673 /// * InappropriateUnitType - the unit is not a worker.
674 /// * Overheated - the worker is not ready to perform a worker action.
675 pub(crate) fn ok_if_can_worker_act(&self) -> Result<(), GameError> {
676 if self.unit_type != Worker {
677 Err(GameError::InappropriateUnitType)?;
678 }
679 if self.has_worker_acted {
680 Err(GameError::Overheated)?;
681 }
682 Ok(())
683 }
684
685 /// Updates the unit as if it has performed a worker action.
686 pub(crate) fn worker_act(&mut self) {

Callers 4

ok_if_can_harvestMethod · 0.80
ok_if_can_blueprintMethod · 0.80
ok_if_can_buildMethod · 0.80
ok_if_can_repairMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected