예제 #1
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.");
   }
 }
예제 #2
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();
   }
 }
예제 #3
0
 /**
  * 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);
       }
     }
   }
 }