1package com.osroyale.content.store;
3import com.osroyale.content.store.currency.CurrencyType;
4import com.osroyale.game.world.items.Item;
6import java.util.Optional;
7import java.util.OptionalInt;
42* A simple wrapper
class which holds extra attributes for the item object.
44 * @author <a href=
"http://www.rune-server.org/members/stand+up/">Stand Up</a>
47public final class StoreItem
extends Item {
52 public static final int RESTOCK_RATE = 5;
55 public OptionalInt value = OptionalInt.empty();
58 public Optional<CurrencyType> currency = Optional.empty();
63 private int restockTimer = RESTOCK_RATE;
66 public StoreItem(
int id,
int amount, OptionalInt value, Optional<CurrencyType> currency) {
69 this.currency = currency;
72 public StoreItem(
int id,
int amount,
int value) {
73 this(id, amount, OptionalInt.of(value), Optional.of(CurrencyType.COINS));
76 public StoreItem(
int id,
int amount) {
77 this(id, amount, OptionalInt.empty(), Optional.empty());
80 public int getShopValue() {
81 return value.orElse((
int)((
double)getValue() * 1.20));
84 public void setShopValue(
int value) {
85 this.value = OptionalInt.of(value);
88 public CurrencyType getShopCurrency(Store store) {
89 return currency.orElse(store.currencyType);
92 public void setCurrency(CurrencyType type) {
93 this.currency = currency;
96 public boolean canReduce() {
97 if (--restockTimer <= 0) {
98 restockTimer = RESTOCK_RATE;
105 public StoreItem copy() {
106 return new StoreItem(getId(), getAmount(), value, currency);