From 95e1fc2ff058af794dceaed3ce53328359d3ea21 Mon Sep 17 00:00:00 2001 From: Acamaeda Date: Mon, 12 Oct 2020 23:28:02 -0400 Subject: [PATCH] Added documentation for bars, fixes in other docs --- docs/bars.md | 39 +++++++++++++++++++++++++++++++++++ docs/basic-layer-breakdown.md | 1 - docs/buyables.md | 2 +- docs/challenges.md | 2 +- docs/clickables.md | 2 +- docs/milestones.md | 2 +- docs/upgrades.md | 2 +- js/layerSupport.js | 11 +++++----- js/layers.js | 2 +- js/temp.js | 6 ++++-- 10 files changed, 54 insertions(+), 15 deletions(-) create mode 100644 docs/bars.md diff --git a/docs/bars.md b/docs/bars.md new file mode 100644 index 0000000..6cbb85a --- /dev/null +++ b/docs/bars.md @@ -0,0 +1,39 @@ +# Buyables + +Bars let you display information in a more direct way. It can be a progress bar, health bar, capacity gague, or anything else. + +Bars are defined like other Big Features: + +```js + bars: { + bigBar: { + display() {return "Blah"}, + etc + } + etc + } +``` + +Features: + +- direction: UP, DOWN, LEFT, or RIGHT (not Strings). Determines the direction that the bar is filled as it progresses. + RIGHT means from left to right. + +- width, height: The size in pixels of the bar, but as Numbers (no "px" at the end) + +- progress(): A function that returns the portion of the bar that is filled, from "empty" at 0 to "full" at 1. + (Nothing bad happens if the value goes out of these bounds, and it can be a number or Decimal). + +- display(): **optional**, A function that returns text to be displayed on top of the bar, can use HTML. + +- unlocked(): **optional**, A function returning a bool to determine if the buyable is visible or not. Default is unlocked. + +- baseStyle, fillStyle, borderStyle, textStyle: **Optional**, Apply CSS to the unfilled portion, filled portion, border, and + display text on the bar, in the form of an object where the keys are CSS attributes, and the values are the + values for those attributes (both as strings). + + +- layer: **Assigned automagically**. It's the same value as the name of this layer, so you can do player[this.layer].points or similar + +- id: **Assigned automagically**. It's the "key" which the bar was stored under, for convenient access. + The bar in the example's id is "bigBar". \ No newline at end of file diff --git a/docs/basic-layer-breakdown.md b/docs/basic-layer-breakdown.md index 43d7696..a9cf954 100644 --- a/docs/basic-layer-breakdown.md +++ b/docs/basic-layer-breakdown.md @@ -8,7 +8,6 @@ This is a very minimal layer with minimal features. Most things will require add startData() { return { // startData is a function that returns default data for a layer. unlocked: false, // You can add more variables here to add them to your layer. points: new Decimal(0), // "points" is the internal name for the main resource of the layer. - // If you add non-standard Decimal variables, look at convertToDecimal }}, color: "#FE0102", // The color for this layer, which affects many elements diff --git a/docs/buyables.md b/docs/buyables.md index b3976db..2422a37 100644 --- a/docs/buyables.md +++ b/docs/buyables.md @@ -17,7 +17,7 @@ Buyables should be formatted like this: Having this function makes a respec button appear respecText: **optional**, text that appears on the respec button 11: { - display:() => "Blah", + display() {return "Blah"}, etc } etc diff --git a/docs/challenges.md b/docs/challenges.md index bb48509..7023ce6 100644 --- a/docs/challenges.md +++ b/docs/challenges.md @@ -15,7 +15,7 @@ Challenges are stored in the following format: rows: # of rows cols: # of columns 11: { - name:() => "Ouch", + name: "Ouch", etc } etc diff --git a/docs/clickables.md b/docs/clickables.md index 9874f19..d2590ed 100644 --- a/docs/clickables.md +++ b/docs/clickables.md @@ -20,7 +20,7 @@ Clickables should be formatted like this: // pressing it will call the function. masterButtonText: "Press me!" // **optional** text to display on the Master Button 11: { - desc:() => "Blah", + display() {return "Blah"}, etc } etc diff --git a/docs/milestones.md b/docs/milestones.md index a8c521c..615abab 100644 --- a/docs/milestones.md +++ b/docs/milestones.md @@ -5,7 +5,7 @@ Milestones should be formatted like this: ```js milestones: { 0: { - requirementDesc:() => "123 waffles", + requirementDesc: "123 waffles", } etc } diff --git a/docs/upgrades.md b/docs/upgrades.md index 3b78ec8..0784210 100644 --- a/docs/upgrades.md +++ b/docs/upgrades.md @@ -15,7 +15,7 @@ Hint: Basic point gain is calculated in game.js's "getPointGain". rows: # of rows cols: # of columns 11: { - desc:() => "Blah", + desc: "Blah", more features } etc diff --git a/js/layerSupport.js b/js/layerSupport.js index 7647d93..26bd62e 100644 --- a/js/layerSupport.js +++ b/js/layerSupport.js @@ -91,12 +91,11 @@ function updateLayers(){ if (layers[layer].bars){ layers[layer].bars.layer = layer for (thing in layers[layer].bars){ - if (!isNaN(thing)){ - layers[layer].bars[thing].id = thing - layers[layer].bars[thing].layer = layer - if (layers[layer].bars[thing].unlocked === undefined) - layers[layer].bars[thing].unlocked = true - } + layers[layer].bars[thing].id = thing + layers[layer].bars[thing].layer = layer + if (layers[layer].bars[thing].unlocked === undefined) + layers[layer].bars[thing].unlocked = true + } } diff --git a/js/layers.js b/js/layers.js index 766b58a..77b97f0 100644 --- a/js/layers.js +++ b/js/layers.js @@ -305,7 +305,7 @@ addLayer("c", { ["blank", ['0', '50px']], ["bar", "flatBoi"] ]], ]], - "blank", ["display-text", "It's because bars! So funny! Ha ha!"], + "blank", ["display-text", "It's jail because \"bars\"! So funny! Ha ha!"], ], }, illuminati: { diff --git a/js/temp.js b/js/temp.js index ebbb0e0..b15a124 100644 --- a/js/temp.js +++ b/js/temp.js @@ -107,6 +107,8 @@ function constructBarStyles(layer){ let bar = tmp[layer].bars[id] if (bar.progress instanceof Decimal) bar.progress = bar.progress.toNumber() + bar.progress = Math.min(Math.max(bar.progress, 0), 1) + bar.dims = {'width': bar.width + "px", 'height': bar.height + "px"} let dir = bar.direction bar.fillDims = {'width': bar.width + "px", 'height': bar.height + "px"} @@ -115,12 +117,12 @@ function constructBarStyles(layer){ bar.fillDims[DIR_MARGINS[dir]] = "0px" if (dir == UP || dir == DOWN) { - bar.fillDims.height = bar.height * Math.min(bar.progress, 1) + "px" + bar.fillDims.height = bar.height * bar.progress + "px" if (dir == UP) bar.fillDims['margin-top'] = bar.height * (1 - Math.min(bar.progress, 1)) + "px" } else { - bar.fillDims.width = bar.width * Math.min(bar.progress, 1) + "px" + bar.fillDims.width = bar.width * bar.progress + "px" if (dir == LEFT) bar.fillDims['margin-left'] = bar.width * (1 - Math.min(bar.progress, 1)) + "px" } }