Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. package viceCity.models.neighbourhood;
  2.  
  3. import viceCity.models.guns.Gun;
  4. import viceCity.models.players.Player;
  5.  
  6. import java.util.Collection;
  7.  
  8. public class GangNeighbourhood implements Neighbourhood {
  9.  
  10.     @Override
  11.     public void action(Player mainPlayer, Collection<Player> civilPlayers) {
  12.  
  13.         for (Player civilPlayer : civilPlayers) {
  14.  
  15.             for (Gun gun : mainPlayer.getGunRepository().getModels()) {
  16.  
  17.                 while (civilPlayer.isAlive() && gun.canFire()) {
  18.                     civilPlayer.takeLifePoints(gun.fire());
  19.                 }
  20.  
  21.                 if (!civilPlayer.isAlive()) {
  22.                     break;
  23.                 }
  24.             }
  25.         }
  26.  
  27.         for (Player civilPlayer : civilPlayers) {
  28.  
  29.             if (!civilPlayer.isAlive()) {
  30.                 continue;
  31.             }
  32.  
  33.             for (Gun gun : civilPlayer.getGunRepository().getModels()) {
  34.  
  35.                 while (mainPlayer.isAlive() && gun.canFire()) {
  36.                     mainPlayer.takeLifePoints(gun.fire());
  37.                 }
  38.  
  39.                 if (!mainPlayer.isAlive()) {
  40.                     break;
  41.                 }
  42.             }
  43.  
  44.             if (!mainPlayer.isAlive()) {
  45.                 break;
  46.             }
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement