forked from profectus/Profectus
Implemented NaN screen
This commit is contained in:
parent
0836550abe
commit
69b1fff796
8 changed files with 145 additions and 15 deletions
|
@ -4,6 +4,7 @@
|
|||
<Tabs />
|
||||
<TPS v-if="showTPS" />
|
||||
<GameOverScreen />
|
||||
<NaNScreen />
|
||||
<portal-target name="modal-root" multiple />
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -43,6 +43,7 @@ import LayerProvider from './system/LayerProvider';
|
|||
import LayerTab from './system/LayerTab';
|
||||
import Microtab from './system/Microtab';
|
||||
import Modal from './system/Modal';
|
||||
import NaNScreen from './system/NaNScreen';
|
||||
import Nav from './system/Nav';
|
||||
import Options from './system/Options';
|
||||
import Resource from './system/Resource';
|
||||
|
@ -110,6 +111,7 @@ Vue.component(LayerProvider.name, LayerProvider);
|
|||
Vue.component(LayerTab.name, LayerTab);
|
||||
Vue.component(Microtab.name, Microtab);
|
||||
Vue.component(Modal.name, Modal);
|
||||
Vue.component(NaNScreen.name, NaNScreen);
|
||||
Vue.component(Nav.name, Nav);
|
||||
Vue.component(Options.name, Options);
|
||||
Vue.component(Resource.name, Resource);
|
||||
|
|
|
@ -13,15 +13,9 @@
|
|||
<div>Please check the Discord to discuss the game or to check for new content updates!</div>
|
||||
<br>
|
||||
<div>
|
||||
<a :href="discordLink" v-if="discordLink !== 'https://discord.gg/WzejVAx'">
|
||||
<a :href="discordLink">
|
||||
<img src="images/discord.png" class="game-over-modal-discord" />
|
||||
{{ discordLink }}
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="https://discord.gg/WzejVAx" class="game-over-modal-discord-link">
|
||||
<img src="images/discord.png" class="game-over-modal-discord" />
|
||||
The Paper Pilot Community
|
||||
{{ discordName }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -33,7 +27,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import modInfo from '../../data/modInfo';
|
||||
import modInfo from '../../data/modInfo.json';
|
||||
import { formatTime } from '../../util/bignum';
|
||||
import { player } from '../../store/proxies';
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
<div class="link" @click="$emit('openDialog', 'Changelog')">Changelog</div>
|
||||
<br>
|
||||
<div>
|
||||
<a :href="discordLink" v-if="discordLink !== 'https://discord.gg/WzejVAx'">
|
||||
<a :href="discordLink" v-if="discordLink !== 'https://discord.gg/WzejVAx'" class="info-modal-discord-link">
|
||||
<img src="images/discord.png" class="info-modal-discord" />
|
||||
{{ discordLink }}
|
||||
{{ discordName }}
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -55,7 +55,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import modInfo from '../../data/modInfo';
|
||||
import modInfo from '../../data/modInfo.json';
|
||||
import { formatTime } from '../../util/bignum';
|
||||
import { hotkeys } from '../../store/layers';
|
||||
|
||||
|
|
114
src/components/system/NaNScreen.vue
Normal file
114
src/components/system/NaNScreen.vue
Normal file
|
@ -0,0 +1,114 @@
|
|||
<template>
|
||||
<Modal :show="show">
|
||||
<div slot="header" class="nan-modal-header">
|
||||
<h2>NaN value detected!</h2>
|
||||
</div>
|
||||
<div slot="body">
|
||||
<div>Attempted to assign NaN value to "{{ property }}" (previously {{ format(previous) }}). Auto-saving has been {{ autosave ? 'enabled' : 'disabled' }}. Check the console for more details, and consider sharing it with the developers on discord.</div>
|
||||
<br>
|
||||
<div>
|
||||
<a :href="discordLink" class="nan-modal-discord-link">
|
||||
<img src="images/discord.png" class="nan-modal-discord" />
|
||||
{{ discordName }}
|
||||
</a>
|
||||
</div>
|
||||
<br>
|
||||
<Toggle title="Autosave" :value="autosave" @change="setAutosave" />
|
||||
</div>
|
||||
<div slot="footer" class="nan-footer">
|
||||
<button @click="setZero" class="button">Set to 0</button>
|
||||
<button @click="setOne" class="button">Set to 1</button>
|
||||
<button @click="setPrev" class="button" v-if="previous && previous.neq(0) && previous.neq(1)">Set to previous</button>
|
||||
<button @click="ignore" class="button danger">Ignore</button>
|
||||
</div>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import modInfo from '../../data/modInfo.json';
|
||||
import Decimal, { format } from '../../util/bignum';
|
||||
import { player } from '../../store/proxies';
|
||||
|
||||
export default {
|
||||
name: 'NaNScreen',
|
||||
data() {
|
||||
const { discordName, discordLink } = modInfo;
|
||||
return { discordName, discordLink, format };
|
||||
},
|
||||
computed: {
|
||||
show() {
|
||||
return player.hasNaN;
|
||||
},
|
||||
property() {
|
||||
return player.NaNProperty;
|
||||
},
|
||||
autosave() {
|
||||
return player.autosave;
|
||||
},
|
||||
previous() {
|
||||
return player.NaNPrevious;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setZero() {
|
||||
player.NaNReceiver[player.NaNProperty] = new Decimal(0);
|
||||
player.hasNaN = false;
|
||||
},
|
||||
setOne() {
|
||||
player.NaNReceiver[player.NaNProperty] = new Decimal(1);
|
||||
player.hasNaN = false;
|
||||
},
|
||||
setPrev() {
|
||||
player.NaNReceiver[player.NaNProperty] = player.NaNPrevious;
|
||||
player.hasNaN = false;
|
||||
},
|
||||
ignore() {
|
||||
player.hasNaN = false;
|
||||
},
|
||||
setAutosave(autosave) {
|
||||
player.autosave = autosave;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.nan-modal-header {
|
||||
padding: 10px 0;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.nan-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.nan-footer button {
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
.nan-modal-discord-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nan-modal-discord {
|
||||
height: 2em;
|
||||
margin: 0;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.danger {
|
||||
border: solid 2px var(--danger);
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.danger::after {
|
||||
content: "!";
|
||||
color: white;
|
||||
background: var(--danger);
|
||||
padding: 2px;
|
||||
margin-left: 6px;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
|
@ -107,6 +107,10 @@ function update() {
|
|||
if (store.getters.hasWon && !player.keepGoing) {
|
||||
return;
|
||||
}
|
||||
// Stop here if the player had a NaN value
|
||||
if (player.hasNaN) {
|
||||
return;
|
||||
}
|
||||
|
||||
diff = new Decimal(diff).max(0);
|
||||
|
||||
|
|
|
@ -33,7 +33,17 @@ const playerHandler = {
|
|||
|
||||
return target[key];
|
||||
},
|
||||
set(target, property, value) {
|
||||
set(target, property, value, receiver) {
|
||||
if (!player.hasNaN && value instanceof Decimal && (isNaN(value.sign) || isNaN(value.layer) || isNaN(value.mag))) {
|
||||
player.autosave = false;
|
||||
player.hasNaN = true;
|
||||
player.NaNProperty = property;
|
||||
player.NaNReceiver = receiver;
|
||||
player.NaNPrevious = target[property];
|
||||
Vue.set(target, property, value);
|
||||
console.error(`Attempted to set NaN value`, target, property);
|
||||
throw 'Attempted to set NaN value. See above for details';
|
||||
}
|
||||
Vue.set(target, property, value);
|
||||
if (property === 'points') {
|
||||
if (target.best != undefined) {
|
||||
|
|
|
@ -11,7 +11,6 @@ export function getInitialStore() {
|
|||
offlineProd: true,
|
||||
timePlayed: new Decimal(0),
|
||||
keepGoing: false,
|
||||
hasNaN: false,
|
||||
lastTenTicks: [],
|
||||
showTPS: true,
|
||||
msDisplay: "all",
|
||||
|
@ -32,6 +31,12 @@ export function getInitialStore() {
|
|||
...layer.startData?.()
|
||||
};
|
||||
return acc;
|
||||
}, {})
|
||||
}, {}),
|
||||
|
||||
// Values that don't get saved
|
||||
hasNaN: false,
|
||||
NaNProperty: "",
|
||||
NaNReceiver: null,
|
||||
NaNPrevious: null
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue