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

Method get_viewer_units

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

Get the list of units, with some info truncated, to send to the viewer.

(&self)

Source from the content-addressed store, hash-verified

2325
2326 /// Get the list of units, with some info truncated, to send to the viewer.
2327 pub(crate) fn get_viewer_units(&self) -> Vec<ViewerUnitInfo> {
2328 let mut units = Vec::new();
2329 for unit in self.get_planet(Planet::Earth).units.values() {
2330 if unit.location().is_on_map() {
2331 units.push(ViewerUnitInfo {
2332 id: unit.id(),
2333 unit_type: unit.unit_type(),
2334 health: unit.health(),
2335 location: unit.location().map_location().unwrap(),
2336 team: unit.team()
2337 });
2338 }
2339 }
2340 for unit in self.get_planet(Planet::Mars).units.values() {
2341 if unit.location().is_on_map() {
2342 units.push(ViewerUnitInfo {
2343 id: unit.id(),
2344 unit_type: unit.unit_type(),
2345 health: unit.health(),
2346 location: unit.location().map_location().unwrap(),
2347 team: unit.team(),
2348 });
2349 }
2350 }
2351 units
2352 }
2353
2354 // ************************************************************************
2355 // ****************************** PLAYER API ******************************

Callers 1

apply_turnMethod · 0.80

Calls 8

get_planetMethod · 0.80
is_on_mapMethod · 0.80
locationMethod · 0.80
idMethod · 0.80
unit_typeMethod · 0.80
healthMethod · 0.80
map_locationMethod · 0.80
teamMethod · 0.45

Tested by

no test coverage detected