From 7c59c2c3a5b703a9b81cd8664355e3eea2ea7e3e Mon Sep 17 00:00:00 2001 From: Gary Tierney Date: Sat, 31 Mar 2018 22:12:34 +0100 Subject: [PATCH] Clean up remaining issues on prayer plugin --- game/plugin/skills/prayer/src/data.kt | 16 ++++++++-------- game/plugin/skills/prayer/src/prayer.plugin.kts | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/game/plugin/skills/prayer/src/data.kt b/game/plugin/skills/prayer/src/data.kt index 60353664..73510c66 100644 --- a/game/plugin/skills/prayer/src/data.kt +++ b/game/plugin/skills/prayer/src/data.kt @@ -10,9 +10,8 @@ val PLAYER_PRAYERS: SetMultimap = MultimapBuilder.hashKeys() .enumSetValues(Prayer::class.java) .build() -fun Player.getCurrentPrayers(): Set { - return PLAYER_PRAYERS[this] -} +val Player.currentPrayers : Set + get() = PLAYER_PRAYERS[this] enum class Bone(val id: Int, val xp: Double) { REGULAR_BONES(id = 526, xp = 5.0), @@ -63,17 +62,18 @@ enum class Prayer(val button: Int, val level: Int, val setting: Int, val drain: SMITE(button = 685, level = 52, setting = 100, drain = 0.2); companion object { - val PRAYERS = Prayer.values() + private val PRAYERS = Prayer.values() fun forButton(button: Int) = PRAYERS.find { it.button == button } } } fun updatePrayer(player: Player, prayer: Prayer) { - //Clear active prayer - if (player.getCurrentPrayers().contains(prayer)) { - player.send(ConfigMessage(prayer.setting, 0)) + val prayerSettingValue = if (player.currentPrayers.contains(prayer)) { + 1 } else { - player.send(ConfigMessage(prayer.setting, 1)) + 0 } + + player.send(ConfigMessage(prayer.setting, prayerSettingValue)) } \ No newline at end of file diff --git a/game/plugin/skills/prayer/src/prayer.plugin.kts b/game/plugin/skills/prayer/src/prayer.plugin.kts index 5317ade2..a86262b2 100644 --- a/game/plugin/skills/prayer/src/prayer.plugin.kts +++ b/game/plugin/skills/prayer/src/prayer.plugin.kts @@ -34,14 +34,16 @@ on { ItemOptionMessage::class } class BuryBoneAction(val player: Player, val slot: Int, val bone: Bone) : AsyncAction(0, true, player) { override fun action(): ActionBlock = { - if (player.inventory.get(slot).id == bone.id) { + if (player.inventory.removeSlot(slot, 1) > 0) { player.sendMessage("You dig a hole in the ground...") player.playAnimation(BURY_BONE_ANIMATION) + wait(1) //Wait for animation - player.inventory.reset(slot) + player.sendMessage("You bury the bones.") player.prayer.experience += bone.xp } + stop() } } \ No newline at end of file