diff --git a/src/components/board/Board.vue b/src/components/board/Board.vue index 5d60a07..445f014 100644 --- a/src/components/board/Board.vue +++ b/src/components/board/Board.vue @@ -16,7 +16,7 @@ <svg class="stage" width="100%" height="100%"> <g id="g1"> <transition-group name="link" appear> - <g v-for="(link, index) in board.links || []" :key="index"> + <g v-for="link in board.links || []" :key="link"> <BoardLink :link="link" /> </g> </transition-group> diff --git a/src/components/board/BoardNode.vue b/src/components/board/BoardNode.vue index ac2d12e..ea726a7 100644 --- a/src/components/board/BoardNode.vue +++ b/src/components/board/BoardNode.vue @@ -229,7 +229,22 @@ export default defineComponent({ return this.board.selectedAction; }, actions(): BoardNodeAction[] | null | undefined { - return getNodeTypeProperty(this.nodeType, this.node, "actions"); + const actions = getNodeTypeProperty(this.nodeType, this.node, "actions") as + | BoardNodeAction[] + | null + | undefined; + if (actions) { + return actions.filter(action => { + if (action.enabled == null) { + return true; + } + if (typeof action.enabled === "function") { + return action.enabled(); + } + return action.enabled; + }); + } + return null; }, draggable(): boolean { return getNodeTypeProperty(this.nodeType, this.node, "draggable"); @@ -363,17 +378,17 @@ export default defineComponent({ transform: rotate(-90deg); } -.action:hover circle, -.action.selected circle { +.action:not(.boardnode):hover circle, +.action:not(.boardnode).selected circle { r: 25; } -.action:hover text, -.action.selected text { +.action:not(.boardnode):hover text, +.action:not(.boardnode).selected text { font-size: 187.5%; /* 150% * 1.25 */ } -.action text { +.action:not(.boardnode) text { text-anchor: middle; dominant-baseline: central; } diff --git a/src/data/layers/Main.vue b/src/data/layers/Main.vue index c27b588..045bf48 100644 --- a/src/data/layers/Main.vue +++ b/src/data/layers/Main.vue @@ -1,6 +1,7 @@ <template> <div v-if="devSpeed === 0">Game Paused</div> <div v-else-if="devSpeed && devSpeed !== 1">Dev Speed: {{ formattedDevSpeed }}x</div> + <div>Day {{ day }}</div> <Board id="main" /> <Modal :show="showModal" @close="closeModal"> <template v-slot:header v-if="title"> @@ -70,7 +71,9 @@ export default defineComponent(function Main() { const devSpeed = computed(() => player.devSpeed); const formattedDevSpeed = computed(() => player.devSpeed && format(player.devSpeed)); - return { title, body, footer, showModal, closeModal, devSpeed, formattedDevSpeed }; + const day = computed(() => player.day); + + return { title, body, footer, showModal, closeModal, devSpeed, formattedDevSpeed, day }; }); </script> @@ -82,4 +85,8 @@ export default defineComponent(function Main() { .entry:not(:last-child) { border-bottom: solid 4px var(--separator); } + +.boardnode.action .progressDiamond { + transition-duration: 0s; +} </style> diff --git a/src/data/layers/main.ts b/src/data/layers/main.ts index c682033..79d001a 100644 --- a/src/data/layers/main.ts +++ b/src/data/layers/main.ts @@ -60,11 +60,9 @@ type Resource = { const resources = { time: createResource("time", "#3EB489", 24 * 60 * 60, 24 * 60 * 60, [ - { resource: "social", amount: 1 / (60 * 60), linkType: LinkType.LossOnly }, { resource: "mental", amount: 1 / (120 * 60), linkType: LinkType.LossOnly } ]), energy: createResource("energy", "#FFA500", 100, 100), - social: createResource("social", "#800080", 100, 100), mental: createResource("mental", "#32CD32", 100, 100), focus: createResource("focus", "#0000FF", 100, 0) } as Record<string, Resource>; @@ -159,6 +157,7 @@ type Action = { amount: DecimalSource; assign?: boolean; }>; + enabled?: boolean | (() => boolean); }; const actions = { @@ -190,7 +189,7 @@ const actions = { ] }, sleep: { - icon: "bed", + icon: "mode_night", tooltip: "Sleep", events: [ { @@ -309,6 +308,28 @@ const actions = { { resource: "energy", amount: 30 }, { resource: "mental", amount: -5 } ] + }, + makeBed: { + icon: "king_bed", + tooltip: "Make Bed", + enabled: () => + Decimal.lt(player.lastDayBedMade as DecimalSource, player.day as DecimalSource), + events: [ + { + event: () => { + player.lastDayBedMade = player.day; + return { + description: `It's a small thing, but you feel better after making your bed` + }; + }, + weight: 1 + } + ], + baseChanges: [ + { resource: "time", amount: -10 * 60 }, + { resource: "energy", amount: -5 }, + { resource: "mental", amount: 5 } + ] } } as Record<string, Action>; @@ -352,7 +373,7 @@ const actionNodes = { display: "Web" }, bed: { - actions: ["sleep", "rest"], + actions: ["sleep", "rest", "makeBed"], display: "Bed" } } as Record<string, ActionNode>; @@ -618,7 +639,8 @@ const actionNodeType = { } as BoardNodeLink; }) ]; - } + }, + enabled: action.enabled } as BoardNodeAction; }) ]; @@ -720,14 +742,6 @@ export default { amount: new Decimal(100) } as ResourceNodeData }, - { - position: { x: 150, y: 0 }, - type: "resource", - data: { - resourceType: "social", - amount: new Decimal(100) - } as ResourceNodeData - }, { position: { x: -150, y: 0 }, type: "resource", diff --git a/src/data/mod.ts b/src/data/mod.ts index 3035aee..e6d3e97 100644 --- a/src/data/mod.ts +++ b/src/data/mod.ts @@ -1,7 +1,6 @@ import { RawLayer } from "@/typings/layer"; import { PlayerData } from "@/typings/player"; import Decimal from "@/util/bignum"; -import { hardReset } from "@/util/save"; import { computed } from "vue"; import main from "./layers/main"; @@ -12,7 +11,9 @@ export const getInitialLayers = ( export function getStartingData(): Record<string, unknown> { return { - points: new Decimal(10) + points: new Decimal(10), + day: new Decimal(1), + lastDayBedMade: new Decimal(0) }; } diff --git a/src/typings/player.d.ts b/src/typings/player.d.ts index c901591..71d6748 100644 --- a/src/typings/player.d.ts +++ b/src/typings/player.d.ts @@ -1,7 +1,7 @@ import { Themes } from "@/data/themes"; import { DecimalSource } from "@/lib/break_eternity"; import Decimal from "@/util/bignum"; -import { BoardData, BoardNode } from "./features/board"; +import { BoardData } from "./features/board"; import { MilestoneDisplay } from "./features/milestone"; import { State } from "./state";