MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / ok_if_can_harvest

Method ok_if_can_harvest

battlecode-engine/src/world.rs:1210–1219  ·  view source on GitHub ↗
(&self, worker_id: UnitID, direction: Direction)

Source from the content-addressed store, hash-verified

1208 // ************************************************************************
1209
1210 fn ok_if_can_harvest(&self, worker_id: UnitID, direction: Direction) -> Result<(), GameError> {
1211 let unit = self.my_unit(worker_id)?;
1212 unit.ok_if_can_worker_act()?;
1213 let harvest_loc = unit.location().map_location()?.add(direction);
1214 // Check to see if we can sense the harvest location, (e.g. it is on the map).
1215 if self.karbonite_at(harvest_loc)? == 0 {
1216 Err(GameError::KarboniteDepositEmpty)?;
1217 }
1218 Ok(())
1219 }
1220
1221 /// Whether the worker is ready to harvest, and the given direction contains
1222 /// karbonite to harvest. The worker cannot already have performed an action

Callers 2

can_harvestMethod · 0.80
harvestMethod · 0.80

Calls 6

my_unitMethod · 0.80
ok_if_can_worker_actMethod · 0.80
map_locationMethod · 0.80
locationMethod · 0.80
addMethod · 0.45
karbonite_atMethod · 0.45

Tested by

no test coverage detected