Fix nitpicks in Mining plugin

Also adds equals() and hashcode() implementations to the various
Mining actions.
This commit is contained in:
Major
2018-03-28 16:50:43 +01:00
parent 173623b76b
commit 6941fc9de0
5 changed files with 257 additions and 214 deletions
+23 -19
View File
@@ -1,23 +1,27 @@
package org.apollo.game.plugin.skills.mining
import org.apollo.game.model.Animation;
import org.apollo.game.model.Animation
import org.apollo.game.model.entity.Player
import org.apollo.game.plugin.api.mining
enum class Pickaxe(val id: Int, val level: Int, val animation: Animation, val pulses: Int) {
RUNE(1275, 41, Animation(624), 3),
ADAMANT(1271, 31, Animation(628), 4),
MITHRIL(1273, 21, Animation(629), 5),
STEEL(1269, 1, Animation(627), 6),
ITRON(1267, 1, Animation(626), 7),
BRONZE(1265, 1, Animation(625), 8)
enum class Pickaxe(val id: Int, val level: Int, animation: Int, val pulses: Int) {
BRONZE(id = 1265, level = 1, animation = 625, pulses = 8),
ITRON(id = 1267, level = 1, animation = 626, pulses = 7),
STEEL(id = 1269, level = 1, animation = 627, pulses = 6),
MITHRIL(id = 1273, level = 21, animation = 629, pulses = 5),
ADAMANT(id = 1271, level = 31, animation = 628, pulses = 4),
RUNE(id = 1275, level = 41, animation = 624, pulses = 3);
val animation = Animation(animation)
companion object {
private val PICKAXES = Pickaxe.values().sortedByDescending { it.level }
fun bestFor(player: Player): Pickaxe? {
return PICKAXES.asSequence()
.filter { it.level <= player.mining.current }
.filter { player.equipment.contains(it.id) || player.inventory.contains(it.id) }
.firstOrNull()
}
}
}
val PICKAXES = Pickaxe.values()
fun getPickaxes(): Array<Pickaxe> {
return PICKAXES
}
fun lookupPickaxe(id: Int): Pickaxe? = PICKAXES.find { it.id == id }