forked from profectus/Profectus
Added amount displays to resource and item nodes
This commit is contained in:
parent
dc912ef54d
commit
8a38ecf928
1 changed files with 26 additions and 11 deletions
|
@ -3,6 +3,8 @@ import { layers } from "@/game/layers";
|
||||||
import player from "@/game/player";
|
import player from "@/game/player";
|
||||||
import Decimal, { DecimalSource } from "@/lib/break_eternity";
|
import Decimal, { DecimalSource } from "@/lib/break_eternity";
|
||||||
import { RawLayer } from "@/typings/layer";
|
import { RawLayer } from "@/typings/layer";
|
||||||
|
import { formatTime } from "@/util/bignum";
|
||||||
|
import { format } from "@/util/break_eternity";
|
||||||
import { camelToTitle } from "@/util/common";
|
import { camelToTitle } from "@/util/common";
|
||||||
import { getUniqueNodeID } from "@/util/features";
|
import { getUniqueNodeID } from "@/util/features";
|
||||||
import themes from "../themes";
|
import themes from "../themes";
|
||||||
|
@ -47,7 +49,7 @@ const redditEvents = [
|
||||||
position: { x: 0, y: 150 }, // TODO function to get nearest unoccupied space
|
position: { x: 0, y: 150 }, // TODO function to get nearest unoccupied space
|
||||||
type: "item",
|
type: "item",
|
||||||
data: {
|
data: {
|
||||||
itemType: "speed",
|
itemType: "time",
|
||||||
amount: new Decimal(15 * 60)
|
amount: new Decimal(15 * 60)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -118,7 +120,7 @@ export default {
|
||||||
position: { x: 0, y: 150 },
|
position: { x: 0, y: 150 },
|
||||||
type: "item",
|
type: "item",
|
||||||
data: {
|
data: {
|
||||||
itemType: "speed",
|
itemType: "time",
|
||||||
amount: new Decimal(5 * 60 * 60)
|
amount: new Decimal(5 * 60 * 60)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -138,6 +140,13 @@ export default {
|
||||||
return (node.data as ResourceNodeData).resourceType;
|
return (node.data as ResourceNodeData).resourceType;
|
||||||
},
|
},
|
||||||
label(node) {
|
label(node) {
|
||||||
|
if (player.layers[this.layer].boards[this.id].selectedNode == node.id) {
|
||||||
|
const data = node.data as ResourceNodeData;
|
||||||
|
if (data.resourceType === "time") {
|
||||||
|
return { text: formatTime(data.amount), color: "#0FF3" };
|
||||||
|
}
|
||||||
|
return { text: format(data.amount), color: "#0FF3" };
|
||||||
|
}
|
||||||
if (player.layers[this.layer].boards[this.id].selectedAction == null) {
|
if (player.layers[this.layer].boards[this.id].selectedAction == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -172,10 +181,6 @@ export default {
|
||||||
canAccept(node, otherNode) {
|
canAccept(node, otherNode) {
|
||||||
return otherNode.type === "item";
|
return otherNode.type === "item";
|
||||||
},
|
},
|
||||||
onClick(node) {
|
|
||||||
player.layers.main.openNode = node.id;
|
|
||||||
player.layers.main.showModal = true;
|
|
||||||
},
|
|
||||||
onDrop(node, otherNode) {
|
onDrop(node, otherNode) {
|
||||||
const index = player.layers[this.layer].boards[this.id].nodes.indexOf(
|
const index = player.layers[this.layer].boards[this.id].nodes.indexOf(
|
||||||
otherNode
|
otherNode
|
||||||
|
@ -189,11 +194,21 @@ export default {
|
||||||
},
|
},
|
||||||
item: {
|
item: {
|
||||||
title(node) {
|
title(node) {
|
||||||
return (node.data as ItemNodeData).itemType;
|
switch ((node.data as ItemNodeData).itemType) {
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
case "time":
|
||||||
|
return "speed";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onClick(node) {
|
label(node) {
|
||||||
player.layers.main.openNode = node.id;
|
if (player.layers[this.layer].boards[this.id].selectedNode == node.id) {
|
||||||
player.layers.main.showModal = true;
|
const data = node.data as ItemNodeData;
|
||||||
|
if (data.itemType === "time") {
|
||||||
|
return { text: formatTime(data.amount), color: "#0FF3" };
|
||||||
|
}
|
||||||
|
return { text: format(data.amount), color: "#0FF3" };
|
||||||
|
}
|
||||||
},
|
},
|
||||||
draggable: true
|
draggable: true
|
||||||
},
|
},
|
||||||
|
@ -211,7 +226,7 @@ export default {
|
||||||
id: "info",
|
id: "info",
|
||||||
icon: "history_edu",
|
icon: "history_edu",
|
||||||
fillColor() {
|
fillColor() {
|
||||||
return themes[player.theme].variables["--separator"];
|
return themes[player.theme].variables["--secondary-background"];
|
||||||
},
|
},
|
||||||
tooltip: "Log",
|
tooltip: "Log",
|
||||||
onClick(node) {
|
onClick(node) {
|
||||||
|
|
Loading…
Reference in a new issue