HexCasting/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapUnescapedValue.kt

36 lines
1.2 KiB
Kotlin
Raw Normal View History

package at.petrak.hexcasting.api.casting.mishaps
2022-05-11 01:42:10 +02:00
2023-01-22 03:29:09 +01:00
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.pigment.FrozenPigment
2022-05-11 01:42:10 +02:00
import net.minecraft.world.item.DyeColor
/**
* The value was a naked iota without being Considered or Retrospected.
*/
class MishapUnescapedValue(
2022-06-14 02:26:39 +02:00
val perpetrator: Iota
2022-05-11 01:42:10 +02:00
) : Mishap() {
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
2022-05-11 01:42:10 +02:00
dyeColor(DyeColor.GRAY)
2023-01-22 03:29:09 +01:00
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
2022-05-25 22:34:46 +02:00
// TODO
/*
2022-05-11 01:42:10 +02:00
val idx = stack.indexOfLast { it.getType() == DatumType.LIST }
if (idx != -1) {
val list = stack[idx].payload as SpellList
val idxOfIota = list.indexOfFirst { it == perpetrator }
if (idxOfIota != -1) {
stack[idx] = SpellDatum.make(list.modifyAt(idxOfIota) {
SpellList.LPair(SpellDatum.make(Widget.GARBAGE), it.cdr)
})
}
}
2022-05-25 22:34:46 +02:00
*/
2022-05-11 01:42:10 +02:00
}
2023-01-22 03:29:09 +01:00
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context) =
error("unescaped", perpetrator.display())
2022-05-11 01:42:10 +02:00
}