Port Herblore plugin to Kotlin

This commit is contained in:
Chivvon
2018-04-06 16:50:27 +02:00
committed by Major
parent 9c4eff712e
commit a52837975e
9 changed files with 410 additions and 0 deletions
@@ -0,0 +1,48 @@
import CrushableIngredient.Companion.isCrushable
import CrushableIngredient.Companion.isGrindingTool
import Herb.Companion.isIdentified
import Herb.Companion.isUnidentified
import Ingredient.Companion.isIngredient
import UnfinishedPotion.Companion.isUnfinished
import org.apollo.game.message.impl.ItemOnItemMessage
import org.apollo.game.message.impl.ItemOptionMessage
on { ItemOptionMessage::class }
.where { option == IdentifyHerbAction.IDENTIFY_OPTION && id.isUnidentified() }
.then { player ->
val unidentified = Herb[id]!!
player.startAction(IdentifyHerbAction(player, slot, unidentified))
terminate()
}
on { ItemOnItemMessage::class }
.where { (id.isGrindingTool() && targetId.isCrushable() || id.isCrushable() && targetId.isGrindingTool()) }
.then { player ->
val crushableId = if (id.isCrushable()) id else targetId
val raw = CrushableIngredient[crushableId]!!
player.startAction(CrushIngredientAction(player, raw))
terminate()
}
on { ItemOnItemMessage::class }
.where { id == VIAL_OF_WATER && targetId.isIdentified() || id.isIdentified() && targetId == VIAL_OF_WATER }
.then { player ->
val herbId = if (id.isIdentified()) id else targetId
val unfinished = UnfinishedPotion[herbId]!!
player.startAction(MakeUnfinishedPotionAction(player, unfinished))
terminate()
}
on { ItemOnItemMessage::class }
.where { id.isUnfinished() && targetId.isIngredient() || id.isIngredient() && targetId.isUnfinished() }
.then { player ->
val key = if (id.isUnfinished()) Pair(id, targetId) else Pair(targetId, id)
val finished = FinishedPotion[key]!!
player.startAction(MakeFinishedPotionAction(player, finished))
terminate()
}