RuneHive-Game
Loading...
Searching...
No Matches
SmeltingData.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.smithing;
2
3/**
4 * Created by Daniel on 2017-12-31.
5 */
6
7import com.google.common.collect.ImmutableSet;
8import com.google.common.collect.Sets;
9import com.runehive.game.world.items.Item;
10
11import java.util.EnumSet;
12import java.util.Optional;
13
14/** The enumerated type whose elements represent definitions for each smeltable bar. */
15public enum SmeltingData {
16 BRONZE(3987, new Item[]{new Item(438), new Item(436)}, new Item[]{new Item(2349)}, 6.25, 1),
17 BRONZE_5(3986, BRONZE, 5),
18 BRONZE_10(2807, BRONZE, 10),
19 BRONZE_X(2414, BRONZE, -1),
20 IRON(3991, new Item[]{new Item(440)}, new Item[]{new Item(2351)}, 12.5, 15),
21 IRON_5(3990, IRON, 5),
22 IRON_10(3989, IRON, 10),
23 IRON_X(3988, IRON, -1),
24 SILVER(3995, new Item[]{new Item(442)}, new Item[]{new Item(2355)}, 13.67, 20),
25 SILVER_5(3994, SILVER, 5),
26 SILVER_10(3993, SILVER, 10),
27 SILVER_X(3992, SILVER, -1),
28 STEEL(3999, new Item[]{new Item(440), new Item(453, 2)}, new Item[]{new Item(2353)}, 17.5, 30),
29 STEEL_5(3998, STEEL, 5),
30 STEEL_10(3997, STEEL, 10),
31 STEEL_X(3996, STEEL, -1),
32 GOLD(4003, new Item[]{new Item(444)}, new Item[]{new Item(2357)}, 22.5, 40),
33 GOLD_5(4002, GOLD, 5),
34 GOLD_10(4001, GOLD, 10),
35 GOLD_X(4000, GOLD, -1),
36 MITHRIL(7441, new Item[]{new Item(447), new Item(453, 4)}, new Item[]{new Item(2359)}, 30, 50),
37 MITHRIL_5(7440, MITHRIL, 5),
38 MITHRIL_10(6397, MITHRIL, 10),
39 MITHRIL_X(4158, MITHRIL, -1),
40 ADAMANT(7446, new Item[]{new Item(449), new Item(453, 6)}, new Item[]{new Item(2361)}, 37.5, 70),
41 ADAMANT_5(7444, ADAMANT, 5),
42 ADAMANT_10(7443, ADAMANT, 10),
43 ADAMANT_X(7442, ADAMANT, -1),
44 RUNITE(7450, new Item[]{new Item(451), new Item(453, 8)}, new Item[]{new Item(2363)}, 50, 85),
45 RUNITE_5(7449, RUNITE, 5),
46 RUNITE_10(7448, RUNITE, 10),
47 RUNITE_X(7447, RUNITE, -1);
48
49 /** Caches our enum values. */
50 private static final ImmutableSet<SmeltingData> VALUES = Sets.immutableEnumSet(EnumSet.allOf(SmeltingData.class));
51
52 /** The button identification. */
53 private final int buttonId;
54
55 /** The required items to smelt this bar. */
56 public final Item[] required;
57
58 /** he produced items for smelting the required items. */
59 public final Item[] produced;
60
61 /** The experience gained upon smelting one bar. */
62 public final double experience;
63
64 /** The requirement required to smelt the bar. */
65 public final int requirement;
66
67 /** The amount we're producing. */
68 public final int amount;
69
70 /** Constructs a new {@link SmeltingData} enumerator. */
72 this.buttonId = buttonId;
73 this.required = required;
74 this.produced = produced;
75 this.experience = experience;
76 this.requirement = requirement;
77 this.amount = 1;
78 }
79
80 /** Constructs a new {@link SmeltingData} enumerator. */
81 SmeltingData(int buttonId, SmeltingData definition, int amount) {
82 this.buttonId = buttonId;
83 this.required = definition.required;
84 this.produced = definition.produced;
85 this.experience = definition.experience;
86 this.requirement = definition.requirement;
87 this.amount = amount;
88 }
89
90 /** Searches for a match for the internal button identification. */
91 public static Optional<SmeltingData> getDefinition(int buttonId) {
92 return VALUES.stream().filter(def -> def.buttonId == buttonId).findAny();
93 }
94
95 /** Searches for a match for the internal required items. */
96 public static Optional<SmeltingData> getDefinitionByItem(int itemId) {
97 for (SmeltingData data : VALUES) {
98 for (Item item : data.required) {
99 if (item.getId() == itemId) {
100 return Optional.of(data);
101 }
102 }
103 }
104 return Optional.empty();
105 }
106
107 public static SmeltingData getSmeltData(int itemId) {
108 switch(itemId) {
109 case 438:
110 case 436:
111 return BRONZE;
112 case 440:
113 return IRON;
114 case 442:
115 return SILVER;
116 case 444:
117 return GOLD;
118 case 447:
119 return MITHRIL;
120 case 449:
121 return ADAMANT;
122 case 451:
123 return RUNITE;
124 }
125 return null;
126 }
127}
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 amount
The amount we're producing.
SmeltingData(int buttonId, Item[] required, Item[] produced, double experience, int requirement)
Constructs a new SmeltingData enumerator.
static Optional< SmeltingData > getDefinition(int buttonId)
Searches for a match for the internal button identification.
final Item[] required
The required items to smelt this bar.
static Optional< SmeltingData > getDefinitionByItem(int itemId)
Searches for a match for the internal required items.
SmeltingData(int buttonId, SmeltingData definition, int amount)
Constructs a new SmeltingData enumerator.
final int requirement
The requirement required to smelt the bar.
static final ImmutableSet< SmeltingData > VALUES
Caches our enum values.
final int buttonId
The button identification.
final Item[] produced
he produced items for smelting the required items.
final double experience
The experience gained upon smelting one bar.