Add exit challenge confirmation

This commit is contained in:
SpectralFlame 2023-03-16 07:00:33 -05:00 committed by cyip92
parent 55a6135f5f
commit 77a7f9fe71
7 changed files with 112 additions and 70 deletions

View File

@ -2347,18 +2347,6 @@ br {
/* #endregion c-game-header__antimatter */
.l-game-header__challenge-text {
display: flex;
height: 2rem;
top: 50%;
justify-content: center;
align-items: center;
font-size: 1.2rem;
font-weight: bold;
color: var(--color-text);
margin: 0.5rem;
}
.l-game-header__buttons-line {
position: relative;
}

View File

@ -1,49 +0,0 @@
<script>
import ModalWrapperChoice from "@/components/modals/ModalWrapperChoice";
export default {
name: "ExitCelestialModal",
components: {
ModalWrapperChoice
},
data() {
return {
isRestarting: false
};
},
methods: {
update() {
this.isRestarting = player.options.retryCelestial;
},
handleYesClick() {
beginProcessReality(getRealityProps(true));
EventHub.ui.offAll(this);
}
},
};
</script>
<template>
<ModalWrapperChoice
option="resetCelestial"
@confirm="handleYesClick"
>
<template #header>
You are about to {{ isRestarting ? "restart" : "exit" }} a Celestial Reality
</template>
<div class="c-modal-message__text">
<span v-if="isRestarting">
Restarting a Celestial's Reality will reset your Reality and
immediately enter you into this Celestial again, without the benefits of completing the Celestial.
</span>
<span v-else>
Exiting a Celestial's Reality early will reset your Reality and
exit the Celestial without the benefits of completing the Celestial.
</span>
</div>
<template #confirm-text>
{{ isRestarting ? "Restart" : "Exit" }}
</template>
</ModalWrapperChoice>
</template>

View File

@ -0,0 +1,68 @@
<script>
import ModalWrapperChoice from "@/components/modals/ModalWrapperChoice";
export default {
name: "ExitChallengeModal",
components: {
ModalWrapperChoice
},
props: {
challengeName: {
type: String,
required: true,
},
normalName: {
type: String,
required: true,
},
hasHigherLayers: {
type: Boolean,
required: true,
},
exitFn: {
type: Function,
required: true,
}
},
computed: {
isCelestial() {
return this.challengeName.match("Reality");
},
isRestarting() {
return this.isCelestial ? player.options.retryCelestial : player.options.retryChallenge;
}
},
methods: {
handleYesClick() {
this.exitFn();
EventHub.ui.offAll(this);
}
},
};
</script>
<template>
<ModalWrapperChoice
option="exitChallenge"
@confirm="handleYesClick"
>
<template #header>
You are about to {{ isRestarting ? "restart" : "exit" }} {{ challengeName }}
</template>
<div class="c-modal-message__text">
<span v-if="isRestarting">
You will immediately re-enter {{ challengeName }} again after confirming this modal.
</span>
<span v-else>
This will place you back into a regular {{ normalName }} without any restrictions.
</span>
<span v-if="hasHigherLayers">
However, other effects coming from higher-layer restrictions will still continue to apply.
</span>
</div>
<template #confirm-text>
{{ isRestarting ? "Restart" : "Exit" }}
</template>
</ModalWrapperChoice>
</template>

View File

@ -112,17 +112,35 @@ export default {
this.resetCelestial = player.options.retryCelestial;
this.inPelle = Pelle.isDoomed;
},
// Process exit requests from the inside out; exit any Challenges first, then dilation, then Celestial Reality
// Process exit requests from the inside out; Challenges first, then dilation, then Celestial Reality. If the
// relevant option is toggled, we pass a bunch of information over to a modal - otherwise we immediately exit
exitButtonClicked() {
const current = Player.anyChallenge;
let names, clickFn;
if (Player.isInAnyChallenge) {
current.exit();
// Regex replacement is used to remove the "(X/Y)" which appears after ECs. The ternary statement is there
// because this path gets called for NCs, ICs, and ECs
const toExit = this.activeChallengeNames[this.activeChallengeNames.length - 1].replace(/\W+\(.*\)/u, "");
names = { chall: toExit, normal: toExit.match("Eternity") ? "Eternity" : "Infinity" };
clickFn = () => Player.anyChallenge.exit();
} else if (player.dilation.active) {
startDilatedEternityRequest();
} else if (player.options.confirmations.resetCelestial) {
Modal.exitCelestialReality.show();
names = { chall: "Time Dilation", normal: "Eternity" };
clickFn = () => startDilatedEternityRequest();
} else {
beginProcessReality(getRealityProps(true));
names = { chall: this.activeChallengeNames[0], normal: "Reality" };
clickFn = () => beginProcessReality(getRealityProps(true));
}
if (player.options.confirmations.exitChallenge) {
Modal.exitChallenge.show(
{
challengeName: names.chall,
normalName: names.normal,
hasHigherLayers: this.inPelle || this.activeChallengeNames.length > 1,
exitFn: clickFn
}
);
} else {
clickFn();
}
},
// Bring the player to the tab related to the innermost challenge
@ -186,6 +204,18 @@ export default {
</template>
<style scoped>
.l-game-header__challenge-text {
display: flex;
height: 2rem;
top: 50%;
justify-content: center;
align-items: center;
font-size: 1.2rem;
font-weight: bold;
color: var(--color-text);
margin: 0.5rem;
}
.l-challenge-display {
padding: 0.5rem;
cursor: default;

View File

@ -16,7 +16,7 @@ import DimensionBoostModal from "@/components/modals/prestige/DimensionBoostModa
import EnterCelestialsModal from "@/components/modals/prestige/EnterCelestialsModal";
import EnterDilationModal from "@/components/modals/prestige/EnterDilationModal";
import EternityModal from "@/components/modals/prestige/EternityModal";
import ExitCelestialModal from "@/components/modals/prestige/ExitCelestialModal";
import ExitChallengeModal from "@/components/modals/prestige/ExitChallengeModal";
import ExitDilationModal from "@/components/modals/prestige/ExitDilationModal";
import HardResetModal from "@/components/modals/prestige/HardResetModal";
import ModifySeedModal from "@/components/modals/ModifySeedModal";
@ -198,13 +198,13 @@ Modal.dimensionBoost = new Modal(DimensionBoostModal, 1, GAME_EVENT.DIMBOOST_AFT
Modal.antimatterGalaxy = new Modal(AntimatterGalaxyModal, 1, GAME_EVENT.GALAXY_RESET_AFTER);
Modal.bigCrunch = new Modal(BigCrunchModal, 1, GAME_EVENT.BIG_CRUNCH_AFTER);
Modal.exitChallenge = new Modal(ExitChallengeModal, 1, GAME_EVENT.REALITY_RESET_AFTER);
Modal.replicantiGalaxy = new Modal(ReplicantiGalaxyModal, 1, GAME_EVENT.ETERNITY_RESET_AFTER);
Modal.eternity = new Modal(EternityModal, 1, GAME_EVENT.ETERNITY_RESET_AFTER);
Modal.enterDilation = new Modal(EnterDilationModal, 1, GAME_EVENT.REALITY_RESET_AFTER);
Modal.exitDilation = new Modal(ExitDilationModal, 1, GAME_EVENT.REALITY_RESET_AFTER);
Modal.reality = new Modal(RealityModal, 1, GAME_EVENT.REALITY_RESET_AFTER);
Modal.resetReality = new Modal(ResetRealityModal, 1, GAME_EVENT.REALITY_RESET_AFTER);
Modal.exitCelestialReality = new Modal(ExitCelestialModal, 1, GAME_EVENT.REALITY_RESET_AFTER);
Modal.celestials = new Modal(EnterCelestialsModal, 1);
Modal.hardReset = new Modal(HardResetModal, 1);
Modal.enterSpeedrun = new Modal(SpeedrunModeModal);

View File

@ -819,6 +819,7 @@ window.player = {
armageddon: true,
sacrifice: true,
challenges: true,
exitChallenge: true,
eternity: true,
dilation: true,
resetReality: true,

View File

@ -21,6 +21,10 @@ GameDatabase.confirmationTypes = [
name: "Challenges",
option: "challenges",
isUnlocked: () => PlayerProgress.infinityUnlocked(),
}, {
name: "Exit Challenges",
option: "exitChallenge",
isUnlocked: () => PlayerProgress.infinityUnlocked(),
}, {
name: "Replicanti Galaxy",
option: "replicantiGalaxy",