RuneHive-Game
Loading...
Searching...
No Matches
ViggorasChainmace.java
Go to the documentation of this file.
1package com.runehive.content.itemaction.impl;
2
3import com.runehive.content.itemaction.ItemAction;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.items.Item;
6import com.runehive.game.world.items.ItemDefinition;
7import com.runehive.net.packet.out.SendInputAmount;
8import com.runehive.util.Utility;
9
10public class ViggorasChainmace extends ItemAction {
11
12 public static final short VIGGORAS_CHAINMACE_UNCHARGED_ID = 22542;
13 public static final short VIGGORAS_CHAINMACE_CHARGED_ID = 22545;
14 public static final short ETHER_ID = 21820;
15
16 @Override
17 public String name() {
18 return "Viggora's chainmace";
19 }
20
21 @Override
22 public boolean itemOnItem(Player player, Item first, Item second) {
23 System.out.println("?????");
25 System.out.println("dfgdfgdfg");
26 return false;
27 }
28
29 if(first.getId() == ETHER_ID || second.getId() == ETHER_ID) {
31 if(!player.inventory.contains(ETHER_ID, 1000)) {
32 player.message("You need at least 1000 "+ ItemDefinition.get(ETHER_ID).getName() +" to charge the "+name()+".");
33 return true;
34 }
35 player.inventory.remove(ETHER_ID, 1000);
38 player.inventory.refresh();
39 } else {
40 System.out.println("Recharge craws bow");
41 player.send(new SendInputAmount("How many charges would you like add? (0-"+player.inventory.computeAmountForId(ETHER_ID)+")", 10, input -> charge(player, Integer.parseInt(input))));
42 }
43 return true;
44 }
45
46 return false;
47 }
48
49 @Override
50 public boolean inventory(Player player, Item item, int opcode) {
52 return false;
53 }
54
55 if (opcode == 2) {
56 check(player);
57 return true;
58 }
59
60 return false;
61 }
62
63 @Override
64 public boolean equipment(Player player, Item item, int opcode) {
66 return false;
67 }
68 if (opcode == 1) {
69 check(player);
70 return true;
71 }
72 return true;
73 }
74
75 @Override
76 public boolean drop(Player player, Item item) {
78 return false;
79 }
80
83 player.inventory.add(ETHER_ID, 1000 + player.viggorasChainmaceCharges);
84 player.viggorasChainmaceCharges = 0;
85
86 player.message("You uncharge your "+name()+".");
87
88 return true;
89 }
90
91 private void check(Player player) {
92 player.message("You have " + Utility.formatDigits(player.viggorasChainmaceCharges) + " charges in your "+name()+".");
93 }
94
95 private void charge(Player player, int amount) {
96 if (amount > player.inventory.computeAmountForId(ETHER_ID)) {
97 amount = player.inventory.computeAmountForId(ETHER_ID);
98 }
99 if (amount > 0) {
100 player.inventory.remove(ETHER_ID, amount);
101 player.inventory.refresh();
102 player.viggorasChainmaceCharges += amount;
103 player.message("You added " + amount + " charges to your "+name()+"");
104 }
105 }
106
107}
Handles executing an item action.
boolean equipment(Player player, Item item, int opcode)
boolean itemOnItem(Player player, Item first, Item second)
boolean inventory(Player player, Item item, int opcode)
The execution method of the action.
This class represents a character controlled by a player.
Definition Player.java:125
Represents all of an in-game Item's attributes.
static ItemDefinition get(int id)
Gets an item definition.
The container class that represents an item that can be interacted with.
Definition Item.java:21
final int getId()
Gets the identification of this item.
Definition Item.java:324
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.
boolean add(Item item)
Attempts to deposit item into this container.
boolean contains(int id)
Determines if this container contains id.
void refresh()
Refreshes the players inventory.
Handles miscellaneous methods.
Definition Utility.java:27
static String formatDigits(final int amount)
Formats digits for integers.
Definition Utility.java:41