Пример #1
0
  public void run() {
    Foodistan fdistan = Foodistan.getfoodistan();
    while (System.currentTimeMillis() <= Foodistan.getfoodistan().getFoodistanEndTime()) {
      for (int z = 0; z < fdistan.getFoodies().size(); z++) {
        Foodie f = fdistan.foodies.get(z);
        if (f.getfStatus() == foodieStatus.WAITING) {
          /*	if((f.getMaxWaitTime() + f.getWaitStartTime()) - System.currentTimeMillis() < 10000l)
          {
          	if(fdistan.getMg().hasInventory(fdistan.getInv(), 1)){
          		fdistan.setAvgWaitingTime(fdistan.getAvgWaitingTime()+(System.currentTimeMillis()-f.getWaitStartTime()));
          		fdistan.getFoodies().get(z).consumeItem(fdistan.getMg().getItem(fdistan.getInv(), 1));
          		fdistan.getOdrsOnHold().remove(0).setOrdrStatus(orderStatus.COMPLETE);
          		fdistan.getFoodiesOnHold().remove(0);
          		fdistan.setBurgerNeeded(fdistan.getBurgerNeeded()-1);
          		fdistan.setOrdersDelivered(Foodistan.getfoodistan().getOrdersDelivered()+1);

          	}

          }*/
          if ((f.getMaxWaitTime() + f.getWaitStartTime()) < System.currentTimeMillis()) {
            fdistan.foodies.get(z).setfStatus(foodieStatus.DEAD);
            fdistan.getFoodiesOnHold().remove(0);
            fdistan.getOdrsOnHold().remove(0);
            fdistan.setBurgerNeeded(fdistan.getBurgerNeeded() - 1);
            fdistan.setAvgWaitingTime(fdistan.getAvgWaitingTime() + (f.getMaxWaitTime()));
            fdistan.setDeathPenalty(fdistan.getDeathPenalty() + 1);
          }
        }
      }
    }
  }
Пример #2
0
  public void run() {
    Foodistan fdistan = Foodistan.getfoodistan();
    long waitTime = 0l;
    while (System.currentTimeMillis() <= Foodistan.getfoodistan().getFoodistanEndTime()) {
      for (int x = 0; x < fdistan.getFoodies().size(); x++) {
        Foodie f = fdistan.getFoodies().get(x);
        if (f.getfStatus() == foodieStatus.WAITING) {

          if ((fdistan.getMg().hasInventory(Foodistan.getfoodistan().getInv(), 1) == false)
              || (fdistan.getMg().calculateDiscount() < f.getFoodieDiscount())) {
          } else {
            waitTime = System.currentTimeMillis() - f.getWaitStartTime();
            if (waitTime > fdistan.getMaxWaitingTime()) fdistan.setMaxWaitingTime(waitTime);
            fdistan.setAvgWaitingTime(fdistan.getAvgWaitingTime() + waitTime);
            Item itm = fdistan.getMg().getItem(fdistan.getInv());
            fdistan.getFoodies().get(x).consumeItem(itm);
            fdistan.setAvgItemLifeTime(
                fdistan.getAvgItemLifeTime()
                    + (System.currentTimeMillis() - itm.getItemStartTime()));
            fdistan.getOdrsOnHold().remove(0).setOrdrStatus(orderStatus.COMPLETE);
            fdistan.getFoodiesOnHold().remove(0);
            fdistan.setBurgerNeeded(fdistan.getBurgerNeeded() - 1);
            fdistan.setOrdersDelivered(Foodistan.getfoodistan().getOrdersDelivered() + 1);
          }
        }
      }
    }
  }