From 47c429bc7b72c65d0c192c778b447fb7a09e17b1 Mon Sep 17 00:00:00 2001 From: gamma-delta <29877714+gamma-delta@users.noreply.github.com> Date: Sun, 13 Nov 2022 23:29:52 -0600 Subject: [PATCH] close #288 --- .../api/spell/mishaps/MishapOthersName.kt | 20 +++++++++++++++---- .../casting/operators/OpTheCoolerWrite.kt | 8 +++++--- .../assets/hexcasting/lang/en_us.json | 4 +++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapOthersName.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapOthersName.kt index 81f258a8..fa2e16b4 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapOthersName.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapOthersName.kt @@ -10,20 +10,32 @@ import net.minecraft.world.effect.MobEffects import net.minecraft.world.entity.player.Player import net.minecraft.world.item.DyeColor -class MishapOthersName(val other: Player) : Mishap() { +/** + * Also throwable for your *own* name, for cases like Chronicler's Gambit + */ +class MishapOthersName(val confidant: Player) : Mishap() { override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.BLACK) override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - ctx.caster.addEffect(MobEffectInstance(MobEffects.BLINDNESS, 20 * 60)) + val seconds = if (this.confidant == ctx.caster) 5 else 60; + ctx.caster.addEffect(MobEffectInstance(MobEffects.BLINDNESS, seconds * 20)) } override fun errorMessage(ctx: CastingContext, errorCtx: Context) = - error("others_name", other.name) + if (this.confidant == ctx.caster) + error("others_name.self") + else + error("others_name", confidant.name) companion object { + /** + * Return any true names found in this iota. + * + * If `caster` is non-null, it will ignore that when checking. + */ @JvmStatic - fun getTrueNameFromDatum(datum: Iota, caster: Player): Player? { + fun getTrueNameFromDatum(datum: Iota, caster: Player?): Player? { val poolToSearch = ArrayDeque() poolToSearch.addLast(datum) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerWrite.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerWrite.kt index 3f153f7b..3ded5aba 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerWrite.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerWrite.kt @@ -17,15 +17,17 @@ object OpTheCoolerWrite : SpellAction { args: List, ctx: CastingContext ): Triple> { - val datum = args[0] - val target = args.getEntity(1, argc) + val target = args.getEntity(0, argc) + val datum = args[1] ctx.assertEntityInRange(target) val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(target) ?: throw MishapBadEntity.of(target, "iota.write") - val trueName = MishapOthersName.getTrueNameFromDatum(datum, ctx.caster) + // We pass null here so that even the own caster won't be allowed into a focus. + // Otherwise, you could sentinel scout to people and remotely write their names into things using a cleric circle. + val trueName = MishapOthersName.getTrueNameFromDatum(datum, null) if (trueName != null) throw MishapOthersName(trueName) diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.json b/Common/src/main/resources/assets/hexcasting/lang/en_us.json index 16e2c298..0bdf1d9b 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.json +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.json @@ -270,6 +270,7 @@ "hexcasting.spell.book.hexcasting:const/vec/x": "Vector Rfln. +X/-X", "hexcasting.spell.book.hexcasting:const/vec/y": "Vector Rfln. +Y/-Y", "hexcasting.spell.book.hexcasting:const/vec/z": "Vector Rfln. +Z/-Z", + "hexcasting.spell.book.hexcasting:write/entity": "Chronicler's Prfn.", "hexcasting.spell.book.hexcasting:number": "Numerical Reflection", "hexcasting.spell.book.hexcasting:mask": "Bookkeeper's Gambit", @@ -519,6 +520,7 @@ "hexcasting.mishap.already_brainswept": "The villager has already been used", "hexcasting.mishap.no_spell_circle": "%s requires a spell circle", "hexcasting.mishap.others_name": "Tried to invade the privacy of %s's soul", + "hexcasting.mishap.others_name.self": "Tried to divulge my Name too recklessly", "hexcasting.mishap.divide_by_zero.divide": "Attempted to divide %s by %s", "hexcasting.mishap.divide_by_zero.project": "Attempted to project %s onto %s", "hexcasting.mishap.divide_by_zero.exponent": "Attempted to raise %s to the %s", @@ -975,7 +977,7 @@ "hexcasting.page.readwrite.read": "Copy the iota stored in the item in my other hand and add it to the stack.", "hexcasting.page.readwrite.write": "Remove the top iota from the stack, and save it into the item in my other hand.", "hexcasting.page.readwrite.read/entity": "Like $(l:patterns/readwrite#hexcasting:read)$(action)Scribe's Reflection/$, but the iota is read out of an entity instead of my other hand.", - "hexcasting.page.readwrite.write/entity": "Like $(l:patterns/readwrite#hexcasting:read)$(action)Scribe's Reflection/$, but the iota is written to an entity instead of my other hand.", + "hexcasting.page.readwrite.write/entity": "Like $(l:patterns/readwrite#hexcasting:read)$(action)Scribe's Gambit/$, but the iota is written to an entity instead of my other hand.$(br2)Interestingly enough, it looks like I cannot write my own Name using this spell. I get a sense that I might be endangered if I could.", "hexcasting.page.readwrite.readable": "If the item in my other hand holds an iota I can read, returns True. Otherwise, returns False.", "hexcasting.page.readwrite.readable/entity": "Like $(l:patterns/readwrite#hexcasting:readable)$(action)Auditor's Reflection/$, but the readability of an entity is checked instead of my other hand.", "hexcasting.page.readwrite.writable": "If I could save an iota into the item in my other hand, returns True. Otherwise, returns False.",