Add option to ignore date

This commit is contained in:
thepaperpilot 2022-12-31 15:18:02 -06:00
parent 804dac69f5
commit bf318bc823
4 changed files with 37 additions and 9 deletions

View file

@ -13,6 +13,8 @@
</template>
<template v-slot:body>
<div v-if="isTab('behaviour')">
<Select :title="ignoreDateTitle" :options="ignoreDateOptions" v-model="ignoreDate" />
<Toggle v-if="projInfo.enablePausing" :title="isPausedTitle" v-model="isPaused" />
<div v-if="canAutoSave">
<Toggle :title="autosaveTitle" v-model="autosave" />
<FeedbackButton v-if="!autosave" class="button save-button" @click="save()">
@ -22,7 +24,6 @@
<div style="text-align: center" v-else>
Auto-saving is disabled while between days
</div>
<Toggle v-if="projInfo.enablePausing" :title="isPausedTitle" v-model="isPaused" />
</div>
<div v-if="isTab('appearance')">
<Select :title="themeTitle" :options="themes" v-model="theme" />
@ -41,7 +42,7 @@ import projInfo from "data/projInfo.json";
import rawThemes from "data/themes";
import { jsx } from "features/feature";
import Tooltip from "features/tooltips/Tooltip.vue";
import player from "game/player";
import player, { IgnoreDateSettings } from "game/player";
import settings, { settingFields } from "game/settings";
import { camelToTitle } from "util/common";
import { save } from "util/save";
@ -80,13 +81,19 @@ const themes = Object.keys(rawThemes).map(theme => ({
value: theme
}));
const ignoreDateOptions = [
{ label: "Don't Ignore", value: IgnoreDateSettings.AsIntended },
{ label: "Ignore Month", value: IgnoreDateSettings.IgnoreMonth },
{ label: "Ignore Month and Day", value: IgnoreDateSettings.IgnoreDay }
];
const settingFieldsComponent = computed(() => {
return coerceComponent(jsx(() => (<>{settingFields.map(render)}</>)));
});
const { showTPS, theme, usingLog, alignUnits } = toRefs(settings);
const { autosave, autoPause } = toRefs(player);
const { autosave, autoPause, ignoreDate } = toRefs(player);
const isPaused = computed({
get() {
@ -107,6 +114,12 @@ const autosaveTitle = jsx(() => (
<desc>Automatically save the game every second or when the game is closed.</desc>
</span>
));
const ignoreDateTitle = jsx(() => (
<span class="option-title">
Ignore Date<Tooltip display="Save-specific">*</Tooltip>
<desc>Allow playing the game not as an advent calendar</desc>
</span>
));
const isPausedTitle = jsx(() => (
<span class="option-title">
Pause game<Tooltip display="Save-specific">*</Tooltip>

View file

@ -50,6 +50,7 @@ import Notif from "components/Notif.vue";
import { Visibility } from "features/feature";
import Tooltip from "features/tooltips/Tooltip.vue";
import { layers } from "game/layers";
import player, { IgnoreDateSettings } from "game/player";
import Decimal from "util/bignum";
import { formatTime } from "util/break_eternity";
import { Direction } from "util/common";
@ -80,8 +81,8 @@ const canOpen = computed(
() =>
props.layer != null &&
Decimal.gte(main.day.value, props.day) &&
new Date().getMonth() === 11 &&
new Date().getDate() >= props.day
(new Date().getMonth() === 10 || player.ignoreDate !== IgnoreDateSettings.AsIntended) &&
(new Date().getDate() >= props.day || player.ignoreDate === IgnoreDateSettings.IgnoreDay)
);
const isMastering = main.isMastery;

View file

@ -10,7 +10,7 @@ import {
import { createParticles } from "features/particles/particles";
import { BaseLayer, createLayer, GenericLayer, layers } from "game/layers";
import { isPersistent, Persistent, persistent } from "game/persistence";
import type { PlayerData } from "game/player";
import { IgnoreDateSettings, PlayerData } from "game/player";
import player from "game/player";
import { format, formatTime } from "util/bignum";
import { Computable, convertComputable, ProcessedComputable } from "util/computed";
@ -86,9 +86,15 @@ export const main = createLayer("main", function (this: BaseLayer) {
const day = persistent<number>(1);
const hasWon = persistent<boolean>(false);
const timeUntilNewDay = computed(
() => (+new Date(new Date().getFullYear(), 11, day.value) - player.time) / 1000
);
const timeUntilNewDay = computed(() => {
if (player.ignoreDate === IgnoreDateSettings.IgnoreDay) {
return 0;
} else {
const month =
player.ignoreDate === IgnoreDateSettings.IgnoreMonth ? new Date().getMonth() : 11;
return (+new Date(new Date().getFullYear(), month, day.value) - player.time) / 1000;
}
});
const showLoreModal = ref<boolean>(false);
const loreScene = ref<number>(-1);

View file

@ -6,6 +6,12 @@ import { reactive, unref } from "vue";
import type { Ref } from "vue";
import transientState from "./state";
export enum IgnoreDateSettings {
AsIntended,
IgnoreMonth,
IgnoreDay
}
/** The player save data object. */
export interface PlayerData {
/** The ID of this save. */
@ -37,6 +43,7 @@ export interface PlayerData {
/** Should the game be paused when the player complete a day? */
autoPause: boolean;
ignoreDate: IgnoreDateSettings;
}
/** The proxied player that is used to track NaN values. */
@ -69,6 +76,7 @@ const state = reactive<PlayerData>({
modID: "",
modVersion: "",
layers: {},
ignoreDate: IgnoreDateSettings.AsIntended,
autoPause: true
});