RuneHive-Game
Loading...
Searching...
No Matches
TradingPostListing.java
Go to the documentation of this file.
1package com.runehive.content.tradingpost;
2
3import com.runehive.game.world.entity.mob.player.Player;
4import com.runehive.net.packet.out.SendMessage;
5
6public class TradingPostListing {
7 private final int itemId;
8 private final String seller;
9 private int amountSold = 0;
10 private int price;
11 private int initialQuantity = 1;
12
13 public TradingPostListing(int itemId, String seller) {
14 this.itemId = itemId;
15 this.seller = seller;
16 }
17
18 public int getItemId() {
19 return itemId;
20 }
21
22 public int getInitialQuantity() {
23 return initialQuantity;
24 }
25
26 public void setQuantity(Player player, int quantity) {
27 this.initialQuantity = quantity;
28 if (this.initialQuantity == 0) {
29 this.initialQuantity = 1;
30 }
31 checkAndUpdate(player);
32 }
33
34 public int getPrice() {
35 return price;
36 }
37
38 public void setPrice(Player player, int price) {
39 if ((long) price * initialQuantity > Integer.MAX_VALUE) {
40 player.send(new SendMessage("Unable to set this price to this quantity. reason: above max integer value."));
41 return;
42 }
43 this.price = price;
45 }
46
47 public String getSeller() {
48 return seller;
49 }
50
51 public void removeQuantity(Player player, int amount) {
52 initialQuantity -= amount;
53 if (initialQuantity <= 0) {
55 }
58 }
59
60 public void addQuantity(Player player, int amount) {
61 initialQuantity += amount;
62 checkAndUpdate(player);
63 }
64
65 public void checkAndUpdate(Player player) {
66 int playerAmount = player.inventory.computeAmountForId(itemId);
67 if (initialQuantity > playerAmount) {
68 initialQuantity = playerAmount;
69 }
72 }
73
74 public int getAmountLeft() {
76 }
77
78 public int getAmountSold() {
79 return amountSold;
80 }
81
82 public void addToAmountSold(int amountSold) {
83 this.amountSold += amountSold;
84 }
85
86 public void setAmountSold(int amountSold) {
87 this.amountSold = amountSold;
88 }
89
90 public void setPrice(int price) {
91 this.price = price;
92 }
93
95 this.initialQuantity = initialQuantity;
96 }
97}
void updatePriceStrings()
void updateQuantityString()
TradingPostListing(int itemId, String seller)
int getAmountLeft()
int getPrice()
void setPrice(int price)
void removeQuantity(Player player, int amount)
int getInitialQuantity()
void addQuantity(Player player, int amount)
void setPrice(Player player, int price)
int initialQuantity
void setInitialQuantity(int initialQuantity)
void addToAmountSold(int amountSold)
void setAmountSold(int amountSold)
void setQuantity(Player player, int quantity)
int getItemId()
int getAmountSold()
int amountSold
final String seller
String getSeller()
void checkAndUpdate(Player player)
int price
final int itemId
This class represents a character controlled by a player.
Definition Player.java:125
final int computeAmountForId(int id)
Computes the total quantity of the Items in this container with id.
The OutgoingPacket that sends a message to a Players chatbox in the client.