コード例 #1
0
  public void run() {

    Foodistan fdistan = Foodistan.getfoodistan();
    while (System.currentTimeMillis() <= Foodistan.getfoodistan().getFoodistanEndTime()) {
      for (int k = 0; k < fdistan.getChefs().size(); k++) {
        Chef c = fdistan.chefs.get(k);

        // decreasing speed
        if (fdistan.getInv().items.size() > fdistan.getBurgerNeeded()) {

          long changeUpTime = c.getBackUpCookTime() * 2;
          if (changeUpTime <= 3600000) {
            fdistan.chefs.get(k).setBackUpCookTime(changeUpTime);
          } else {

            fdistan.chefs.get(k).setBackUpCookTime(fdistan.chefs.get(k).getDefaultCookTime());
          }
        }

        // increasing speed
        if (fdistan.getInv().items.size() < fdistan.getBurgerNeeded()) {
          long changeDownTime = c.getBackUpCookTime() / 2;

          if (changeDownTime > 1) {

            fdistan.chefs.get(k).setBackUpCookTime(changeDownTime);
          }
        }
      }
    }
  }
コード例 #2
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);
          }
        }
      }
    }
  }
コード例 #3
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);
          }
        }
      }
    }
  }