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

Method ok_if_can_load

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

Returns OK if the structure can load a unit. The structure must have enough space. InappropriateUnitType - the unit is not a structure. StructureNotYetBuilt - the structure has not yet been built. GarrisonFull - the unit's garrison is already full.

(&self)

Source from the content-addressed store, hash-verified

953 /// * StructureNotYetBuilt - the structure has not yet been built.
954 /// * GarrisonFull - the unit's garrison is already full.
955 pub(crate) fn ok_if_can_load(&self) -> Result<(), GameError> {
956 self.ok_if_structure_built()?;
957 if self.garrison.len() == self.max_capacity {
958 Err(GameError::GarrisonFull)?;
959 }
960 Ok(())
961 }
962
963 /// Updates the structure as if it has loaded a unit inside its garrison.
964 /// Adds the unit ID to the garrison.

Callers 1

process_factory_roundMethod · 0.45

Calls 1

ok_if_structure_builtMethod · 0.80

Tested by

no test coverage detected