moar bugfix

This commit is contained in:
Alwinfy 2022-05-08 19:24:36 -04:00
parent 3311c9a16f
commit 4d0f83a3a2
No known key found for this signature in database
GPG key ID: 2CCB99445F0C949E
3 changed files with 6 additions and 4 deletions

View file

@ -48,7 +48,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()