implemented "Undo in parenthised" mentioned in #441. The *way* I did this is kinda hacky, particularly in GuiSpellcasting.

This commit is contained in:
Talia-12 2023-06-01 22:23:06 +10:00
parent 0daecb38e4
commit a10b096402
6 changed files with 20 additions and 8 deletions

View file

@ -6,6 +6,7 @@ enum class ResolvedPatternType(val color: Int, val fadeColor: Int, val success:
UNRESOLVED(0x7f7f7f, 0xcccccc, false),
EVALUATED(0x7385de, 0xfecbe6, true),
ESCAPED(0xddcc73, 0xfffae5, true),
UNDONE(0xb26b6b, 0xcca88e, true), // TODO: Pick better colours
ERRORED(0xde6262, 0xffc7a0, false),
INVALID(0xb26b6b, 0xcca88e, false);

View file

@ -7,4 +7,6 @@ public final class SpecialPatterns {
public static final HexPattern INTROSPECTION = HexPattern.fromAngles("qqq", HexDir.WEST);
public static final HexPattern RETROSPECTION = HexPattern.fromAngles("eee", HexDir.EAST);
public static final HexPattern CONSIDERATION = HexPattern.fromAngles("qqqaw", HexDir.WEST);
public static final HexPattern EVANITION = HexPattern.fromAngles("eeedw", HexDir.EAST);
}

View file

@ -97,8 +97,7 @@ public class StaffCastEnv extends PlayerBasedCastEnv {
ExecutionClientView clientInfo = vm.queueExecuteAndWrapIota(new PatternIota(msg.pattern()), sender.getLevel());
// if (clientInfo.isStackClear()) {
if (clientInfo.isStackClear() && clientInfo.getRavenmind() == null) {
if (clientInfo.isStackClear()) {
IXplatAbstractions.INSTANCE.setStaffcastImage(sender, null);
IXplatAbstractions.INSTANCE.setPatterns(sender, List.of());
} else {

View file

@ -65,7 +65,7 @@ class CastingVM(var image: CastingImage, val env: CastingEnvironment) {
val (stackDescs, ravenmind) = generateDescs()
val isStackClear = image.stack.isEmpty() && image.parenCount == 0 && !image.escapeNext
val isStackClear = image.stack.isEmpty() && image.parenCount == 0 && !image.escapeNext && ravenmind == null
return ExecutionClientView(isStackClear, lastResolutionType, stackDescs, ravenmind)
}
@ -170,6 +170,12 @@ class CastingVM(var image: CastingImage, val env: CastingEnvironment) {
) to ResolvedPatternType.EVALUATED
}
SpecialPatterns.EVANITION.anglesSignature() -> {
val newParens = this.image.parenthesized.toMutableList()
val last = newParens.removeLastOrNull()
this.image.copy(parenthesized = newParens) to if (last == null) ResolvedPatternType.ERRORED else ResolvedPatternType.UNDONE
}
SpecialPatterns.INTROSPECTION.anglesSignature() -> {
// we have escaped the parens onto the stack; we just also record our count.
val newParens = this.image.parenthesized.toMutableList()

View file

@ -62,14 +62,18 @@ class GuiSpellcasting constructor(
}
fun recvServerUpdate(info: ExecutionClientView, index: Int) {
if (info.isStackClear && info.ravenmind == null) {
if (info.isStackClear) {
this.minecraft?.setScreen(null)
return
}
this.patterns.getOrNull(index)?.let {
it.type = info.resolutionType
}
// TODO this is the kinda hacky bit
if (info.resolutionType == ResolvedPatternType.UNDONE) {
this.patterns.getOrNull(index - 1)?.let { it.type = ResolvedPatternType.UNDONE }
this.patterns.getOrNull(index)?.let { it.type = ResolvedPatternType.EVALUATED }
} else this.patterns.getOrNull(index)?.let {
it.type = info.resolutionType
}
this.cachedStack = info.stackDescs
this.cachedRavenmind = info.ravenmind

View file

@ -52,7 +52,7 @@ public record MsgNewSpellPatternS2C(ExecutionClientView info, int index) impleme
public static void handle(MsgNewSpellPatternS2C self) {
Minecraft.getInstance().execute(() -> {
var mc = Minecraft.getInstance();
if (self.info().isStackClear() && self.info().getRavenmind() == null) {
if (self.info().isStackClear()) {
// don't pay attention to the screen, so it also stops when we die
mc.getSoundManager().stop(HexSounds.CASTING_AMBIANCE.getLocation(), null);
}