RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.itemaction.impl.TanzaniteHelm Class Reference
Inheritance diagram for com.runehive.content.itemaction.impl.TanzaniteHelm:
Collaboration diagram for com.runehive.content.itemaction.impl.TanzaniteHelm:

Public Member Functions

boolean drop (Player player, Item item)
boolean equipment (Player player, Item item, int opcode)
boolean inventory (Player player, Item item, int opcode)
 The execution method of the action.
boolean itemOnItem (Player player, Item first, Item second)
String name ()
 The name of the action.
 TanzaniteHelm ()
Public Member Functions inherited from com.runehive.content.itemaction.ItemAction
int delay ()
 The item click delay of the action.
String message (Item item)
 The message of the action.
String toString ()

Static Public Member Functions

static void check (Player player)

Static Private Member Functions

static void charge (Player player, Item helm, Item scales)
static void restore (Player player, Item item)
static void uncharge (Player player)

Static Private Attributes

static final short CHARGED_HELM = 13_197
static final DecimalFormat FORMATTER = new DecimalFormat("#.#")
static final short FULL = 11_000
static final short UNCHARGED_HELM = 13_196
static final short ZULRAH_SCALES = 12_934

Detailed Description

Definition at line 15 of file TanzaniteHelm.java.

Constructor & Destructor Documentation

◆ TanzaniteHelm()

com.runehive.content.itemaction.impl.TanzaniteHelm.TanzaniteHelm ( )

Definition at line 25 of file TanzaniteHelm.java.

25 {
26 FORMATTER.setRoundingMode(RoundingMode.FLOOR);
27 }

References FORMATTER.

Member Function Documentation

◆ charge()

void com.runehive.content.itemaction.impl.TanzaniteHelm.charge ( Player player,
Item helm,
Item scales )
staticprivate

Definition at line 83 of file TanzaniteHelm.java.

83 {
84 if (player.tanzaniteHelmCharges >= FULL) {
85 if (helm.matchesId(UNCHARGED_HELM)) {
86 player.inventory.replace(UNCHARGED_HELM, CHARGED_HELM, true);
87 }
88 player.message("Your Tanzanite helm is already fully charged.");
89 return;
90 }
91
92 if (Integer.MAX_VALUE - scales.getAmount() < FULL) {
93 scales = scales.copy();
94 scales.setAmount(FULL - player.tanzaniteHelmCharges);
95 }
96
97 if (player.tanzaniteHelmCharges + scales.getAmount() > FULL) {
98 scales = scales.copy();
99 scales.setAmount(FULL - player.tanzaniteHelmCharges);
100 }
101
102 player.tanzaniteHelmCharges += scales.getAmount();
103 player.inventory.remove(scales);
104 player.inventory.replace(UNCHARGED_HELM, CHARGED_HELM, true);
105 player.message(String.format("You load %s scales into your Tanzanite helm.", Utility.formatDigits(scales.getAmount())));
106 }

References CHARGED_HELM, com.runehive.game.world.items.Item.copy(), com.runehive.util.Utility.formatDigits(), FULL, com.runehive.game.world.items.Item.getAmount(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.items.Item.matchesId(), com.runehive.game.world.entity.mob.player.Player.message(), com.runehive.game.world.items.containers.ItemContainer.remove(), com.runehive.game.world.items.containers.ItemContainer.replace(), com.runehive.game.world.items.Item.setAmount(), com.runehive.game.world.entity.mob.player.Player.tanzaniteHelmCharges, and UNCHARGED_HELM.

Referenced by itemOnItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check()

void com.runehive.content.itemaction.impl.TanzaniteHelm.check ( Player player)
static

Definition at line 78 of file TanzaniteHelm.java.

78 {
79 String scales = FORMATTER.format(player.tanzaniteHelmCharges * 100 / FULL) + "%";
80 player.message("Charges: <col=007F00>" + scales);
81 }

References FORMATTER, FULL, com.runehive.game.world.entity.mob.player.Player.message(), and com.runehive.game.world.entity.mob.player.Player.tanzaniteHelmCharges.

Referenced by equipment(), and inventory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drop()

boolean com.runehive.content.itemaction.impl.TanzaniteHelm.drop ( Player player,
Item item )

Reimplemented from com.runehive.content.itemaction.ItemAction.

Definition at line 70 of file TanzaniteHelm.java.

70 {
71 if (item.matchesId(CHARGED_HELM)) {
72 uncharge(player);
73 return true;
74 }
75 return false;
76 }

References CHARGED_HELM, com.runehive.game.world.items.Item.matchesId(), and uncharge().

Here is the call graph for this function:

◆ equipment()

boolean com.runehive.content.itemaction.impl.TanzaniteHelm.equipment ( Player player,
Item item,
int opcode )

Reimplemented from com.runehive.content.itemaction.ItemAction.

Definition at line 62 of file TanzaniteHelm.java.

62 {
63 if (opcode == 1) {
64 check(player);
65 }
66 return true;
67 }

References check().

Here is the call graph for this function:

◆ inventory()

boolean com.runehive.content.itemaction.impl.TanzaniteHelm.inventory ( Player player,
Item item,
int opcode )

The execution method of the action.

Reimplemented from com.runehive.content.itemaction.ItemAction.

Definition at line 51 of file TanzaniteHelm.java.

51 {
52 if (opcode == 3) {
53 restore(player, item);
54 } else if (opcode == 2) {
55 check(player);
56 }
57
58 return true;
59 }

References check(), and restore().

Here is the call graph for this function:

◆ itemOnItem()

boolean com.runehive.content.itemaction.impl.TanzaniteHelm.itemOnItem ( Player player,
Item first,
Item second )

Reimplemented from com.runehive.content.itemaction.ItemAction.

Definition at line 35 of file TanzaniteHelm.java.

35 {
36 Item item = first;
37
38 if (first.getId() == UNCHARGED_HELM || first.getId() == CHARGED_HELM) {
39 item = second;
40 }
41
42 if (item.getId() == ZULRAH_SCALES) {
43 charge(player, item.equals(first) ? second : first, item);
44 return true;
45 }
46
47 return false;
48 }

References charge(), CHARGED_HELM, com.runehive.game.world.items.Item.equals(), com.runehive.game.world.items.Item.getId(), UNCHARGED_HELM, and ZULRAH_SCALES.

Here is the call graph for this function:

◆ name()

String com.runehive.content.itemaction.impl.TanzaniteHelm.name ( )

The name of the action.

Reimplemented from com.runehive.content.itemaction.ItemAction.

Definition at line 30 of file TanzaniteHelm.java.

30 {
31 return "Tanzanite Helm";
32 }

◆ restore()

void com.runehive.content.itemaction.impl.TanzaniteHelm.restore ( Player player,
Item item )
staticprivate

Definition at line 122 of file TanzaniteHelm.java.

122 {
123 player.send(new SendItemOnInterfaceSlot(14171, item, 0));
124 player.send(new SendString("Are you sure you want to restore this item?", 14174));
125 player.send(new SendString("Yes.", 14175));
126 player.send(new SendString("No.", 14176));
127 player.send(new SendString("", 14177));
128 player.send(new SendString("This will replace your helm with the original Serpentine helm.", 14182));
129 player.send(new SendString("", 14183));
130 player.send(new SendString(item.getName(), 14184));
131 player.send(new SendChatBoxInterface(14170));
132 player.attributes.set("RESTORE_HELM_KEY", item);
133 }

References com.runehive.game.world.entity.mob.Mob.attributes, com.runehive.game.world.items.Item.getName(), com.runehive.game.world.entity.mob.player.Player.send(), and com.runehive.util.generic.GenericAttributes.set().

Referenced by inventory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uncharge()

void com.runehive.content.itemaction.impl.TanzaniteHelm.uncharge ( Player player)
staticprivate

Definition at line 108 of file TanzaniteHelm.java.

108 {
109 Item scales = new Item(ZULRAH_SCALES, player.tanzaniteHelmCharges);
110
111 if (!player.inventory.hasCapacityFor(scales)) {
112 player.send(new SendMessage("You need more inventory space to do this."));
113 return;
114 }
115
116 player.tanzaniteHelmCharges = 0;
117 player.inventory.add(scales);
118 player.inventory.replace(CHARGED_HELM, UNCHARGED_HELM, true);
119 player.message(String.format("You uncharged your Tanzanite helm and received %s of Zulra's scales.", Utility.formatDigits(scales.getAmount())));
120 }

References com.runehive.game.world.items.containers.ItemContainer.add(), CHARGED_HELM, com.runehive.util.Utility.formatDigits(), com.runehive.game.world.items.Item.getAmount(), com.runehive.game.world.items.containers.ItemContainer.hasCapacityFor(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.entity.mob.player.Player.message(), com.runehive.game.world.items.containers.ItemContainer.replace(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.game.world.entity.mob.player.Player.tanzaniteHelmCharges, UNCHARGED_HELM, and ZULRAH_SCALES.

Referenced by drop().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ CHARGED_HELM

final short com.runehive.content.itemaction.impl.TanzaniteHelm.CHARGED_HELM = 13_197
staticprivate

Definition at line 21 of file TanzaniteHelm.java.

Referenced by charge(), drop(), itemOnItem(), and uncharge().

◆ FORMATTER

final DecimalFormat com.runehive.content.itemaction.impl.TanzaniteHelm.FORMATTER = new DecimalFormat("#.#")
staticprivate

Definition at line 23 of file TanzaniteHelm.java.

Referenced by check(), and TanzaniteHelm().

◆ FULL

final short com.runehive.content.itemaction.impl.TanzaniteHelm.FULL = 11_000
staticprivate

Definition at line 16 of file TanzaniteHelm.java.

Referenced by charge(), and check().

◆ UNCHARGED_HELM

final short com.runehive.content.itemaction.impl.TanzaniteHelm.UNCHARGED_HELM = 13_196
staticprivate

Definition at line 20 of file TanzaniteHelm.java.

Referenced by charge(), itemOnItem(), and uncharge().

◆ ZULRAH_SCALES

final short com.runehive.content.itemaction.impl.TanzaniteHelm.ZULRAH_SCALES = 12_934
staticprivate

Definition at line 18 of file TanzaniteHelm.java.

Referenced by itemOnItem(), and uncharge().


The documentation for this class was generated from the following file: