Get the list of units, with some info truncated, to send to the viewer.
(&self)
| 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 ****************************** |
no test coverage detected