26 lines
1.1 KiB
Kotlin
26 lines
1.1 KiB
Kotlin
package at.petrak.hexcasting.common.casting.operators.local
|
|
|
|
import at.petrak.hexcasting.api.HexAPI
|
|
import at.petrak.hexcasting.api.casting.castables.Action
|
|
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
|
import at.petrak.hexcasting.api.casting.eval.OperationResult
|
|
import at.petrak.hexcasting.api.casting.eval.vm.CastingImage
|
|
import at.petrak.hexcasting.api.casting.eval.vm.SpellContinuation
|
|
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
|
|
import at.petrak.hexcasting.common.lib.hex.HexEvalSounds
|
|
|
|
object OpPushLocal : Action {
|
|
override fun operate(env: CastingEnvironment, image: CastingImage, continuation: SpellContinuation): OperationResult {
|
|
val stack = image.stack.toMutableList()
|
|
|
|
if (stack.isEmpty())
|
|
throw MishapNotEnoughArgs(1, 0)
|
|
|
|
val newLocal = stack.removeLast()
|
|
image.userData.put(HexAPI.RAVENMIND_USERDATA, newLocal.serialize())
|
|
|
|
val image2 = image.withUsedOp().copy(stack = stack)
|
|
return OperationResult(image2, listOf(), continuation, HexEvalSounds.NORMAL_EXECUTE)
|
|
}
|
|
}
|