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

Method process_asteroids

battlecode-engine/src/world.rs:650–673  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

648 }
649
650 fn process_asteroids(&mut self) {
651 if self.asteroids.has_asteroid(self.round) {
652 let (location, karbonite) = {
653 let asteroid = self.asteroids.asteroid(self.round).unwrap();
654 (asteroid.location, asteroid.karbonite)
655 };
656 self.viewer_changes.push(ViewerDelta::AsteroidStrike { location, karbonite });
657 if let Some(id) = self.get_planet(location.planet).units_by_loc.get(&location) {
658 if self.get_unit(*id).unwrap().unit_type().is_structure() {
659 return;
660 }
661 }
662
663 let new_amount = {
664 let planet_info = self.get_planet_mut(location.planet);
665 planet_info.karbonite[location.y as usize][location.x as usize] += karbonite;
666 planet_info.karbonite[location.y as usize][location.x as usize]
667 };
668 self.viewer_changes.push(ViewerDelta::KarboniteChanged {
669 location: location,
670 new_amount: new_amount,
671 });
672 }
673 }
674
675 // ************************************************************************
676 // *********************** COMMUNICATION METHODS **************************

Callers 1

end_roundMethod · 0.80

Calls 7

has_asteroidMethod · 0.80
asteroidMethod · 0.80
get_planetMethod · 0.80
is_structureMethod · 0.80
unit_typeMethod · 0.80
get_unitMethod · 0.80
get_planet_mutMethod · 0.80

Tested by

no test coverage detected