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

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)
 MagmaHelm ()
String name ()
 The name of the action.
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_199
static final DecimalFormat FORMATTER = new DecimalFormat("#.#")
static final short FULL = 11_000
static final short UNCHARGED_HELM = 13_198
static final short ZULRAH_SCALES = 12_934

Detailed Description

Definition at line 15 of file MagmaHelm.java.

Constructor & Destructor Documentation

◆ MagmaHelm()

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

Definition at line 25 of file MagmaHelm.java.

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

References FORMATTER.

Member Function Documentation

◆ charge()

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

Definition at line 86 of file MagmaHelm.java.

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

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.entity.mob.player.Player.magmaHelmCharges, 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(), 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.MagmaHelm.check ( Player player)
static

Definition at line 81 of file MagmaHelm.java.

81 {
82 String scales = FORMATTER.format(player.magmaHelmCharges * 100 / FULL) + "%";
83 player.message("Charges: <col=007F00>" + scales);
84 }

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

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.MagmaHelm.drop ( Player player,
Item item )

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

Definition at line 73 of file MagmaHelm.java.

73 {
74 if (item.matchesId(CHARGED_HELM)) {
75 uncharge(player);
76 return true;
77 }
78 return false;
79 }

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.MagmaHelm.equipment ( Player player,
Item item,
int opcode )

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

Definition at line 65 of file MagmaHelm.java.

65 {
66 if (opcode == 1) {
67 check(player);
68 }
69 return true;
70 }

References check().

Here is the call graph for this function:

◆ inventory()

boolean com.runehive.content.itemaction.impl.MagmaHelm.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 MagmaHelm.java.

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

References check(), and restore().

Here is the call graph for this function:

◆ itemOnItem()

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

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

Definition at line 35 of file MagmaHelm.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.MagmaHelm.name ( )

The name of the action.

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

Definition at line 30 of file MagmaHelm.java.

30 {
31 return "Magma helm";
32 }

◆ restore()

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

Definition at line 125 of file MagmaHelm.java.

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

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.MagmaHelm.uncharge ( Player player)
staticprivate

Definition at line 111 of file MagmaHelm.java.

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

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.magmaHelmCharges, 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(), 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.MagmaHelm.CHARGED_HELM = 13_199
staticprivate

Definition at line 21 of file MagmaHelm.java.

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

◆ FORMATTER

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

Definition at line 23 of file MagmaHelm.java.

Referenced by check(), and MagmaHelm().

◆ FULL

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

Definition at line 16 of file MagmaHelm.java.

Referenced by charge(), and check().

◆ UNCHARGED_HELM

final short com.runehive.content.itemaction.impl.MagmaHelm.UNCHARGED_HELM = 13_198
staticprivate

Definition at line 20 of file MagmaHelm.java.

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

◆ ZULRAH_SCALES

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

Definition at line 18 of file MagmaHelm.java.

Referenced by itemOnItem(), and uncharge().


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