Implemented lore and locked doors

This commit is contained in:
thepaperpilot 2022-11-30 09:03:49 -06:00
parent e43d0ff0d7
commit 37622b65c2
2 changed files with 67 additions and 14 deletions

View file

@ -14,10 +14,11 @@
v-else v-else
class="day feature dontMerge" class="day feature dontMerge"
:class="{ can: canOpen, locked: !canOpen, canOpen }" :class="{ can: canOpen, locked: !canOpen, canOpen }"
@click="emit('unlockLayer')" @click="tryUnlock"
> >
<div class="doors"></div> <div class="doors"></div>
<div class="date">Dec<br />{{ day }}</div> <div class="date">Dec<br />{{ day }}</div>
<div v-if="!canOpen" class="material-icons lock">lock</div>
<Notif v-if="canOpen" /> <Notif v-if="canOpen" />
</div> </div>
</template> </template>
@ -28,13 +29,14 @@ import { unref, toRef, computed } from "vue";
import type { Ref } from "vue"; import type { Ref } from "vue";
import Notif from "components/Notif.vue"; import Notif from "components/Notif.vue";
import { computeComponent } from "util/vue"; import { computeComponent } from "util/vue";
import { ProcessedComputable } from "util/computed";
const props = defineProps<{ const props = defineProps<{
day: number; day: number;
symbol: CoercableComponent; symbol: CoercableComponent;
opened: Ref<boolean>; opened: Ref<boolean>;
tooltipText: CoercableComponent; unlocked: ProcessedComputable<boolean>;
shouldNotify: Ref<boolean>; shouldNotify: ProcessedComputable<boolean>;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@ -46,8 +48,14 @@ const emit = defineEmits<{
const symbolComp = computeComponent(toRef(props, "symbol")); const symbolComp = computeComponent(toRef(props, "symbol"));
const canOpen = computed( const canOpen = computed(
() => true /*new Date().getMonth() === 12 && new Date().getDate() >= props.day*/ () => unref(props.unlocked) && new Date().getMonth() === 12 && new Date().getDate() >= props.day
); );
function tryUnlock() {
if (canOpen.value) {
emit("unlockLayer");
}
}
</script> </script>
<style scoped> <style scoped>
@ -118,6 +126,9 @@ const canOpen = computed(
height: 100%; height: 100%;
top: 0; top: 0;
left: 0; left: 0;
}
.day.opened .doors {
cursor: pointer; cursor: pointer;
} }
@ -148,6 +159,7 @@ const canOpen = computed(
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
z-index: 2; z-index: 2;
font-size: x-large; font-size: x-large;
pointer-events: none;
user-select: none; user-select: none;
backface-visibility: hidden; backface-visibility: hidden;
width: 100%; width: 100%;
@ -177,4 +189,13 @@ const canOpen = computed(
.lore:hover { .lore:hover {
box-shadow: 0 0 10px var(--points); box-shadow: 0 0 10px var(--points);
} }
.lock {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0.2;
font-size: 500%;
}
</style> </style>

View file

@ -2,62 +2,76 @@ import "@fontsource/material-icons";
import Spacer from "components/layout/Spacer.vue"; import Spacer from "components/layout/Spacer.vue";
import Day from "./Day.vue"; import Day from "./Day.vue";
import { CoercableComponent, Component, GatherProps, jsx } from "features/feature"; import { CoercableComponent, Component, GatherProps, jsx } from "features/feature";
import type { BaseLayer, GenericLayer } from "game/layers"; import { BaseLayer, GenericLayer, layers } from "game/layers";
import { createLayer } from "game/layers"; import { createLayer } from "game/layers";
import { persistent } from "game/persistence"; import { persistent } from "game/persistence";
import type { PlayerData } from "game/player"; import type { PlayerData } from "game/player";
import player from "game/player"; import player from "game/player";
import { format, formatTime } from "util/bignum"; import { format, formatTime } from "util/bignum";
import { renderRow, VueFeature } from "util/vue"; import { render, renderRow, VueFeature } from "util/vue";
import { computed, ref } from "vue"; import { computed, ref } from "vue";
import type { Ref } from "vue"; import type { Ref } from "vue";
import prestige from "./layers/prestige"; import prestige from "./layers/prestige";
import { createLazyProxy } from "util/proxies"; import { createLazyProxy } from "util/proxies";
import { Computable, convertComputable, ProcessedComputable } from "util/computed";
import Modal from "components/Modal.vue";
export interface Day extends VueFeature { export interface Day extends VueFeature {
day: number; day: number;
layer: string | null; layer: string | null;
symbol: CoercableComponent; symbol: CoercableComponent;
story: string; story: string;
tooltipText: CoercableComponent;
opened: Ref<boolean>; opened: Ref<boolean>;
shouldNotify: Ref<boolean>; unlocked: ProcessedComputable<boolean>;
shouldNotify: ProcessedComputable<boolean>;
} }
export const main = createLayer("main", function (this: BaseLayer) { export const main = createLayer("main", function (this: BaseLayer) {
const day = persistent<number>(1); const day = persistent<number>(1);
const openLore = ref<number>(-1);
function createDay( function createDay(
optionsFunc: () => { optionsFunc: () => {
day: number; day: number;
unlocked: Computable<boolean>;
shouldNotify: Computable<boolean>;
layer: string | null; layer: string | null;
symbol: CoercableComponent; symbol: CoercableComponent;
story: string; story: string;
} }
): Day { ): Day {
const opened = persistent<boolean>(false); const opened = persistent<boolean>(false);
return createLazyProxy(() => { return createLazyProxy(() => {
const day = optionsFunc(); const day = optionsFunc();
const unlocked = convertComputable(day.unlocked);
const shouldNotify = convertComputable(day.shouldNotify);
return { return {
...day, ...day,
opened, opened,
tooltipText: day.layer ?? day.symbol, unlocked,
shouldNotify: ref(false), shouldNotify,
[Component]: Day, [Component]: Day,
[GatherProps]: function (this: Day) { [GatherProps]: function (this: Day) {
const { day, layer, symbol, opened, tooltipText, shouldNotify } = this; const { day, layer, symbol, opened, unlocked, shouldNotify } = this;
return { return {
day, day,
symbol, symbol,
opened, opened,
tooltipText, unlocked,
shouldNotify, shouldNotify,
onOpenLore() {
openLore.value = day;
},
onOpenLayer() { onOpenLayer() {
player.tabs.splice(1, 1, layer ?? "prestige"); player.tabs.splice(1, 1, layer ?? "p");
}, },
onUnlockLayer() { onUnlockLayer() {
opened.value = true; opened.value = true;
openLore.value = day;
} }
}; };
} }
@ -68,24 +82,41 @@ export const main = createLayer("main", function (this: BaseLayer) {
const days = [ const days = [
createDay(() => ({ createDay(() => ({
day: 1, day: 1,
unlocked: true,
shouldNotify: false,
layer: null, layer: null,
symbol: "🎄", symbol: "🎄",
story: "Oh no! Santa forgot about Christmas and it's only 25 days away! He's asked for your help due to your history getting large quantities of things in short amounts of time. Unfortunately you're really starting from scratch here - let's start with getting wood, which you'll need for everything from building workshops to wrapping paper to many of the toys themselves" story: "Oh no! Santa forgot about Christmas and it's only 25 days away! He's asked for your help due to your history getting large quantities of things in short amounts of time. Unfortunately you're really starting from scratch here - let's start with getting wood, which you'll need for everything from building workshops to wrapping paper to many of the toys themselves!"
})), })),
createDay(() => ({ createDay(() => ({
day: 2, day: 2,
unlocked: false,
shouldNotify: false,
layer: null, layer: null,
symbol: "<span class='material-icons'>cabin</span>", symbol: "<span class='material-icons'>cabin</span>",
story: "Santa looked over your tree farm and was impressed with how much you could accomplish in just one day. Today's goal is to get a workshop built up for the elves to work in - and apparently, they need quite a lot of space to work!" story: "Santa looked over your tree farm and was impressed with how much you could accomplish in just one day. Today's goal is to get a workshop built up for the elves to work in - and apparently, they need quite a lot of space to work!"
})), })),
createDay(() => ({ createDay(() => ({
day: 3, day: 3,
unlocked: false,
shouldNotify: false,
layer: null, layer: null,
symbol: "🧝", symbol: "🧝",
story: "With this unbelievably large workshop complete, it's time to get the elves to work! But it appears they've forgotten how to make toys over the last 11 months - guess it's time to setup training sessions!" story: "With this unbelievably large workshop complete, it's time to get the elves to work! But it appears they've forgotten how to make toys over the last 11 months - guess it's time to setup training sessions!"
})) }))
]; ];
const loreModal = jsx(() => (
<Modal
modelValue={openLore.value !== -1}
onUpdate:modelValue={() => (openLore.value = -1)}
v-slots={{
header: () => <h2>{layers[days[openLore.value - 1]?.layer ?? "p"]?.name}</h2>,
body: () => days[openLore.value - 1]?.story ?? ""
}}
/>
));
return { return {
name: "Calendar", name: "Calendar",
days, days,
@ -115,6 +146,7 @@ export const main = createLayer("main", function (this: BaseLayer) {
) )
.map(days => renderRow(...days))} .map(days => renderRow(...days))}
</div> </div>
{render(loreModal)}
</> </>
)) ))
}; };