コード例 #1
0
ファイル: Compost.java プロジェクト: root-voicenet/Konklex
  /* handle what happens when the player opens the compost bin */
  public void openCompostBin(final int index) {
    // check if the time elapsed is enough to rot the compost
    int timerRequired;
    timerRequired = compostBins[index] == 200 ? 90 : 45;
    if (World.getWorld().getUptime() - compostBinsTimer[index] >= timerRequired) {
      compostBins[index] += 50;
      player.playAnimation(new Animation(834, 0));
      World.getWorld()
          .schedule(
              new ScheduledTask(2, false) {

                @Override
                public void execute() {
                  updateCompostBin(index);
                  stop();
                }

                @Override
                public void stop() {
                  super.stop();
                }
              });
    } else {
      player.sendMessage("The compost bin is still rotting. I should wait until it is complete.");
    }
  }
コード例 #2
0
 /*
  * (non-Javadoc)
  * @see org.apollo.game.model.inter.EnterAmountListener#amountEntered(int)
  */
 @Override
 public void amountEntered(int amount) {
   if (player.getInterfaceSet().contains(BankConstants.BANK_WINDOW_ID)) {
     BankUtils.deposit(player, slot, id, amount);
   } else if (player.getInterfaceSet().contains(DepositBoxConstants.DEPBOX_WINDOW_ID)) {
     DepositBoxUtils.put(player, slot, id, amount);
   }
 }
コード例 #3
0
ファイル: Shop.java プロジェクト: amarsut/Konklex
 /**
  * Buys a item from the store.
  *
  * @param player The player.
  * @param item The item to buy.
  */
 public void buyItem(Player player, SlottedItem item) {
   if (player.getInventory().freeSlots() >= item.getItem().getAmount()) {
     if (payment.buyItem(player, item)) {
       player.getInventory().add(item.getItem());
       player.send(new UpdateItemsEvent(3823, player.getInventory().getItems()));
       if (!type.equals(ShopType.UNLIMITED_BUY_ONLY)) {
         items.remove(item.getItem());
       }
     }
   } else {
     player.getInventory().forceCapacityExceeded();
   }
 }
コード例 #4
0
ファイル: Shop.java プロジェクト: amarsut/Konklex
 /**
  * Sells a item to the store.
  *
  * @param player The player that is selling this item.
  * @param slot The item slot.
  * @param item The item.
  */
 public void sellItem(Player player, Item item) {
   if (type.equals(ShopType.BUY_AND_SELL)) {
     if (player.getInventory().contains(item)) {
       if (payment.sellItem(player, item)) {
         player.getInventory().remove(item);
         player.send(new UpdateItemsEvent(3823, player.getInventory().getItems()));
         items.add(item);
       }
     }
   } else {
     player.sendMessage("You cannot sell items in this shop.");
   }
 }
コード例 #5
0
ファイル: CastleWars.java プロジェクト: SimonSheehan/Konklex
 /**
  * Return the flag.
  *
  * @param player The player that is return the flag.
  */
 public void returnFlag(Player player) {
   if (getPlayers(GameType.ACTIVE).contains(player)) {
     Team team =
         getTeam(player, GameType.ACTIVE) == Team.SARADOMIN ? Team.ZAMORAK : Team.SARADOMIN;
     if (teams.get(team).getAttribute(4)) {
       Item weapon = player.getEquipment().get(EquipmentConstants.WEAPON);
       if (weapon != null && weapon.getId() == teams.get(team).getFlag()) {
         player.getEquipment().set(EquipmentConstants.WEAPON, null);
         teams.get(getTeam(player, GameType.ACTIVE)).addPoint();
         teams.get(team).setAttribute(4, false);
         setAttribute(1, true);
         setAttribute(3, true);
       }
     }
   }
 }
コード例 #6
0
ファイル: Compost.java プロジェクト: root-voicenet/Konklex
  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;
  }
コード例 #7
0
ファイル: Compost.java プロジェクト: root-voicenet/Konklex
  // handle what happens when the player retrieve the compost
  public void retrieveCompost(final int index) {
    final int finalItem =
        compostBins[index] == 150
            ? COMPOST
            : compostBins[index] == 250 ? SUPER_COMPOST : ROTTE_TOMATO;

    player.playAnimation(new Animation(832, 0));
    Action<Player> action =
        new Action<Player>(2, false, player) {

          @Override
          public void execute() {
            if (!player.getInventory().contains(1925) && compostBins[index] != 350
                || organicItemAdded[index] == 0) {
              stop();
              return;
            }
            player
                .getSkillSet()
                .addExperience(
                    Skill.FARMING,
                    finalItem == COMPOST
                        ? COMPOST_EXP_RETRIEVE
                        : finalItem == SUPER_COMPOST
                            ? SUPER_COMPOST_EXP_RETRIEVE
                            : ROTTEN_TOMATOES_EXP_RETRIEVE);
            if (compostBins[index] != 350) {
              player.getInventory().remove(new Item(1925));
            }
            player.getInventory().add(new Item(finalItem));
            player.playAnimation(new Animation(832, 0));
            organicItemAdded[index]--;
            if (organicItemAdded[index] == 0) {
              resetVariables(index);
            }
            updateCompostBin(index);
          }

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

    player.startAction(action);
  }
コード例 #8
0
ファイル: CastleWars.java プロジェクト: SimonSheehan/Konklex
 /**
  * Capture the flag.
  *
  * @param player The player that is capturing.
  */
 public void captureFlag(Player player) {
   if (getPlayers(GameType.ACTIVE).contains(player)) {
     Team team =
         getTeam(player, GameType.ACTIVE) == Team.SARADOMIN ? Team.ZAMORAK : Team.SARADOMIN;
     if (!teams.get(team).getAttribute(4)) {
       if (player.getInventory().freeSlots() >= 2) {
         player
             .getInventory()
             .add(
                 player
                     .getEquipment()
                     .set(EquipmentConstants.WEAPON, new Item(teams.get(team).getFlag())));
         player.getInventory().add(player.getEquipment().set(EquipmentConstants.SHIELD, null));
         teams.get(team).setAttribute(4, true);
         setAttribute(team == Team.SARADOMIN ? 3 : 4, true);
         setAttribute(1, true);
       }
     }
   }
 }
コード例 #9
0
ファイル: CastleWars.java プロジェクト: SimonSheehan/Konklex
 /**
  * Send the current config update to the specified player.
  *
  * @param player The player to recieve the update.
  */
 public void sendConfig(Player player) {
   Team team = getTeam(player, GameType.ACTIVE);
   CastleWarsTeams sara = teams.get(Team.SARADOMIN), zammy = teams.get(Team.ZAMORAK);
   int config = zammy.getHealth();
   if (team == Team.ZAMORAK ? zammy.getAttribute(0) : sara.getAttribute(0)) {
     config += 128;
   }
   if (!sara.getAttribute(1)) {
     config += 256;
   }
   if (!sara.getAttribute(2)) {
     config += 512;
   }
   if (team == Team.ZAMORAK ? !zammy.getAttribute(3) : !sara.getAttribute(3)) {
     config += 1024;
   }
   if (team == Team.ZAMORAK ? zammy.getAttribute(4) : sara.getAttribute(4)) {
     config += 2097152;
   }
   config += 16777216 * (team == Team.ZAMORAK ? zammy.getScore() : sara.getScore());
   player.send(new ConfigEvent(team == Team.ZAMORAK ? 377 : 378, config));
   config = sara.getHealth();
   if (team == Team.ZAMORAK ? zammy.getAttribute(0) : sara.getAttribute(0)) {
     config += 128;
   }
   if (!zammy.getAttribute(1)) {
     config += 256;
   }
   if (!zammy.getAttribute(2)) {
     config += 512;
   }
   if (!sara.getAttribute(3)) {
     config += 1024;
   }
   if (team == Team.ZAMORAK ? sara.getAttribute(4) : zammy.getAttribute(4)) {
     config += 2097152;
   }
   config += 16777216 * (team == Team.ZAMORAK ? sara.getScore() : zammy.getScore());
   player.send(new ConfigEvent(team == Team.ZAMORAK ? 378 : 377, config));
 }
コード例 #10
0
ファイル: CastleWars.java プロジェクト: SimonSheehan/Konklex
 /**
  * Updates the flag positions for the specified team.
  *
  * @param player The player to receive the update.
  * @param team The team to look for the flag positions.
  */
 public void updateFlag(Player player, Team team) {
   if (getPlayers(GameType.ACTIVE).contains(player)) {
     if (teams.get(team).getAttribute(4)) {
       player
           .getObjectSet()
           .add(
               new StaticObjectDefinition(
                   teams.get(team).getPole(),
                   teams.get(team).getBaseOff(),
                   team == Team.ZAMORAK ? -1 : -3,
                   10));
     } else {
       player
           .getObjectSet()
           .remove(
               new StaticObjectDefinition(
                   teams.get(team).getPole(),
                   teams.get(team).getBaseOn(),
                   team == Team.ZAMORAK ? -1 : -3,
                   10));
     }
   }
 }
コード例 #11
0
ファイル: Compost.java プロジェクト: root-voicenet/Konklex
  /* handle what happens when the player close the compost bin */
  public void closeCompostBin(final int index) {
    compostBins[index] = tempCompostState * 100;
    compostBinsTimer[index] = World.getWorld().getUptime();

    player.playAnimation(new Animation(835, 0));
    World.getWorld()
        .schedule(
            new ScheduledTask(2, false) {

              @Override
              public void execute() {
                player.sendMessage("You close the compost bin, and its content start to rot.");
                updateCompostBin(index);
                stop();
              }

              public void stop() {
                super.stop();
              }
            });
  }
コード例 #12
0
ファイル: Shop.java プロジェクト: amarsut/Konklex
 /**
  * Refresh the shop for all viewers.
  *
  * @param si The slotted item to refresh.
  */
 public void refresh(SlottedItem si) {
   for (Player player : players) {
     player.send(new UpdateSlottedItemsEvent(3900, si));
   }
 }
コード例 #13
0
ファイル: Shop.java プロジェクト: amarsut/Konklex
 /** Refresh the shop for all viewers. */
 public void refresh() {
   for (Player player : players) {
     player.send(new UpdateItemsEvent(3900, items.getItems()));
   }
 }
コード例 #14
0
ファイル: CastleWars.java プロジェクト: SimonSheehan/Konklex
 /** The ticker, called every second. */
 public void process() {
   if (getAttribute(0)) {
     if (tick <= 0) {
       for (Player player : getPlayers(GameType.ACTIVE)) {
         player.teleport(new Position(2440, 3090, 0), false);
         player.getInterfaceSet().openWalkable(-1);
       }
       setAttribute(0, false);
       clear(GameType.ACTIVE);
     } else {
       ArrayList<Player> players = getPlayers(GameType.ACTIVE);
       if (getAttribute(1)) {
         for (Player player : players) {
           sendConfig(player);
         }
         setAttribute(1, false);
       }
       if (getAttribute(2)) {
         int time = tick / 60 == 0 ? 1 : tick / 60;
         for (Player player : players) {
           player.send(new ConfigEvent(380, time));
         }
         for (Player player : getPlayers(GameType.WAITING)) {
           player.send(new ConfigEvent(380, time));
         }
         setAttribute(2, false);
       }
       if (getAttribute(3)) {
         for (Player player : players) {
           updateFlag(player, Team.SARADOMIN);
         }
         setAttribute(3, false);
       }
       if (getAttribute(4)) {
         for (Player player : players) {
           updateFlag(player, Team.ZAMORAK);
         }
         setAttribute(4, false);
       }
       tick--;
     }
   } else if (tick <= 0) {
     for (Player player : getPlayers(GameType.WAITING)) {
       Team team = getTeam(player, GameType.WAITING);
       if (addPlayer(team, GameType.ACTIVE, player)) {
         player.teleport(teams.get(team).getGame(), false);
       }
     }
     setAttribute(0, true);
     clear(GameType.WAITING);
   } else {
     if (getAttribute(2)) {
       int time = tick / 60 == 0 ? 1 : tick / 60;
       for (Player player : getPlayers(GameType.WAITING)) {
         player.send(new ConfigEvent(380, time));
       }
       setAttribute(2, false);
     }
     tick--;
   }
 }
コード例 #15
0
ファイル: Compost.java プロジェクト: root-voicenet/Konklex
  /* 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();
              }
            });
  }
コード例 #16
0
ファイル: Compost.java プロジェクト: root-voicenet/Konklex
  /* handle compost bin updating */
  private void updateCompostBin(int index) {
    CompostBinStages compostBinStages =
        CompostBinStages.forId(CompostBinLocations.forId(index).getBinObjectId());

    if (compostBinStages == null) {
      return;
    }
    int x = CompostBinLocations.forId(index).getBinPosition().getX();
    int y = CompostBinLocations.forId(index).getBinPosition().getY();
    int z = CompostBinLocations.forId(index).getBinPosition().getHeight();
    int finalObject;

    // handling the different ways to fill a compost bin
    if (compostBins[index] > 0) {
      if (compostBins[index] % 17 == 0) {
        finalObject = compostBinStages.getBinWithSuperCompostable();
      } else if (compostBins[index] % 77 == 0) {
        finalObject = compostBinStages.getBinWithTomatoes();
      } else {
        finalObject = compostBinStages.getBinWithCompostable();
      }
    } else {
      finalObject = compostBinStages.getBinEmpty();
    }

    // handling the different ways to complete a compost bin
    if (compostBins[index] == 255) {
      finalObject = compostBinStages.getBinFullOFSuperCompostable();
      tempCompostState = 2;
    } else if (compostBins[index] == 1155) {
      finalObject = compostBinStages.getBinFullOfTomatoes();
      tempCompostState = 3;
    } else if (organicItemAdded[index] == 15) {
      finalObject = compostBinStages.getBinFullOfCompostable();
      tempCompostState = 1;
    }
    // handling the closed state of the compost bin
    switch (compostBins[index]) {
      case 100:
      case 200:
      case 300:
        finalObject = compostBinStages.getClosedBin();
        break;

        // handling the rotted state of the compost in the bin
      case 150:
        finalObject = compostBinStages.getBinFullOfCompost();
        break;
      case 250:
        finalObject = compostBinStages.getBinFullOfSuperCompost();
        break;
      case 350:
        finalObject = compostBinStages.getBinFullOfRottenTomatoes();
        break;
    }

    // handle the compost bin state when the player retrieve the compost
    if (compostBins[index] == 150 && organicItemAdded[index] < 15) {
      finalObject = compostBinStages.getBinWithCompost();
    } else if (compostBins[index] == 250 && organicItemAdded[index] < 15) {
      finalObject = compostBinStages.getBinWithSuperCompost();
    }
    if (compostBins[index] == 350 && organicItemAdded[index] < 15) {
      finalObject = compostBinStages.getBinWithRottenTomatoes();
    }

    final Position pos = new Position(x, y, z);
    GameObject object =
        new GameObject(
            ObjectDefinition.forId(finalObject),
            pos,
            10,
            CompostBinLocations.forId(index).getObjectFace());
    player.send(new PositionEvent(player.getLastKnownRegion(), pos));
    player.send(new CreateObjectEvent(object));
  }