Skip to content

Commit

Permalink
Minor-Fixes (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryceg committed Jun 13, 2021
1 parent 4ba2c75 commit f4937a5
Show file tree
Hide file tree
Showing 35 changed files with 983 additions and 966 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/release.yml
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions global.d.ts
Expand Up @@ -22,3 +22,5 @@ declare function gtag(event: string, action: string, data: {
event_action?: string,
value?: string
}): void

declare module 'rita'
5 changes: 3 additions & 2 deletions lib/npc-generation/familyRelationships.ts
Expand Up @@ -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) {
Expand All @@ -129,5 +129,6 @@ export function createFamilyHouse (town: Town, family: Family) {
road: road.key
}
})
console.log('Assigned a house!')
// return family as Family
}
24 changes: 24 additions & 0 deletions lib/npc-generation/professions.ts
Expand Up @@ -2524,6 +2524,30 @@ export const professions: Record<string, Profession> = {
}
}
},
'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',
Expand Down
1 change: 1 addition & 0 deletions lib/npc-generation/raceTraits.ts
Expand Up @@ -141,6 +141,7 @@ export const raceTraits: Record<RaceName, RaceTrait> = {
bmiModifier: 500,
ageTraits: {
'ageDescriptors': [
[400, 'ancient'],
[300, 'ancient'],
[250, 'incredibly elderly'],
[200, 'vulnerably elderly'],
Expand Down
18 changes: 9 additions & 9 deletions 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 _____'
Expand Down Expand Up @@ -279,18 +279,17 @@ export const traitDescriptions: Record<Virtues, ThresholdTable<string>> = {
[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]) {
Expand All @@ -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 })
Expand Down
9 changes: 4 additions & 5 deletions 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',
Expand Down Expand Up @@ -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)
Expand Down
40 changes: 34 additions & 6 deletions lib/src/arpa.ts
@@ -1,3 +1,5 @@
import RiTa from 'rita'

interface RitaAnalyze {
phones: string
pos: string
Expand All @@ -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<string, string> = {
// 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'],
Expand Down Expand Up @@ -413,8 +442,7 @@ export function ArpabetToIpa (analyze: RitaAnalyze) {
// type: 'Syllabification'
// }
// }
const str = analyze.phones
const ArpabetToIpaTable: Record<string, string> = {
const arpabetToIpaTable: Record<string, string> = {
AA: 'ɑ',
AE: 'æ',
AH: 'ʌ',
Expand Down Expand Up @@ -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}/.`
}
9 changes: 4 additions & 5 deletions lib/src/findProfession.ts
Expand Up @@ -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') {
Expand All @@ -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') {
Expand Down
1 change: 0 additions & 1 deletion lib/town/roads.ts
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions main.ejs
Expand Up @@ -15,9 +15,6 @@
<!-- Polyfills for browser compatibility -->
<script async src="https://unpkg.com/core-js-bundle@3.0.1/minified.js"></script>


<script src="https://unpkg.com/rita"></script>

<!-- Bundle -->
<script defer src="main.js"></script>

Expand Down
5 changes: 3 additions & 2 deletions package.json
@@ -1,15 +1,15 @@
{
"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": {
"type": "git",
"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"
},
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/Alchemist/AlchemistOutput.twee
Expand Up @@ -4,7 +4,7 @@
<<set $building to lib.findInArray($town.buildings, "key", $currentPassage.key)>>
<<set $building.brew to lib.createAlchemy({ type: "brewing potion" })>><<set $currentPassage.availableRelationships to lib.alchemistData.get.customers>>
<<set $associatedNPC to $npcs[$building.associatedNPC.key]>>
<<button "Edit $building.name" $building.initPassage>><</button>>
<span class='flex-line'><<button "Edit $building.name" $building.initPassage>><</button>></span>
<h1 class="interactive-only">$building.name</h1><span @id="$building.key"></span><p>You enter $building.name, <<print lib.articles.output($building.structure.alchemistDescriptor)>>. <<print lib.closestMatch(lib.alchemistData.get.lookAround($building), 'note', 'cleanliness', 'wealth', $building.roll.cleanliness, $building.roll.wealth)>> There is a chemist behind the shop counter currently <<print $associatedNPC.idle.random()>>.</p>
<section><h3>Chemist</h3><p>The $associatedNPC.weight chemist <<print $associatedNPC.greeting.random()>> <<print ['when you come inside', 'after finishing with another customer', 'as soon as you come through the door', 'when you come up to the counter', 'while you look around'].random()>>. <<print $associatedNPC.heshe.toUpperFirst()>> introduces $associatedNPC.himherself as <<profile $associatedNPC>>, the $associatedNPC.owner of the shop, and asks what $associatedNPC.heshe can do for you.</p>
<<linkreplace "Talk with $associatedNPC.name" t8n>>
Expand Down
2 changes: 1 addition & 1 deletion src/Blacksmith/SmithyOutput.twee
Expand Up @@ -4,7 +4,7 @@
<<set $building to lib.findInArray($town.buildings, "key", $currentPassage.key)>>
<<set $associatedNPC to $npcs[$building.associatedNPC.key]>>
<<set $currentPassage.availableRelationships to lib.smithyData.get.customers>>
<<button "Edit $building.name" $building.initPassage>><</button>>
<span class='flex-line'><<button "Edit $building.name" $building.initPassage>><</button>></span>
<h1 class="interactive-only">$building.name</h1><span @id="$building.key"></span>
<p>You make your way down <<print lib.createTippyFull($town.roads[$building.road].description, $town.roads[$building.road].name)>>, and enter $building.name and see that inside, the $building.structure.descriptor is $building.size. <<print lib.closestMatch(lib.smithyData.get.lookAround($building), 'note', 'cleanliness', 'wealth', $building.roll.cleanliness, $building.roll.wealtYh)>> There is a blacksmith currently <<print $associatedNPC.idle.random()>>.</p>
<p><<print lib.closestMatch(lib.smithyData.get.expertise($building), 'note', 'expertise', 'wealth', $building.roll.expertise, $building.roll.wealth)>>
Expand Down
4 changes: 2 additions & 2 deletions src/Buildings/GenericPassage.twee
@@ -1,6 +1,6 @@
:: GenericPassage
<<include "PrintImage">>
<<set $building to lib.findInArray($town.buildings, "key", $currentPassage.key)>><h1 class="interactive-only">$building.name</h1><span @id="$building.key"></span>
<<set $building to lib.findInArray($town.buildings, "key", $currentPassage.key)>><<include "PrintImage">>
\<h1 class="interactive-only">$building.name</h1><span @id="$building.key"></span>
<<for _i to 0; _i < $building.PassageFormat.length; _i++>>
<<print $building.PassageFormat[_i]>>
<</for>>
6 changes: 4 additions & 2 deletions src/Factions/FactionProfile.twee
Expand Up @@ -3,13 +3,15 @@
<<set $currentPassage to $town.factions[$currentPassage.key]>><<run console.log($currentPassage)>>
<<set $currentPassage.availableRelationships to lib.factionData.types[$currentPassage.type].members.professions>>
<h1 class="interactive-only">$currentPassage.name</h1><span @id="$currentPassage.key"></span>
<<button "Edit $currentPassage.name" FactionSliders>>
<span class='flex-line'>
<<button "Edit $currentPassage.name" FactionSliders>>
<<run setup.history($currentPassage, "FactionSliders", "Editing " + $currentPassage.name)>>
<</button>>
</span>
<p><<print lib.firstCharacter($currentPassage.name)>> is <<print lib.articles.output($currentPassage.type)>> $currentPassage.wordNoun. It's $currentPassage.age, and the $currentPassage.size faction has <<print lib.articles.output($currentPassage.reputation)>> reputation, and is motivated by $currentPassage.motivation. They are $currentPassage.misc.</p>
<<if $currentPassage.isPolicing>><<include "PolicingFaction">><</if>>
<<include "FactionGovernance">>
<p><h3>Members</h3>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.</p>
<p><h3>Members</h3>Members of $currentPassage.name are identifiable by <<print $currentPassage.membersTrait || $currentFaction.membersTrait>>. Membership requires $currentPassage.joiningRequirement, and costs $currentPassage.joiningFee. The initiation into $currentPassage.name involves $currentPassage.joiningInitiation.</p>
<<linkreplace "<h4>Create Members</h4>" t8n>><<include "CreateFactionNpc">><</linkreplace>>
<<include "FactionRelationshipsTable">>
<<include "FactionResources">>
Expand Down
2 changes: 1 addition & 1 deletion src/GeneralStore/GeneralStoreOutput.twee
Expand Up @@ -3,7 +3,7 @@
<<set $building to lib.findInArray($town.buildings, "key", $currentPassage.key)>>
<<set $associatedNPC to $npcs[$building.associatedNPC.key]>>
<<set $currentPassage.availableRelationships to lib.generalStore.get.customers>>
<<button "Edit $building.name" $building.initPassage>><</button>>
<span class='flex-line'><<button "Edit $building.name" $building.initPassage>><</button>></span>
<h1 class="interactive-only">$building.name</h1><span @id="$building.key"></span>
<p>You make your way down <<print lib.createTippyFull($town.roads[$building.road].description, $town.roads[$building.road].name)>>, and enter $building.structure.descriptor and see that inside, the $building.size building is $building.cleanliness.<<if $building.clutter>> $building.clutter<</if>> You notice $building.note. The store's shopkeep is currently $building.idle.</p>
<h3>Shopkeeper</h3>
Expand Down
2 changes: 1 addition & 1 deletion src/MiniEstablishments/Guardhouse/GuardhouseOutput.twee
Expand Up @@ -4,7 +4,7 @@
<<set $associatedNPC to $npcs[$currentPassage.associatedNPC.key]>>
<<set $currentPassage.availableRelationships to lib.guardhouseData.get.customers>>
<<include "PrintImage">>
<h1 class="interactive-only">$currentPassage.name</h1><span @id="$building.key"></span><p>You make your way down <<print lib.createTippyFull($town.roads[$currentPassage.road].description, $town.roads[$currentPassage.road].name)>>, and enter $currentPassage.name $currentPassage.structure.descriptor. $currentPassage.name is known for $currentPassage.notableFeature</p>
<h1 class="interactive-only">$currentPassage.name</h1><span @id="$currentPassage.key"></span><p>You make your way down <<print lib.createTippyFull($town.roads[$currentPassage.road].description, $town.roads[$currentPassage.road].name)>>, and enter $currentPassage.name $currentPassage.structure.descriptor. $currentPassage.name is known for $currentPassage.notableFeature</p>
<p>It is run by <<profile $town.factions[$currentFaction.key]>>, who are $currentPassage.expertise.
At the moment, <<print lib.weightedRandomFetcher($town, lib.guardhouseData.get.event($town, $currentPassage), $currentPassage, undefined)>></p>
<<include "PolicingFaction">>
Expand Down

0 comments on commit f4937a5

Please sign in to comment.