From 15931a0ffa36de6fde48c5d1f05b6edaa7964cdc Mon Sep 17 00:00:00 2001 From: Harley White Date: Sat, 11 Sep 2021 20:55:46 -0400 Subject: [PATCH] Added pluralize --- changelog.md | 2 ++ docs/layer-features.md | 2 ++ docs/main-game-info.md | 2 ++ js/Demo/demoGame.js | 1 + js/Demo/layers/c.js | 1 + js/components.js | 2 +- js/technical/systemComponents.js | 2 +- js/utils/NumberFormating.js | 6 ++++++ 8 files changed, 16 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 5d14bbe..17f591c 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,8 @@ - Changed the name to "Incrementum" and replaced all instances of "mod" with "game". game.js has been renamed incrementum.js, and mod.js is now game.js. - Added linear and quadratic prestige types, improved the prestige type system. +- Added "pluralize" function, and made main point displays correctly use singular and plural (if singular is supplied). + - Upgrade effectDisplay and grid tooltip no longer display if they return "". diff --git a/docs/layer-features.md b/docs/layer-features.md index 39876eb..5009e68 100644 --- a/docs/layer-features.md +++ b/docs/layer-features.md @@ -32,6 +32,8 @@ You can make almost any value dynamic by using a function in its place, includin - resource: Name of the main currency you gain by resetting on this layer. +- singular: **optional**, singular version of the currency name. + - effect(): **optional**. A function that calculates and returns the current values of any bonuses inherent to the main currency. Can return a value or an object containing multiple values. *You will also have to implement the effect where it is applied.* - effectDescription: **optional**. A function that returns a description of this effect. If the text stays constant, it can just be a string. diff --git a/docs/main-game-info.md b/docs/main-game-info.md index c6397a5..b6298ea 100644 --- a/docs/main-game-info.md +++ b/docs/main-game-info.md @@ -10,6 +10,8 @@ Here's a breakdown of what's in it: - id: The id for your game, a unique string that is used to determine savefile location. Be sure to set it when you start making a game, and don't change it later because it will erase all saves. - author: The name of the author, displayed in the info tab. - pointsName: This changes what is displayed instead of "points" for the main currency. (It does not affect it in the code.) + = singularName: The singular version of pointsName. + - gameFiles: An array of file addresses which will be loaded for this game. Using smaller files makes it easier to find what you're looking for. - discordName, discordLink: If you have a Discord server or other discussion place, you can add a link to it. diff --git a/js/Demo/demoGame.js b/js/Demo/demoGame.js index 71c06ac..5a69a58 100644 --- a/js/Demo/demoGame.js +++ b/js/Demo/demoGame.js @@ -2,6 +2,7 @@ let gameInfo = { name: "Incrementum", id: "modbase", pointsName: "points", + singularName: "point", gameFiles: ["Demo/layers/c.js", "Demo/layers/f.js", "Demo/layers/a.js", "Demo/demoTree.js"], diff --git a/js/Demo/layers/c.js b/js/Demo/layers/c.js index 79df9fe..37ba96c 100644 --- a/js/Demo/layers/c.js +++ b/js/Demo/layers/c.js @@ -20,6 +20,7 @@ addLayer("c", { color: "#4BDC13", requires: new Decimal(10), // Can be a function that takes requirement increases into account resource: "lollipops", // Name of prestige currency + singular: "lollipop", baseResource: "points", // Name of resource prestige is based on baseAmount() {return player.points}, // Get the current amount of baseResource type: "normal", // normal: cost to gain currency depends on amount gained. static: cost depends on how much you already have diff --git a/js/components.js b/js/components.js index 9804a42..9fdbe9b 100644 --- a/js/components.js +++ b/js/components.js @@ -236,7 +236,7 @@ function loadVue() { Vue.component('main-display', { props: ['layer', 'data'], template: ` -
You have

{{data ? format(player[layer].points, data) : formatWhole(player[layer].points)}}

{{tmp[layer].resource}},

+
You have

{{data ? format(player[layer].points, data) : formatWhole(player[layer].points)}}

{{pluralize(player[layer].points, tmp[layer].singular || tmp[layer].resource, tmp[layer].resource)}},

` }) diff --git a/js/technical/systemComponents.js b/js/technical/systemComponents.js index f0ad353..307bb0f 100644 --- a/js/technical/systemComponents.js +++ b/js/technical/systemComponents.js @@ -114,7 +114,7 @@ var systemComponents = {
You have

{{format(player.points)}}

- {{gameInfo.pointsName}} + {{pluralize(player.points, gameInfo.singularName || gameInfo.pointsName, gameInfo.pointsName)}}
({{tmp.other.oompsMag != 0 ? format(tmp.other.oomps) + " OOM" + (tmp.other.oompsMag < 0 ? "^OOM" : tmp.other.oompsMag > 1 ? "^" + tmp.other.oompsMag : "") + "s" : formatSmall(getPointGen())}}/sec)
diff --git a/js/utils/NumberFormating.js b/js/utils/NumberFormating.js index 0db0dbf..b48befb 100644 --- a/js/utils/NumberFormating.js +++ b/js/utils/NumberFormating.js @@ -1,3 +1,9 @@ +// Makes things grammatically correct +function pluralize (value, singular, plural) { + value = new Decimal(value) + if (value.eq(decimalOne)) return singular + return plural +} function exponentialFormat(num, precision, mantissa = true) { let e = num.log10().floor()