From de1f37d73246b48065456fb97a06dfa1b5b87a82 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Mon, 8 May 2023 22:39:05 -0500 Subject: [PATCH] Change upgrade names --- package.json | 1 - src/data/planes.tsx | 21 ++------ src/data/utils.tsx | 115 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 4b6e62b..4aa9568 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "jsdom": "^20.0.0", "prettier": "^2.5.1", "typescript": "^5.0.2", - "unique-names-generator": "^4.7.1", "vitest": "^0.29.3", "vue-tsc": "^0.38.1" }, diff --git a/src/data/planes.tsx b/src/data/planes.tsx index 91a6983..0579181 100644 --- a/src/data/planes.tsx +++ b/src/data/planes.tsx @@ -28,7 +28,6 @@ import { } from "game/modifiers"; import { State, noPersist, persistent } from "game/persistence"; import { createCostRequirement } from "game/requirements"; -import { adjectives, colors, uniqueNamesGenerator } from "unique-names-generator"; import Decimal, { DecimalSource } from "util/bignum"; import { format, formatWhole } from "util/break_eternity"; import { Direction, WithRequired, camelToTitle } from "util/common"; @@ -37,7 +36,7 @@ import { VueFeature, render, renderRow, trackHover } from "util/vue"; import { ComputedRef, Ref, computed, ref, unref } from "vue"; import { useToast } from "vue-toastification"; import { createCollapsibleModifierSections, createFormulaPreview, estimateTime } from "./common"; -import { getColor, getName, sfc32 } from "./utils"; +import { getColor, getName, getPowerName, sfc32 } from "./utils"; import { Resources, InfluenceState, @@ -218,7 +217,7 @@ export function createPlane( }; const upgradeType = pickRandom(upgradeTypeWeights, random); const cost = nextCost.value; - const title = getRandomUpgrade(random); + const title = getPowerName(random); let description = ""; let modifier: WithRequired; let previewModifier: WithRequired; @@ -309,7 +308,7 @@ export function createPlane( // This will become less accurate the further n gets from when the repeatable showed up, but at that time it should be having an increasingly smaller effect on the overall gain const currentN = n.value; const initialCost = nextCost.value; - const title = getRandomUpgrade(random); + const title = getPowerName(random); let description = ""; let effect: ComputedRef; let modifier: WithRequired; @@ -431,7 +430,7 @@ export function createPlane( cachedGain[n.value] = costFormula.evaluate(); n.value += 2; const clickableVisibility = visibility; - const title = getRandomUpgrade(random); + const title = getPowerName(random); const formula = Formula.variable(prestigeResource).pow(effectExponent).add(1); const modifier = createMultiplicativeModifier(() => ({ multiplier: () => formula.evaluate(), @@ -527,7 +526,7 @@ export function createPlane( const xp = createResource(0); const barVisibility = visibility; const currentN = n.value; - const title = getRandomUpgrade(random); + const title = getPowerName(random); const cost = Decimal.add(difficulty, random() - 0.5) .pow_base(2) .times(10); @@ -1080,14 +1079,4 @@ function pickRandom(items: Record, random: () => nu return result; } -function getRandomUpgrade(random: () => number) { - return camelToTitle( - uniqueNamesGenerator({ - dictionaries: [colors, adjectives], - seed: random() * 4294967296, - separator: " " - }) + "ity" - ); -} - export type GenericPlane = ReturnType; diff --git a/src/data/utils.tsx b/src/data/utils.tsx index e24b883..e7f5447 100644 --- a/src/data/utils.tsx +++ b/src/data/utils.tsx @@ -212,6 +212,121 @@ export function getName(random: () => number) { return camelToTitle(name); } +const powerMorphemes = { + 1: ["a", "e", "i", "o", "u"], + 2: [ + "ph", + "th", + "ch", + "sh", + "br", + "cr", + "dr", + "fr", + "gr", + "pr", + "tr", + "str", + "sc", + "sk", + "sm", + "sn", + "sp", + "st", + "sw" + ], + 3: [ + "ae", + "ai", + "ao", + "au", + "ay", + "ea", + "ei", + "eo", + "eu", + "ey", + "ua", + "ue", + "ui", + "uo", + "uy", + "ia", + "ie", + "iu", + "io", + "iy", + "oa", + "oe", + "ou", + "oi", + "oy" + ], + 4: [ + "morp", + "flux", + "syn", + "void", + "rift", + "dyn", + "nov", + "chron", + "lum", + "par", + "ter", + "psy", + "phan", + "man", + "grav", + "pyr", + "cry", + "hydr", + "elec", + "kin", + "nan", + "omni" + ], + 5: [ + "ance", + "ation", + "esis", + "ergy", + "tide", + "al", + "ism", + "ity", + "mancy", + "urgy", + "pathy", + "port", + "shift", + "burst", + "pulse", + "wave", + "field", + "storm", + "force", + "blade" + ] +}; +const powerTemplates = [ + [1, 2, 1, 4, 5], + [1, 4, 5], + [2, 1, 4, 5], + [1, 2, 3, 4, 5], + [3, 4, 5] +] as const; + +export function getPowerName(random: () => number) { + const template = powerTemplates[Math.floor(random() * powerTemplates.length)]; + let name = ""; + for (let i = 0; i < template.length; i++) { + const morphemeSet = powerMorphemes[template[i]]; + name += morphemeSet[Math.floor(random() * morphemeSet.length)]; + } + return camelToTitle(name); +} + export function getColor(base: [number, number, number], random: () => number) { const [h, s, v] = rgb2hsv(...base); const [r, g, b] = hsv2rgb(Math.floor(random() * 360), s, v);