1package com.runehive.content.store;
3import com.runehive.content.store.currency.CurrencyType;
4import com.runehive.content.store.impl.PersonalStore;
5import com.runehive.game.world.entity.mob.player.Player;
6import com.runehive.game.world.entity.mob.player.PlayerRight;
7import com.runehive.game.world.items.Item;
8import com.runehive.game.world.items.containers.ItemContainer;
9import com.runehive.net.packet.out.SendMessage;
10import com.runehive.util.Utility;
23 public static Map<String, Store>
STORES =
new HashMap<>();
38 public final Set<Player>
players =
new HashSet<>();
44 this.itemCache =
new HashMap<>(
container.capacity());
76 List<PersonalStore> personal_shops =
new ArrayList<>();
78 return personal_shops;
82 List<PersonalStore> featured_shops =
new ArrayList<>();
84 return featured_shops;
96 if (!find.isPresent()) {
100 Item found = find.get();
114 player.
send(
new SendMessage(
"There is none of this item left in stock!"));
118 player.
send(
new SendMessage(
"Ironman-players cannot buy items sold by players."));
128 player.
send(
new SendMessage(
"You do not have enough space in your inventory to buy this item!"));
164 player.
send(
new SendMessage(
"You don't have enough space in your inventory."));
183 if (inventoryItem ==
null) {
205 player.
send(
new SendMessage(
"There is no room in this store for the item you are trying to sell!"));
210 player.
send(
new SendMessage(
"You do not have enough space in your inventory to sell this item!"));
215 player.
send(
new SendMessage(
"You can not sell currency to this shop!"));
222 player.
send(
new SendMessage(
"This item can not be sold as it has a value greater than 500,000 coins!"));
262 player.
send(
new SendMessage(
"You can not sell currency to this shop!"));
280 if (!find.isPresent()) {
284 Item item = find.get();
309 final int prime = 31;
311 result = prime * result + ((
name ==
null) ? 0 :
name.hashCode());
316 public final boolean equals(Object obj) {
321 if (!(obj instanceof
Store))
325 if (other.
name !=
null)
327 }
else if (!
name.equals(other.
name))
Class to execute all constants for Shops.
static final int MAXIMUM_SELL_VALUE
The maximum sell value.
static final int INTERFACE_ID
The identification for the shop itemcontainer.
abstract SellType sellType()
void sendPurchaseValue(Player player, int slot)
static void closeShop(Player player)
final String name
The name of this shop.
Store(String name, ItemContainer.StackPolicy policy, CurrencyType currencyType, int capacity)
abstract void itemContainerAction(Player player, int id, int slot, int action, boolean purchase)
abstract StoreType type()
final Set< Player > players
The set of players that are currently viewing this shop.
Map< Integer, Integer > itemCache
The map of cached shop item identifications and their amounts.
final void sell(Player player, Item item, int slot, boolean addX)
abstract void open(Player player)
static List< PersonalStore > getFeaturedShops()
void onPurchase(Player player, Item item)
final void sendSellValue(Player player, int slot)
static List< PersonalStore > getPersonalShops()
abstract void refresh(Player player)
static Map< String, Store > STORES
A mapping of each shop by it's name.
abstract void close(Player player)
final CurrencyType currencyType
The currency for this shop.
final boolean equals(Object obj)
ItemContainer container
The current item container which contains the current items from this shop.
static void exchange(Player player, int id, int slot, int action, boolean purchase)
boolean purchase(Player player, Item item, int slot)
A simple wrapper class which holds extra attributes for the item object.
CurrencyType getShopCurrency(Store store)
static void add(Player player, PersonalStore store)
final GenericAttributes attributes
boolean isInterfaceOpen(int id)
Checks if a certain interface is enter.
This class represents a character controlled by a player.
final Inventory inventory
void message(String message)
final InterfaceManager interfaceManager
void send(OutgoingPacket encoder)
The container class that represents an item that can be interacted with.
final void setAmount(int amount)
Sets the quantity of this item.
final int getId()
Gets the identification of this item.
static boolean valid(Item item)
Determines if item is valid.
final int getAmount()
Gets the quantity of this item.
boolean matchesId(int id)
An abstraction game representing a group of Items.
final int computeAmountForId(int id)
Computes the total quantity of the Items in this container with id.
boolean remove(Item item)
Attempts to withdraw item from this container.
final Item get(int index)
Gets the Item located on index.
boolean add(Item item)
Attempts to deposit item into this container.
final boolean hasCapacityFor(Item... item)
Determines if this container has the capacity for item.
boolean contains(int id)
Determines if this container contains id.
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles miscellaneous methods.
static String formatDigits(final int amount)
Formats digits for integers.
public< K, E > E get(K key)
Gets a generic attribute.
public< K > boolean has(K key)
Checks if a key is in the list of generic attribute.
Represents ways items can be sold in a shop.
NONE
No items can be sold in the shop.
CONTAINS
Can only sell items that are contained in the shop.
The enumerated type whose elements represent constants that are used to differ between shops.
PERSONAL
The personal shop which is commonly owned by players.
The enumerated type whom holds all the currencies usable for a server.
static boolean isCurrency(int id)
Holds all the player right data.
static boolean isIronman(Player player)
Checks if the player is an ironman.
An enumerated type defining policies for stackable Items.