42 public static void open(
Player player) {
44 if (player.skulling.isSkulled()) {
50 final Item[] keep =
new Item[kept];
52 final Queue<Item> items =
new PriorityQueue<Item>(
ItemComparator.SHOP_VALUE_COMPARATOR);
54 for (
final Item item : player.inventory.
toArray()) {
56 items.add(item.copy());
60 for (
final Item item : player.equipment.
toArray()) {
62 items.add(item.copy());
66 final Queue<Item> temp =
new PriorityQueue<>(items);
68 for (
int index = 0, taken = 0; index < keep.length; index++) {
69 keep[index] = temp.poll();
70 items.remove(keep[index]);
72 if (keep[index] !=
null) {
73 if (keep[index].getAmount() == keep.length - taken) {
77 if (keep[index].getAmount() > keep.length - taken) {
78 items.add(
new Item(keep[index].getId(), keep[index].getAmount() - (keep.length - taken)));
79 keep[index].setAmount(keep.length - taken);
83 taken += keep[index].getAmount();
87 player.send(
new SendString(
"~ " + kept +
" ~", 17112));
92 player.send(
new SendString(
"You're marked with a \\n<col=ff0000>skull. </col>This reduces the \\nitems you keep from \\nthree to zero!", 17110));
95 player.send(
new SendString(
"You're marked with a \\n<col=ff0000>skull. </col>This reduces the \\nitems you keep from \\nthree to zero! \\nHowever, you also have the \\n<col=ff0000>Protect </col>Items prayer \\nactive, which saves you \\none extra item!", 17110));
98 player.send(
new SendString(
"You have no factors affecting \\nthe items you keep.", 17110));
101 player.send(
new SendString(
"You have the <col=ff0000>Protect Item</col> \\nprayer active, which saves \\nyou none extra item!", 17110));
108 player.send(
new SendString(
"Carried wealth: \\n<col=ff0000>Nothing!", 17115));
109 }
else if (carried >= Long.MAX_VALUE) {
110 player.send(
new SendString(
"Carried wealth: \\n<col=ff0000>Too much!", 17115));
115 Item[] dropped = items.toArray(
new Item[0]);
117 BigInteger risked = BigInteger.ZERO;
118 while (items.peek() !=
null) {
119 final Item dropping = items.poll();
121 if (dropping ==
null) {
125 risked = risked.add(
new BigInteger(String.valueOf(dropping.getValue(
PriceType.
VALUE))).multiply(
new BigInteger(String.valueOf(dropping.getAmount()))));
128 player.send(
new SendString(
"Risked wealth:", 17124));
130 if (risked.equals(BigInteger.ZERO)) {
131 player.send(
new SendString(
"Risked wealth: \\n<col=ff0000>Nothing!", 17116));
133 player.send(
new SendString(
"Risked wealth: \\n<col=ff0000>" + NumberFormat.getNumberInstance(Locale.US).format(risked) +
"</col> coins.", 17116));
138 player.interfaceManager.
open(17100);