Skip to content

Commit

Permalink
do all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
kineticneticat committed Jul 12, 2024
1 parent a2db04c commit fbd92e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.GarbageIota
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.pigment.FrozenPigment
import at.petrak.hexcasting.api.utils.asTextComponent
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.ComponentContents
import net.minecraft.network.chat.MutableComponent
import net.minecraft.network.chat.ComponentUtils
import net.minecraft.world.item.DyeColor

/**
* The value failed some kind of predicate.
*/
class MishapInvalidOperatorArgs(
private val perpetrators: List<Iota>
) : Mishap() {
class MishapInvalidOperatorArgs( val perpetrators: List<Iota> ) : Mishap() {
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
dyeColor(DyeColor.GRAY)

Expand All @@ -27,28 +25,18 @@ class MishapInvalidOperatorArgs(
override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component {
return if (perpetrators.size == 1) {
error(
"invalid_operator_args.single",
"invalid_operator_args.one",
0,
perpetrators[0].display()
)
} else {
error(
"invalid_operator_args.plural",
"invalid_operator_args.many",
perpetrators.size,
0,
perpetrators.lastIndex,
collateIotas(perpetrators)
ComponentUtils.formatList(perpetrators.map {it.display()}, ", ".asTextComponent)
)
}
}
private fun collateIotas(iotas: List<Iota>): MutableComponent {
val out = MutableComponent.create(ComponentContents.EMPTY)
for (i in iotas.indices) {
out.append(iotas[i].display())
if (i < iotas.size-1) {
out.append(", ")
}
}
return out
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,8 @@
},

invalid_operator_args: {
single: "Got an unexpected iota at index %d of the stack: %s",
plural: "Got %d unexpected iotas at indices %d-%d of the stack: %s",
one: "got an unexpected iota at index %d of the stack: %s",
many: "got %d unexpected iotas at indices %d-%d of the stack: %s",
},

no_akashic_record: "No Akashic Record at %s",
Expand Down

0 comments on commit fbd92e2

Please sign in to comment.