From d6eeb9b50bce53c9bdb079d76ba61e3971aef822 Mon Sep 17 00:00:00 2001 From: Acamaeda Date: Wed, 7 Oct 2020 11:08:20 -0400 Subject: [PATCH] Added layer name feature --- docs/layer-features.md | 2 ++ js/game.js | 2 +- js/layers.js | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/layer-features.md b/docs/layer-features.md index 97a4170..6f9afca 100644 --- a/docs/layer-features.md +++ b/docs/layer-features.md @@ -13,6 +13,8 @@ Key: - layer: **Assigned automagically**. It's the same value as the name of this layer, so you can do player[this.layer].points or similar to access the save value. It makes copying code to new layers easier. It is also assigned to all upgrades and buyables and such. +- name: **Optional**, used in reset confirmations (and maybe other places). If absent, it just uses the layer's id. + - startData(): A function to return the default save data for this layer. Add any variables you have to it. Any nonstandard Decimal variables need to be added to convertToDecimal as well. Standard values: diff --git a/js/game.js b/js/game.js index df62477..fdb30df 100644 --- a/js/game.js +++ b/js/game.js @@ -226,7 +226,7 @@ function doReset(layer, force=false) { function respecBuyables(layer) { if (!layers[layer].buyables) return if (!layers[layer].buyables.respec) return - if (!confirm("Are you sure you want to respec? This will force you to do a \"" + layer + "\" reset as well!")) return + if (!confirm("Are you sure you want to respec? This will force you to do a \"" + (layers[layer].name ? layers[layer].name : layer) + "\" reset as well!")) return layers[layer].buyables.respec() } diff --git a/js/layers.js b/js/layers.js index 8adb54d..b02ec1d 100644 --- a/js/layers.js +++ b/js/layers.js @@ -1,5 +1,6 @@ addLayer("c", { layer: "c", // This is assigned automatically, both to the layer and all upgrades, etc. Shown here so you know about it + name: "Candies", // This is optional, only used in a few places, If absent it just uses the layer id. startData() { return { unl: true, points: new Decimal(0),