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

Method ok_if_can_unload_unit

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

Returns OK if the structure can unload a unit. The structure must be on a planet and it must have at least one unit to unload. Does not check whether the unit is ready to move. InappropriateUnitType - the unit is not a structure. StructureNotYetBuilt - the structure has not yet been built. GarrisonEmpty - the unit's garrison is already empty.

(&self)

Source from the content-addressed store, hash-verified

974 /// * StructureNotYetBuilt - the structure has not yet been built.
975 /// * GarrisonEmpty - the unit's garrison is already empty.
976 pub(crate) fn ok_if_can_unload_unit(&self) -> Result<(), GameError> {
977 self.ok_if_structure_built()?;
978 if self.garrison.len() == 0 {
979 Err(GameError::GarrisonEmpty)?;
980 }
981 Ok(())
982 }
983
984 /// Updates the structure as if it has unloaded a single unit from the
985 /// structure, returning the unit ID.

Callers 1

ok_if_can_unloadMethod · 0.80

Calls 1

ok_if_structure_builtMethod · 0.80

Tested by

no test coverage detected