moar bugfix

This commit is contained in:
Alwinfy 2022-05-08 19:24:36 -04:00 committed by yrsegal@gmail.com
parent 156e3263f3
commit 0b13dd55b1
3 changed files with 6 additions and 4 deletions

View file

@ -32,7 +32,7 @@ sealed class SpellList: Iterable<SpellDatum<*>> {
return this
}
while (idx > 0) {
if (ptr.hasNext()) {
if (!ptr.hasNext()) {
return this
}
idx--

View file

@ -4,13 +4,14 @@ import at.petrak.hexcasting.api.spell.OperationResult
import at.petrak.hexcasting.api.spell.Operator
import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked
import at.petrak.hexcasting.api.spell.SpellDatum
import at.petrak.hexcasting.api.spell.SpellList
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.casting.CastingHarness
import at.petrak.hexcasting.api.spell.casting.OperatorSideEffect
object OpEval : Operator {
override fun operate(stack: MutableList<SpellDatum<*>>, local: SpellDatum<*>, ctx: CastingContext): OperationResult {
val instrs: List<SpellDatum<*>> = stack.getChecked(stack.lastIndex)
val instrs: SpellList = stack.getChecked(stack.lastIndex)
stack.removeLastOrNull()
ctx.incDepth()

View file

@ -4,6 +4,7 @@ import at.petrak.hexcasting.api.spell.OperationResult
import at.petrak.hexcasting.api.spell.Operator
import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked
import at.petrak.hexcasting.api.spell.SpellDatum
import at.petrak.hexcasting.api.spell.SpellList
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.casting.CastingHarness
import at.petrak.hexcasting.api.spell.casting.OperatorSideEffect
@ -14,8 +15,8 @@ object OpForEach : Operator {
if (stack.size < 2)
throw MishapNotEnoughArgs(2, stack.size)
val instrs: List<SpellDatum<*>> = stack.getChecked(stack.lastIndex - 1)
val datums: List<SpellDatum<*>> = stack.getChecked(stack.lastIndex)
val instrs: SpellList = stack.getChecked(stack.lastIndex - 1)
val datums: SpellList = stack.getChecked(stack.lastIndex)
stack.removeLastOrNull()
stack.removeLastOrNull()