RuneHive-Game
Loading...
Searching...
No Matches
AxeData.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.woodcutting;
2
3import com.google.common.collect.ImmutableSet;
4import com.google.common.collect.ImmutableSortedSet;
5import com.runehive.game.world.entity.mob.player.Player;
6import com.runehive.game.world.entity.skill.Skill;
7
8import java.util.Optional;
9
10
11/**
12 * Represents types of axes.
13 *
14 * @author Daniel
15 */
16public enum AxeData {
17 BRONZE(1351, 1, 879, 0.1),
18 IRON(1349, 1, 877, 0.2),
19 STEEL(1353, 6, 875, 0.3),
20 BLACK(1361, 6, 873, 0.4),
21 MITHRIL(1355, 21, 871, 0.5),
22 ADAMANT(1357, 31, 869, 0.6),
23 RUNE(1359, 41, 867, 0.75),
24 THIRD_AGE(20011, 90, 7264, 0.80),
25 DRAGON(6739, 61, 2846, 0.85),
26 INFERNAL(13241, 61, 2117, 0.85);
27
28 /**
29 * Caches our enum values.
30 */
31 private static final ImmutableSet<AxeData> VALUES = ImmutableSortedSet.copyOf(values()).descendingSet();
32
33 /**
34 * The id.
35 */
36 public final int id;
37
38 /**
39 * The level.
40 */
41 public final int level;
42
43 /**
44 * The animation.
45 */
46 public final int animation;
47
48 /**
49 * The speed of cutting logs.
50 */
51 public final double speed;
52
53 /**
54 * Creates the axe.
55 *
56 * @param id The id.
57 * @param level The required level.
58 * @param animation The animation id.
59 * @param speed {@link #speed}.
60 */
61 AxeData(int id, int level, int animation, double speed) {
62 this.id = id;
63 this.level = level;
64 this.animation = animation;
65 this.speed = speed;
66 }
67
68 /**
69 * Gets the definition for this hatchet.
70 * @param player the identifier to check for.
71 * @return an optional holding the {@link AxeData} value found,
72 * {@link Optional#empty} otherwise.
73 */
74 public static Optional<AxeData> getDefinition(Player player) {
75 if (player.equipment.hasWeapon()) {
76 Optional<AxeData> result = VALUES.stream().filter(it -> player.equipment.contains(it.id) && player.skills.getLevel(Skill.WOODCUTTING) >= it.level).findFirst();
77
78 if (result.isPresent()) {
79 return result;
80 }
81 }
82 return VALUES.stream().filter(def -> player.inventory.contains(def.id) && player.skills.getLevel(Skill.WOODCUTTING) >= def.level).findAny();
83 }
84
85
86}
This class represents a character controlled by a player.
Definition Player.java:125
Represents a trainable and usable skill.
Definition Skill.java:18
static final int WOODCUTTING
The woodcutting skill id.
Definition Skill.java:45
int getLevel(int id)
Gets the level of a skill.
boolean contains(int id)
Determines if this container contains id.
boolean contains(int[] bowsWithNoArrowsRequired)
static Optional< AxeData > getDefinition(Player player)
Gets the definition for this hatchet.
Definition AxeData.java:74
static final ImmutableSet< AxeData > VALUES
Caches our enum values.
Definition AxeData.java:31
AxeData(int id, int level, int animation, double speed)
Creates the axe.
Definition AxeData.java:61
final double speed
The speed of cutting logs.
Definition AxeData.java:51