예제 #1
0
  public boolean handleObjectClick(int objectId, int objectX, int objectY) {

    switch (objectId) {
      case 7810:
      case 7812:
      case 7820:
      case 7822:
      case 7829:
      case 7833:
        closeCompostBin(
            CompostBinLocations.forPosition(new Position(objectX, objectY)).getCompostIndex());
        return true;

      case 7813:
      case 7823:
        openCompostBin(
            CompostBinLocations.forPosition(new Position(objectX, objectY)).getCompostIndex());
        return true;

      case 7830:
      case 7831:
      case 7834:
      case 7835:
        retrieveCompost(
            CompostBinLocations.forPosition(new Position(objectX, objectY)).getCompostIndex());
        return true;
    }
    return false;
  }
예제 #2
0
  public boolean handleItemOnObject(int itemUsed, int objectId, int objectX, int objectY) {
    switch (objectId) {
      case 7814:
      case 7815:
      case 7816:
      case 7817:
      case 7824:
      case 7825:
      case 7826:
      case 7827:
        if (itemUsed == 1925) {
          retrieveCompost(
              CompostBinLocations.forPosition(new Position(objectX, objectY)).getCompostIndex());
        } else {
          player.sendMessage("You might need some buckets to gather the compost.");
        }
        return true;

      case 7839:
      case 7838:
      case 7837:
      case 7836:
      case 7808:
      case 7809:
      case 7811:
      case 7819:
      case 7821:
      case 7828:
      case 7832:
        fillCompostBin(new Position(objectX, objectY), itemUsed);
        return true;
    }
    return false;
  }
예제 #3
0
  /* handle compost bin filling */
  @SuppressWarnings("unused")
  public void fillCompostBin(final Position binPosition, final int organicItemUsed) {
    final CompostBinLocations compostBinLocations = CompostBinLocations.forPosition(binPosition);
    final int index = compostBinLocations.getCompostIndex();
    if (compostBinLocations == null) {
      return;
    }
    int incrementFactor = 0;
    // setting up the different increments.
    for (int normalCompost : COMPOST_ORGANIC) {
      if (organicItemUsed == normalCompost) {
        incrementFactor = 2;
      }
    }

    for (int superCompost : SUPER_COMPOST_ORGANIC) {
      if (organicItemUsed == superCompost) {
        incrementFactor = 17;
      }
    }

    if (organicItemUsed == TOMATO) {
      if (compostBins[index] % 77 == 0) {
        incrementFactor = 77;
      } else {
        incrementFactor = 2;
      }
    }

    // checking if the item used was an organic item.
    if (incrementFactor == 0) {
      player.sendMessage(
          "You need to put organic items into the compost bin in order to make compost.");
      return;
    }
    final int factor = incrementFactor;
    // launching the main event for filling the compost bin.
    World.getWorld()
        .schedule(
            new ScheduledTask(2, false) {

              @Override
              public void execute() {
                if (!player.getInventory().contains(organicItemUsed)
                    || organicItemAdded[index] == 15) {
                  stop();
                  return;
                }
                organicItemAdded[index]++;
                player.playAnimation(new Animation(832, 0));
                player.getInventory().remove(new Item(organicItemUsed));
                compostBins[index] += factor;
                updateCompostBin(index);
              }

              @Override
              public void stop() {
                player.stopAnimation();
                super.stop();
              }
            });
  }