RuneHive-Game
Loading...
Searching...
No Matches
EquipmentDefinitionParser.java
Go to the documentation of this file.
1package com.runehive.util.parser.old;
2
3import com.google.gson.JsonObject;
4import com.runehive.game.world.items.ItemDefinition;
5import com.runehive.game.world.items.containers.equipment.EquipmentType;
6import com.runehive.util.parser.GsonParser;
7
8/**
9 * Parses through the equipment definitions file and creates equipment
10 * definition object.
11 *
12 * @author Daniel | Obey
13 */
15
17 super("def/equipment/equipment_definitions");
18 }
19
20 public static void main(String[] args) {
21 new EquipmentDefinitionParser().run();
22 // ItemDefinition.merge("wiki/client_item_dump", "wiki/wiki_item_dump", "wiki/new_item_dump");
23 ItemDefinition.dump(ItemDefinition.create("wiki/new_item_dump"), "wiki/item_definitions");
24 }
25
26 @Override
27 public void initialize(int size) {
29 }
30
31 @Override
32 protected void parse(JsonObject data) {
33 int id = data.get("id").getAsInt();
34 ItemDefinition definition = ItemDefinition.get(id);
35
36 if (definition.getEquipmentType() == EquipmentType.NOT_WIELDABLE) {
37 String name = definition.getName().toLowerCase();
38 if (name.startsWith("hood") || name.endsWith("hood")) {
39 definition.setEquipmentType(EquipmentType.FACE);
40 } else if (name.contains("full helm")) {
41 definition.setEquipmentType(EquipmentType.HELM);
42 } else if (name.contains("med helm")) {
43 definition.setEquipmentType(EquipmentType.FACE);
44 } else if (name.contains("helm")) {
45 if (name.startsWith("dharok")) {
46 definition.setEquipmentType(EquipmentType.FACE);
47 } else {
48 definition.setEquipmentType(EquipmentType.HELM);
49 }
50 }
51 }
52
53 }
54
55 @Override
56 protected void onEnd() {
57 ItemDefinition.dump("def/item/newer_item_definitions");
58 }
59
60 private static int getReq(String first, String second, EquipmentType type) {
61 switch (first) {
62 case "bronze":
63 if (type == EquipmentType.WEAPON || type == EquipmentType.ARROWS) {
64 return -1;
65 }
66 return 1;
67
68 case "iron":
69 if (type == EquipmentType.WEAPON || type == EquipmentType.ARROWS) {
70 return -1;
71 }
72 return 1;
73
74 case "steel":
75 if (type == EquipmentType.WEAPON || type == EquipmentType.ARROWS) {
76 return -1;
77 }
78 return 10;
79
80 case "mithril":
81 if (type == EquipmentType.WEAPON || type == EquipmentType.ARROWS) {
82 return -1;
83 }
84 return 20;
85
86 case "adamant":
87 if (type == EquipmentType.WEAPON || type == EquipmentType.ARROWS) {
88 return -1;
89 }
90 return 30;
91
92 case "rune":
93 if (type == EquipmentType.WEAPON || type == EquipmentType.ARROWS) {
94 return -1;
95 }
96 return 40;
97
98 case "dragon":
99 case "toktz-ket-xil":
100 if (type == EquipmentType.WEAPON || type == EquipmentType.ARROWS) {
101 return -1;
102 }
103 return 60;
104
105 case "bandos":
106 if (second.equals("mitre") || second.equals("robe")) {
107 return -1;
108 }
109
110 if (second.startsWith("plate") || second.startsWith("full") || second.startsWith("kite")) {
111 return 40;
112 }
113 if (type == EquipmentType.WEAPON) {
114 return -1;
115 }
116 return 65;
117
118 case "armadyl":
119 if (second.equals("mitre") || second.equals("robe")) {
120 return -1;
121 }
122
123 if (second.startsWith("plate") || second.startsWith("full") || second.startsWith("kite")) {
124 return 40;
125 }
126 if (type == EquipmentType.WEAPON) {
127 return -1;
128 }
129 return 70;
130
131 case "dharok's":
132 case "guthan's":
133 case "torag's":
134 case "verac's":
135 case "karil's":
136 case "ahrim's":
137 case "barrows":
138 if (type == EquipmentType.WEAPON) {
139 return -1;
140 }
141 return 70;
142
143 case "dragonfire":
144 return 75;
145
146 case "neitiznot":
147 return 55;
148
149 case "saradomin":
150 case "guthix":
151 case "zamorak":
152 if (second.equals("mitre") || second.equals("robe")) {
153 return -1;
154 }
155 if (type == EquipmentType.WEAPON) {
156 return -1;
157 }
158 return 40;
159
160 case "berserker":
161 case "archer":
162 case "farseer":
163 case "warrior":
164 if (type == EquipmentType.RING) {
165 return -1;
166 }
167 return 45;
168
169 case "green":
170 case "red":
171 case "blue":
172 case "black":
173 if (type != EquipmentType.BODY) {
174 return -1;
175 }
176
177 return 40;
178
179 case "hardleather":
180 if (type != EquipmentType.BODY) {
181 return -1;
182 }
183
184 return 10;
185
186 case "void":
187 return 42;
188
189 case "snakeskin":
190 return 30;
191
192 case "3rd":
193 return 45;
194
195 case "penance":
196 case "runner":
197 case "fighter":
198 if (type == EquipmentType.GLOVES) {
199 return -1;
200 }
201 return 40;
202 }
203 return -1;
204 }
205
206}
Represents all of an in-game Item's attributes.
static void dump(ItemDefinition[] definitions, String path)
static ItemDefinition[] create(String path)
static ItemDefinition get(int id)
Gets an item definition.
GsonParser(String path)
Creates a new GsonParser.
static int getReq(String first, String second, EquipmentType type)
void parse(JsonObject data)
The method allows a user to modify the data as its being parsed.
void onEnd()
This method handles what happens after the parser has ended.
The enumerated types of a players equipped item slots.