Esempio n. 1
0
 @Override
 public GameObjectID throwFan(GameObjectID player) throws BozorgExceptionBase {
   Player p = (Player) objects.get(player.getNumber());
   if (p.getHp() == 0) throw new BozorgExceptionBase();
   if (p.getFans() == 0) throw new BozorgExceptionBase();
   Fan f = new Fan(p.x, p.y, (Player) objects.get(player.getNumber()));
   objects.add(f);
   GameObjectID g = GameObjectID.create(f.getClass());
   f.id = g;
   objectsId.add(g);
   p.setFans(p.getFans() - 1);
   return g;
 }
Esempio n. 2
0
 @Override
 public void updateInfo(GameObjectID id, String infoKey, Integer infoValue)
     throws BozorgExceptionBase {
   if (objects.get(id.getNumber()).getClass().equals(Fan.class)) {
     Fan f = (Fan) objects.get(id.getNumber());
     if (infoKey.equals(JudgeAbstract.ROW)) f.x = infoValue;
     if (infoKey.equals(JudgeAbstract.COL)) f.y = infoValue;
     if (infoKey.equals(JudgeAbstract.OWNER))
       for (Player p : players) if (p.getName() == infoValue) f.owner = p;
     if (infoKey.equals(JudgeAbstract.IS_ALIVE))
       if (infoValue == JudgeAbstract.ALIVE) f.isAlive = true;
       else f.isAlive = false;
   }
   if (objects.get(id.getNumber()).getClass().equals(Player.class)) {
     Player p = (Player) objects.get(id.getNumber());
     if (infoKey.equals(JudgeAbstract.ROW)) p.x = infoValue;
     if (infoKey.equals(JudgeAbstract.COL)) p.y = infoValue;
     if (infoKey.equals(JudgeAbstract.IS_ALIVE))
       if (infoValue == JudgeAbstract.ALIVE) if (p.getHp() == 0) p.setHp(100);
     if (infoKey.equals(JudgeAbstract.SPEED)) p.setSpeed(infoValue);
     if (infoKey.equals(JudgeAbstract.NAME)) p.setName(infoValue);
     if (infoKey.equals(JudgeAbstract.POWER)) p.setPower(infoValue);
     if (infoKey.equals(JudgeAbstract.VISION)) p.setVision(infoValue);
     if (infoKey.equals(JudgeAbstract.FANS)) p.setFans(infoValue);
   }
 }