From f4937a585521b61ab48456faa16e2bc4fd2cb1a1 Mon Sep 17 00:00:00 2001 From: Rhys <36913739+ryceg@users.noreply.github.com> Date: Sun, 13 Jun 2021 12:10:44 +1000 Subject: [PATCH] Minor-Fixes (#640) --- .github/workflows/release.yml | 7 +- CHANGELOG.md | 13 + global.d.ts | 2 + lib/npc-generation/familyRelationships.ts | 5 +- lib/npc-generation/professions.ts | 24 + lib/npc-generation/raceTraits.ts | 1 + .../traits/getTraitDescriptors.ts | 18 +- lib/npc-generation/traits/getTraits.ts | 9 +- lib/src/arpa.ts | 40 +- lib/src/findProfession.ts | 9 +- lib/town/roads.ts | 1 - main.ejs | 3 - package.json | 5 +- src/Alchemist/AlchemistOutput.twee | 2 +- src/Blacksmith/SmithyOutput.twee | 2 +- src/Buildings/GenericPassage.twee | 4 +- src/Factions/FactionProfile.twee | 6 +- src/GeneralStore/GeneralStoreOutput.twee | 2 +- .../Guardhouse/GuardhouseOutput.twee | 2 +- src/Misc/CreateRandomNPC.twee | 32 +- .../NPCProfile/Components/NPCHeader.twee | 54 +- src/NPCGeneration/NPCProfile/NPCProfile.twee | 100 +- .../components-edit/NPCProfileEdit.twee | 88 +- src/NPCGeneration/createHistory.ts | 4 +- src/NPCGeneration/npcData.js | 2 +- src/Religion/EditPantheon.twee | 4 +- src/Settings/CSS/details.css | 2 +- src/Settings/CSS/stylesheet.css | 6 + src/Settings/CustomImages.twee | 13 +- src/Settings/Setting.js | 1 + src/Start/StoryInit.twee | 2 +- src/Start/Welcome.twee | 2 +- src/Town/components-edit/TownEdit.twee | 4 +- src/World/CreateScenario.twee | 68 +- yarn.lock | 1412 +++++++---------- 35 files changed, 983 insertions(+), 966 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 297bb695a..0d9a5b7e6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,18 +32,17 @@ jobs: run: cp -r ./src/Resources ./gh-pages/src/ - name: Copy index.html - run: cp -r ./index.html ./ + run: cp -r ./gh-pages/index.html ./ - name: Copy main - run: cp -r ./main.js ./ + run: cp -r ./gh-pages/main.js ./ - name: Copy main map - run: cp -r ./main.js.map ./ + run: cp -r ./gh-pages/main.js.map ./ - name: Create TypeDocs run: yarn typedoc - - name: Deploy uses: JamesIves/github-pages-deploy-action@3.7.1 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 230ccf2cf..6952fe30e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## 2.8.10 + +### Added +- Flex to button rows so they are a little more responsive on smaller screens. +### Changed +- Fixed a bug where the key to roads was being assigned rather than the road itself, resulting in the error in NPCs profile. +- Changed expanded details to use – rather than - so there is less shifting of the text. +- Shifted RiTa to an imported module. +- Fixed the surface level NPC editing issue. + +### Removed +- SugarCube history has been removed (as it was not being used), which should reduce lag on larger towns. + ## 2.8.9 ### Added diff --git a/global.d.ts b/global.d.ts index 592b4c317..7156d4e0f 100644 --- a/global.d.ts +++ b/global.d.ts @@ -22,3 +22,5 @@ declare function gtag(event: string, action: string, data: { event_action?: string, value?: string }): void + +declare module 'rita' diff --git a/lib/npc-generation/familyRelationships.ts b/lib/npc-generation/familyRelationships.ts index 4221f0044..6edcc6ef6 100644 --- a/lib/npc-generation/familyRelationships.ts +++ b/lib/npc-generation/familyRelationships.ts @@ -114,8 +114,8 @@ export function createFamily (town: Town, npc: NPC) { export function createFamilyHouse (town: Town, family: Family) { const road = town.roads[family.home.road] || - roads.findExisting(town) || - random(Object.keys(town.roads)) + roads.findExisting(town) || + random(Object.values(town.roads)) // roads.assign(town) for (const member in family.members) { @@ -129,5 +129,6 @@ export function createFamilyHouse (town: Town, family: Family) { road: road.key } }) + console.log('Assigned a house!') // return family as Family } diff --git a/lib/npc-generation/professions.ts b/lib/npc-generation/professions.ts index 8576e1699..eaee60bec 100644 --- a/lib/npc-generation/professions.ts +++ b/lib/npc-generation/professions.ts @@ -2524,6 +2524,30 @@ export const professions: Record = { } } }, + 'conscripted soldier': { + sv: 1000, + isBackground: true, + type: 'profession', + sector: 'military', + description: 'serves in an army against their will.', + domSub: 'dom', + dailyWage: 2, + socialClass: 'indentured servitude', + socialClassRoll () { + return 20 + dice(8, 6) + }, + relationships (town, npc) { + return { + coworker: { + relationship: 'co-worker', + probability: 20, + base: { + profession: npc.profession + } + } + } + } + }, 'spice merchant': { sv: 1500, type: 'business', diff --git a/lib/npc-generation/raceTraits.ts b/lib/npc-generation/raceTraits.ts index e782be181..6f21e95d4 100644 --- a/lib/npc-generation/raceTraits.ts +++ b/lib/npc-generation/raceTraits.ts @@ -141,6 +141,7 @@ export const raceTraits: Record = { bmiModifier: 500, ageTraits: { 'ageDescriptors': [ + [400, 'ancient'], [300, 'ancient'], [250, 'incredibly elderly'], [200, 'vulnerably elderly'], diff --git a/lib/npc-generation/traits/getTraitDescriptors.ts b/lib/npc-generation/traits/getTraitDescriptors.ts index 5d65b9f10..2bc59c957 100644 --- a/lib/npc-generation/traits/getTraitDescriptors.ts +++ b/lib/npc-generation/traits/getTraitDescriptors.ts @@ -1,5 +1,5 @@ import { NPC, ThresholdTable } from '@lib' -import { Virtues } from './getTraits' +import { getTrait, Virtues } from './getTraits' /** * @usage 'is _____' @@ -279,18 +279,17 @@ export const traitDescriptions: Record> = { [1, 'craven'] ] } - -const getTraitPositiveOrNegative = (firstTrait: number, secondTrait: number) => { - if (Math.abs(firstTrait - secondTrait) > 9) return 'but' - return 'and' -} - interface TraitDescriptions { trait: Virtues result: string roll: number } +const getTraitPositiveOrNegative = (firstTrait: number, secondTrait: number) => { + if (Math.abs(firstTrait - secondTrait) > 9) return 'but' + return 'and' +} + export const getTraitDescription = (trait: Virtues, roll: number) => { let results for (const [num, description] of traitDescriptions[trait]) { @@ -300,14 +299,15 @@ export const getTraitDescription = (trait: Virtues, roll: number) => { } } if (results) return results + return null } export const getAllTraits = (npc: NPC) => { const traitDescriptions: TraitDescriptions[] = [] for (const temp in npc.roll.traits) { const trait = temp as Virtues - // const roll = getTrait(trait, npc, true) - const roll = Math.clamp(npc.roll.traits[trait] / 5, 1, 19) + const roll = getTrait(trait, npc, true) + // const roll = Math.clamp(npc.roll.traits[trait] / 5, 1, 19) const result = getTraitDescription(trait, roll) if (result) { traitDescriptions.push({ trait, roll, result }) diff --git a/lib/npc-generation/traits/getTraits.ts b/lib/npc-generation/traits/getTraits.ts index 4ae88107d..fdac8edd7 100644 --- a/lib/npc-generation/traits/getTraits.ts +++ b/lib/npc-generation/traits/getTraits.ts @@ -1,10 +1,5 @@ import { NPC } from '../_common' -interface SanitizedVirtue { - wasVice: boolean - virtue: Virtues -} - export const traits = { virtueKey: { chaste: 'lustful', @@ -41,6 +36,10 @@ export const traits = { export type Virtues = keyof typeof traits['virtueKey'] export type Vices = keyof typeof traits['viceKey'] export type VirtuesVices = Virtues | Vices +interface SanitizedVirtue { + wasVice: boolean + virtue: Virtues +} export const personalityTraitExists = (personalityTrait: string) => { return Object.keys(lib.personalityTraits).includes(personalityTrait) diff --git a/lib/src/arpa.ts b/lib/src/arpa.ts index 7229532b0..2cfa9ce23 100644 --- a/lib/src/arpa.ts +++ b/lib/src/arpa.ts @@ -1,3 +1,5 @@ +import RiTa from 'rita' + interface RitaAnalyze { phones: string pos: string @@ -6,7 +8,34 @@ interface RitaAnalyze { tokens: string } -export function ArpabetToIpa (analyze: RitaAnalyze) { +export function extractIpa (word: string) { + return arpabetToIpa(RiTa.analyze(word) || word) +} + +// export function convertToPastTense (sentence: string) { +// const basics: Record = { +// is: 'was', +// are: 'were', +// has: 'had', +// have: 'had' +// } +// const output: string[] = [] +// const tokens: string[] = RiTa.tokenize(sentence) +// for (const word of tokens) { +// if (basics[word]) { +// output.push(basics[word]) +// } else if (RiTa.isVerb(word)) { +// output.push( +// RiTa.pastPart( +// RiTa.singularize(word))) +// } else { +// output.push(word) +// } +// } +// return RiTa.untokenize(output) +// } + +export function arpabetToIpa (analyze: RitaAnalyze) { // const ipaSounds = { // 'ɑ': { // examples: ['fast, car, hard, bath'], @@ -413,8 +442,7 @@ export function ArpabetToIpa (analyze: RitaAnalyze) { // type: 'Syllabification' // } // } - const str = analyze.phones - const ArpabetToIpaTable: Record = { + const arpabetToIpaTable: Record = { AA: 'ɑ', AE: 'æ', AH: 'ʌ', @@ -466,16 +494,16 @@ export function ArpabetToIpa (analyze: RitaAnalyze) { Z: 'z', ZH: 'ʒ' } - const arrayOfWords = str.split(' ') + const arrayOfWords = analyze.phones.split(' ') let resultantString = '' for (const word of arrayOfWords) { const phoneme = word.split('-') for (const key of phoneme) { - resultantString += ArpabetToIpaTable[key.toUpperCase()] + resultantString += arpabetToIpaTable[key.toUpperCase()] } resultantString += ' ' } - console.log(str, arrayOfWords, resultantString) + // console.log(arrayOfWords, resultantString) return `/${resultantString}/.` } diff --git a/lib/src/findProfession.ts b/lib/src/findProfession.ts index 37c0f293e..130af806e 100644 --- a/lib/src/findProfession.ts +++ b/lib/src/findProfession.ts @@ -4,7 +4,6 @@ import { professions } from '../npc-generation/professions' import { fetchProfessionChance } from '../npc-generation/fetchProfessionChance' import { findInContainer } from './findInContainer' -import { articles } from './articles' export function findProfession (town: Town, npc: NPC, professionName?: string) { if (typeof professionName === 'undefined') { @@ -19,18 +18,18 @@ export function findProfession (town: Town, npc: NPC, professionName?: string) { throw new Error('Could not find a profession name.') } - console.groupCollapsed(`running findProfession for ${npc.name}; looking for ${articles.output(professionName)}`) - console.log({ town, npc, professionName }) + // console.groupCollapsed(`running findProfession for ${npc.name}; looking for ${articles.output(professionName)}`) + // console.log({ town, npc, professionName }) const profession = professions[professionName] if (profession) { - console.log(`${professionName} is defined!`) + // console.log(`${professionName} is defined!`) console.groupEnd() return profession } - console.log('could not find it. Looking for synonyms...') + console.log(`could not find ${professionName}. Looking for synonyms...`) const found = findInContainer(professions)('synonyms', professionName) if (typeof found === 'undefined') { diff --git a/lib/town/roads.ts b/lib/town/roads.ts index 0aae230dd..ccb52df87 100644 --- a/lib/town/roads.ts +++ b/lib/town/roads.ts @@ -157,7 +157,6 @@ export const roads = { findExisting: (town: Town): Road | undefined => { console.log('Searching for an existing road...') for (const key in town.roads) { - console.log(Object.values(town.roads[key].inhabitants.buildings).length) if (town.roads[key].currentOccupancy >= town.roads[key].capacity) { console.log(`${town.roads[key].name} is at its capacity of ${town.roads[key].capacity}!`) continue diff --git a/main.ejs b/main.ejs index 0f7f1c7af..904f02bff 100644 --- a/main.ejs +++ b/main.ejs @@ -15,9 +15,6 @@ - - - diff --git a/package.json b/package.json index c4690ec01..9c53d4991 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "eigengraus-essential-establishment-generator", - "version": "2.5.0", + "version": "2.8.10", "description": "Eigengrau's Essential Establishment Generator", "main": "main.txt", "repository": { @@ -9,7 +9,7 @@ "url": "git+https://github.com/ryceg/Eigengrau-s-Essential-Establishment-Generator.git" }, "author": "ryceg", - "license": "GNU GENERAL PUBLIC LICENSE", + "license": "MIT", "bugs": { "url": "https://github.com/ryceg/Eigengrau-s-Essential-Establishment-Generator/issues" }, @@ -63,6 +63,7 @@ "jest": "^26.6.3", "jscodeshift": "^0.11.0", "lint-staged": "^10.5.3", + "rita": "^2.4.91", "rollup": "^2.36.1", "rollup-plugin-terser": "^7.0.2", "shelljs": "^0.8.4", diff --git a/src/Alchemist/AlchemistOutput.twee b/src/Alchemist/AlchemistOutput.twee index 65cca6fd5..9e7189c6a 100644 --- a/src/Alchemist/AlchemistOutput.twee +++ b/src/Alchemist/AlchemistOutput.twee @@ -4,7 +4,7 @@ <> <><> <> -<> +<>

$building.name

You enter $building.name, <>. <> There is a chemist behind the shop counter currently <>.

Chemist

The $associatedNPC.weight chemist <> <>. <> introduces $associatedNPC.himherself as <>, the $associatedNPC.owner of the shop, and asks what $associatedNPC.heshe can do for you.

<> diff --git a/src/Blacksmith/SmithyOutput.twee b/src/Blacksmith/SmithyOutput.twee index 62b2bbe24..c1add68a9 100644 --- a/src/Blacksmith/SmithyOutput.twee +++ b/src/Blacksmith/SmithyOutput.twee @@ -4,7 +4,7 @@ <> <> <> -<> +<>

$building.name

You make your way down <>, and enter $building.name and see that inside, the $building.structure.descriptor is $building.size. <> There is a blacksmith currently <>.

<> diff --git a/src/Buildings/GenericPassage.twee b/src/Buildings/GenericPassage.twee index 48fad1293..22639f0de 100644 --- a/src/Buildings/GenericPassage.twee +++ b/src/Buildings/GenericPassage.twee @@ -1,6 +1,6 @@ :: GenericPassage -<> -<>

$building.name

+<><> +\

$building.name

<> <> <> diff --git a/src/Factions/FactionProfile.twee b/src/Factions/FactionProfile.twee index 1c41d32ff..9904b49dd 100644 --- a/src/Factions/FactionProfile.twee +++ b/src/Factions/FactionProfile.twee @@ -3,13 +3,15 @@ <><> <>

$currentPassage.name

-<> +

<> is <> $currentPassage.wordNoun. It's $currentPassage.age, and the $currentPassage.size faction has <> reputation, and is motivated by $currentPassage.motivation. They are $currentPassage.misc.

<><><> <> -

Members

Members of $currentPassage.name are identifiable by $currentPassage.membersTrait. Membership requires $currentPassage.joiningRequirement, and costs $currentPassage.joiningFee. The initiation into $currentPassage.name involves $currentPassage.joiningInitiation.

+

Members

Members of $currentPassage.name are identifiable by <>. Membership requires $currentPassage.joiningRequirement, and costs $currentPassage.joiningFee. The initiation into $currentPassage.name involves $currentPassage.joiningInitiation.

<Create Members" t8n>><><> <> <> diff --git a/src/GeneralStore/GeneralStoreOutput.twee b/src/GeneralStore/GeneralStoreOutput.twee index cc30f9830..8a8b16cdf 100644 --- a/src/GeneralStore/GeneralStoreOutput.twee +++ b/src/GeneralStore/GeneralStoreOutput.twee @@ -3,7 +3,7 @@ <> <> <> -<> +<>

$building.name

You make your way down <>, and enter $building.structure.descriptor and see that inside, the $building.size building is $building.cleanliness.<> $building.clutter<> You notice $building.note. The store's shopkeep is currently $building.idle.

Shopkeeper

diff --git a/src/MiniEstablishments/Guardhouse/GuardhouseOutput.twee b/src/MiniEstablishments/Guardhouse/GuardhouseOutput.twee index 4fb8065cd..b7acaeba5 100644 --- a/src/MiniEstablishments/Guardhouse/GuardhouseOutput.twee +++ b/src/MiniEstablishments/Guardhouse/GuardhouseOutput.twee @@ -4,7 +4,7 @@ <> <> <> -

$currentPassage.name

You make your way down <>, and enter $currentPassage.name $currentPassage.structure.descriptor. $currentPassage.name is known for $currentPassage.notableFeature

+

$currentPassage.name

You make your way down <>, and enter $currentPassage.name $currentPassage.structure.descriptor. $currentPassage.name is known for $currentPassage.notableFeature

It is run by <>, who are $currentPassage.expertise. At the moment, <>

<> diff --git a/src/Misc/CreateRandomNPC.twee b/src/Misc/CreateRandomNPC.twee index f4b40d8d0..db3af9859 100644 --- a/src/Misc/CreateRandomNPC.twee +++ b/src/Misc/CreateRandomNPC.twee @@ -5,19 +5,23 @@ ageStage: ["young adult", "young adult", "young adult", "settled adult", "settled adult", "settled adult", "elderly"].random(), profession: Object.keys(lib.professions).random() }>> - - -- - -- - -- - -- <> +
+

$toolbox.randomNPC.name

+ <> is currently <> in the corner. + You strike up conversation with $toolbox.randomNPC.himher, and the $toolbox.randomNPC.descriptor introduces $toolbox.randomNPC.himherself as <>, <> <>. +
+ <> + <> +
\ No newline at end of file diff --git a/src/NPCGeneration/NPCProfile/Components/NPCHeader.twee b/src/NPCGeneration/NPCProfile/Components/NPCHeader.twee index 0afb23145..1ab60a8f7 100644 --- a/src/NPCGeneration/NPCProfile/Components/NPCHeader.twee +++ b/src/NPCGeneration/NPCProfile/Components/NPCHeader.twee @@ -1,33 +1,45 @@ :: NPCHeader [nobr] -

<> -<> +<> + <> <> <> -<> -<> -$currentNPC.title -<>$currentNPC.name

-<> - <>
-<
> - -<> -- - <> -<> <> <> +<> +

+ <> + $currentNPC.title + <> $currentNPC.name +

+ + <> + <> + <> + + <> -- + <> + <> + <> <> +> + <> + <> \ No newline at end of file diff --git a/src/NPCGeneration/NPCProfile/NPCProfile.twee b/src/NPCGeneration/NPCProfile/NPCProfile.twee index 66ed0c376..093cb3a4b 100644 --- a/src/NPCGeneration/NPCProfile/NPCProfile.twee +++ b/src/NPCGeneration/NPCProfile/NPCProfile.twee @@ -1,32 +1,82 @@ :: NPCProfile [nobr] -<> -<><>
<
> -

<><> $currentNPC.name<><><> is <> $currentNPC.malefemale $currentNPC.race. -<> is <> and <>, and has $currentNPC.eyes eyes<> and <>,<> with $currentNPC.skinColour skin. -The most notable physical trait of $currentNPC.firstName is that $currentNPC.heshe has $currentNPC.physicalTrait.

-

$currentNPC.firstName $currentNPC.trait. -<><> $currentNPC.vocalPattern. <> -<><> is <> <> -When $currentNPC.heshe is relaxed, $currentNPC.heshe is $currentNPC.calmTrait. In moments of stress, $currentNPC.heshe becomes $currentNPC.stressTrait. -Religion-wise, $currentNPC.firstName is <> of <><>. -

< 0>>Despite sexism against $currentNPC.himher, <>Perhaps due to sexism, <>$currentNPC.professionSuccess, with a background of being <>. -<> - <> belongs to the <> social class -<> - <> belongs to the $currentNPC.socialClass social class, but <> -<>.

-

$currentNPC.firstName currently has $currentNPC.pockets in $currentNPC.hisher pockets, and <> to $currentNPC.hisher name. <> lives on <>. -<>In combat, $currentNPC.heshe uses $currentNPC.weapon. <><>$currentNPC.firstName knows $currentNPC.knownLanguages[0] and <>. <> -<>$currentNPC.doesnt<> -<> - <> is $currentNPC.sexuality + + <> + +<> + + <> + +
+

+ + <> + <> $currentNPC.name + <> + <> + <> + is <> $currentNPC.malefemale $currentNPC.race. + <> is <> and <>, and has $currentNPC.eyes eyes + <> + and <>, + <> with $currentNPC.skinColour skin. + The most notable physical trait of $currentNPC.firstName is that $currentNPC.heshe has $currentNPC.physicalTrait. +

+

+ $currentNPC.firstName $currentNPC.trait. + <> + <> $currentNPC.vocalPattern. + <> + <> + <> is <> + <> +When $currentNPC.heshe is relaxed, $currentNPC.heshe is $currentNPC.calmTrait. +In moments of stress, $currentNPC.heshe becomes $currentNPC.stressTrait. +Religion-wise, $currentNPC.firstName is <><> of <><>. +

+ < 0>> + Despite sexism against $currentNPC.himher, + <> + Perhaps due to sexism, + <> + $currentNPC.professionSuccess, with a background of being <>. + + <> + <> belongs to the <> social class. + <> + <> belongs to the $currentNPC.socialClass social class, but <>. + <> +

+

+ $currentNPC.firstName currently has $currentNPC.pockets in $currentNPC.hisher pockets, + and <> to $currentNPC.hisher name. + <> + <> lives on <>. + <> + <> + In combat, $currentNPC.heshe uses $currentNPC.weapon. + <> + <> + $currentNPC.firstName knows $currentNPC.knownLanguages[0] and <>. + <> + <> + $currentNPC.doesnt + <> + + <> + <> $currentNPC.sexuality <> - , and has <>, <>. + , and has <>, <>. <> - <>$currentNPC.firstName has <>, <>. -<>

+ <> + $currentNPC.firstName has <>, <>. + <> +

<> -<>

$currentNPC.note

<
> +<> +

+ $currentNPC.note +

+<
> <> <> <> diff --git a/src/NPCGeneration/NPCProfile/components-edit/NPCProfileEdit.twee b/src/NPCGeneration/NPCProfile/components-edit/NPCProfileEdit.twee index 3c3eae0bd..788294f80 100644 --- a/src/NPCGeneration/NPCProfile/components-edit/NPCProfileEdit.twee +++ b/src/NPCGeneration/NPCProfile/components-edit/NPCProfileEdit.twee @@ -1,20 +1,31 @@ :: NPCProfileEdit [force-one-column nobr nofx] -<>

<><><> <>

+ +

+ <> + <> + <> + <> + +

+
<> <> - -- -<> -- -<> -- -<> + <> +/* <> - -<><> <><><><> is <> _gender _race. <> is and , and has eyes<> and <> ,<> with skin. -The most notable physical trait of <> is that <> has . +<> */ + +
+<> + <> +<><> is <> _gender _race. +<> is and , and has eyes<> and <> ,<> with skin. +The most notable physical trait of <> is that <> has . -<> . <><> . -<>When <> is relaxed, <> is . In moments of stress, <> becomes . <><> knows <> and <>.<> +<> . <><> . +<>When <> is relaxed, <> is . In moments of stress, <> becomes . <><> knows <> and <>.<> -<> is <>, with a background of being <>. <> currently has in <> pockets, and <> to <> name. In combat, <> uses . +<> is +<> + <> + <> + <> +, with a background of being +<> +<> + <> +<>. +<> currently has + in <> pockets, and <> to <> name. +/* In combat, <> uses . */ <