Use a map for bone and prayer lookups

This commit is contained in:
Gary Tierney
2018-03-31 22:24:10 +01:00
parent 7c59c2c3a5
commit 2b7a62d997
+4 -4
View File
@@ -35,9 +35,9 @@ enum class Bone(val id: Int, val xp: Double) {
OURG_BONES(id = 4834, xp = 140.0); OURG_BONES(id = 4834, xp = 140.0);
companion object { companion object {
private val BONES = Bone.values() private val BONES = Bone.values().associateBy { it.id }
operator fun get(id: Int) = BONES.find { bone -> bone.id == id } operator fun get(id: Int) = BONES[id]
} }
} }
@@ -62,9 +62,9 @@ enum class Prayer(val button: Int, val level: Int, val setting: Int, val drain:
SMITE(button = 685, level = 52, setting = 100, drain = 0.2); SMITE(button = 685, level = 52, setting = 100, drain = 0.2);
companion object { companion object {
private val PRAYERS = Prayer.values() private val PRAYERS = Prayer.values().associateBy { it.button }
fun forButton(button: Int) = PRAYERS.find { it.button == button } fun forButton(button: Int) = PRAYERS[button]
} }
} }