RuneHive-Game
Loading...
Searching...
No Matches
WeaponDefinition.java
Go to the documentation of this file.
1package com.runehive.util.parser.old.defs;
2
3import com.runehive.Config;
4import com.runehive.game.world.entity.combat.ranged.RangedWeaponDefinition;
5
6import java.util.Optional;
7
8public class WeaponDefinition {
10 private final int item;
11 private final String name;
12 private final boolean twoHanded;
13 private final String weaponType;
15 private final int stand;
16 private final int walk;
17 private final int run;
18
19 public WeaponDefinition(int item, String name, boolean twoHanded, String weaponType, RangedWeaponDefinition rangedDefinition, int stand, int walk, int run) {
20 this.item = item;
21 this.name = name;
22 this.twoHanded = twoHanded;
23 this.weaponType = weaponType;
24 this.rangedDefinition = rangedDefinition;
25 this.stand = stand;
26 this.walk = walk;
27 this.run = run;
28 }
29
30 public int getItem() {
31 return item;
32 }
33
34 public String getName() {
35 return name;
36 }
37
38 public String getWeaponType() {
39 return weaponType;
40 }
41
42 public Optional<RangedWeaponDefinition> getRangedDefinition() {
43 return Optional.ofNullable(rangedDefinition);
44 }
45
46 public boolean isTwoHanded() {
47 return twoHanded;
48 }
49
50 public int getStand() {
51 return stand;
52 }
53
54 public int getWalk() {
55 return walk;
56 }
57
58 public int getRun() {
59 return run;
60 }
61
62 public static boolean isPoisonous(String name) {
63 return name.endsWith("p)") || name.endsWith("p+)") || name.endsWith("p++)");
64 }
65
66 public static int poisonStrength(String name) {
67 return name.endsWith("p)") ? 2 : name.endsWith("p+)") ? 4 : name.endsWith("p++)") ? 6 : 2;
68 }
69
70 /**
71 * Gets an item definition.
72 *
73 * @param id The definition's item id.
74 * @return The item definition for the item id, or null if the item id is
75 * out of bounds.
76 */
77 public static WeaponDefinition get(int id) {
78 if (id < 0 || id >= DEFINITIONS.length) {
79 return null;
80 }
81
82 return DEFINITIONS[id];
83 }
84
85}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final int ITEM_DEFINITION_LIMIT
The limit of the item identification.
Definition Config.java:181
Optional< RangedWeaponDefinition > getRangedDefinition()
WeaponDefinition(int item, String name, boolean twoHanded, String weaponType, RangedWeaponDefinition rangedDefinition, int stand, int walk, int run)