Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert-general-store #489

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/GeneralStore/JS/createGeneralStore.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { articles, Building, createBuildingRelationship, createStructure, defineRollDataGetter, generalStoreModifiers, NPC, Town } from '@lib'

interface Options {
newBuilding?(town: Town, type?: string): Building
npc?: Partial<NPC>
}

// uses setup.createNPC, setup.createGeneralStoreName
setup.createGeneralStore = (town, opts = {}) => {
const createBuilding = opts.newBuilding || lib.createBuilding
export const createGeneralStore = (town: Town, opts: Options = {}) => {
const createBuilding = opts.newBuilding || createBuilding
// @ts-ignore
const createShopkeep = opts.newShopkeep || setup.createNPC

const generalStore = createBuilding(town, 'generalStore')
Expand All @@ -11,27 +20,27 @@ setup.createGeneralStore = (town, opts = {}) => {
greeting: ['nods at you', 'welcomes you warmly', 'smiles and greets you', 'raises a hand with a wave', 'checks you out for just a moment before smiling at you'],
owner: ['owner', 'caretaker', 'proud owner', 'proprietor', 'current owner', 'manager', 'assistant manager', 'acting manager'].random()
}, opts.npc))
lib.createBuildingRelationship(town, generalStore, generalStore.associatedNPC, { relationship: 'owner', reciprocalRelationship: 'business' })
createBuildingRelationship(town, generalStore, generalStore.associatedNPC, { relationship: 'owner', reciprocalRelationship: 'business' })
Object.assign(generalStore, {
note: lib.generalStore.get.note(generalStore),
shopkeepNote: lib.generalStore.get.shopkeepNote(generalStore),
say: lib.generalStore.get.say(generalStore),
note: generalStore.get.note(generalStore),
shopkeepNote: generalStore.get.shopkeepNote(generalStore),
say: generalStore.get.say(generalStore),
wordNoun: ['general store', 'shop'].random(),
crud: lib.generalStore.crud.random(),
idle: lib.generalStore.idle.random(),
crud: generalStore.crud.random(),
idle: generalStore.idle.random(),
notableFeature: 'wide range of goods on sale',
passageName: 'generalStoreOutput',
initPassage: 'InitgeneralStore',
buildingType: 'generalStore'
})
lib.createStructure(town, generalStore)
generalStore.structure.descriptor = `${lib.articles.output(generalStore.structure.material.wealth)} ${generalStore.structure.material.noun} ${generalStore.wordNoun} with ${lib.articles.output(generalStore.structure.roof.verb)} roof`
createStructure(town, generalStore)
generalStore.structure.descriptor = `${articles.output(generalStore.structure.material.wealth)} ${generalStore.structure.material.noun} ${generalStore.wordNoun} with ${articles.output(generalStore.structure.roof.verb)} roof`
setup.createGeneralStoreName(town, generalStore)
lib.generalStoreModifiers(town, generalStore)
generalStoreModifiers(town, generalStore)

const props = ['wealth', 'cleanliness', 'size', 'expertise']
for (const propName of props) {
lib.defineRollDataGetter(generalStore, lib.generalStore.rollData[propName].rolls, propName)
defineRollDataGetter(generalStore, generalStore.rollData[propName].rolls, propName)
}

if (generalStore.roll.cleanliness <= 40) {
Expand All @@ -41,7 +50,7 @@ setup.createGeneralStore = (town, opts = {}) => {
`In one corner of the store there is a large pile of ${generalStore.crud}.`,
`Several bins seemed to be cluttered with ${generalStore.crud}.`].random()
}
// lib.generalStoreRenders(generalStore)
// generalStoreRenders(generalStore)
console.log(generalStore)
console.groupEnd()
return generalStore
Expand Down
3 changes: 0 additions & 3 deletions src/GeneralStore/JS/createGeneralStoreName.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { GeneralStore, Town } from '@lib'
import { random } from '../../../lib/src/random'

// @ts-ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use a ts-ignore here?

// uses setup.createNPC
setup.createGeneralStoreName = (town, generalStore) => {
export const createGeneralStoreName = (town: Town, generalStore: GeneralStore) => {
const adjective = ['Dependable', 'Reliable', 'Expendable', 'Indispensible', 'Incomparable', 'Incredible', 'Excellent', 'Important', 'Cheap', 'Affordable', 'Affable', 'Discount', 'Low-Cost', 'Fancy'].random()
const noun = ['Mount', 'Saddle', 'Guild', 'Fangs', 'Man', 'Pardon', 'Pleasure', 'Belt', 'Staff', 'Shield', 'Prince', 'Master', 'Servant', 'Meal', 'Prince', 'Favor', 'Love', 'Word', 'Scribe', 'Apprentice', 'Acolyte', 'Dress', 'Goddess', 'God', 'Gold', 'Purse', 'Trap', 'King', 'Son', 'Sister', 'Mother', 'Daughter', 'Cry', 'Shout', 'Cupboard', 'Pantry', 'Queen', 'Wealth', 'Star', 'Void', 'Woman', 'Man', 'Whore', 'Butcher', 'Anvil', 'Tome', 'Sacrifice', 'Armor', 'Cup', 'Pot', 'Stove', 'Stool', 'Princess', 'Chain', 'Sword', 'Pork', 'Grain', 'Tooth', 'Lance', 'Axe', 'Scabbard', 'Knife', 'Dagger', 'Spear', 'Bow', 'Crossbow', 'Quarterstaff', 'Staff', 'Fire', 'Ice', 'Wind', 'Earth', 'Water', 'Stone', 'Ladle', 'Monastery', 'Chalice', 'Goblet', 'Dungeon', 'Lust', 'Lantern', 'Bone', 'Life', 'Stone', 'Mistress', 'Mind', 'Treasure', 'Barter', 'Armorer', 'Butler', 'Page', 'Tome', 'Feather', 'Shadow', 'Friend', 'Labyrinth', 'Mountain', 'Hope', 'Boot', 'Gauntlet'].random()
const family = ['son', 'daughter', 'brother', 'sister', 'uncle', 'aunt', 'father', 'friend', 'family', 'employee'].random()
const family = random(['son', 'daughter', 'brother', 'sister', 'uncle', 'aunt', 'father', 'friend', 'family', 'employee'])
const rider = ['Shop', 'Bazaar', 'Convenience Store', 'Trading Post', 'Warehouse', 'Antiquerie', 'Adventure Supplier', 'Supplier', 'Goods', 'Goods and Bads', 'Stock Shop', 'Wares'].random()
const professions = ['shopkeep', "shopkeep's assistant", "shopkeep's assistant", "shopkeep's assistant"]

Expand Down Expand Up @@ -128,14 +133,20 @@ setup.createGeneralStoreName = (town, generalStore) => {
break
case 6:
generalStore.name = lib.toTitleCase(`The ${noun} and ${family.toUpperFirst()}`)
// @ts-ignore
generalStore.assistant = setup.createNPC(town, fam[family])
// @ts-ignore
setup.createRelationship(town, associatedNPC, generalStore.assistant, family,
// @ts-ignore
town.npcRelations[generalStore.assistant.key].filter(r => r.targetNpcKey === associatedNPC.key)[0]?.relation)
break
case 7:
generalStore.name = lib.toTitleCase(`${associatedNPC.firstName} and ${family.toUpperFirst()}`)
// @ts-ignore
generalStore.assistant = setup.createNPC(town, fam[family])
// @ts-ignore
setup.createRelationship(town, associatedNPC, generalStore.assistant, family,
// @ts-ignore
town.npcRelations[generalStore.assistant.key].filter(r => r.targetNpcKey === associatedNPC.key)[0]?.relation)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract to a variable, since it's such a long line. Or even better, to a function since it's repeated in multiple places.

break
default:
Expand Down
8 changes: 7 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { deleteNPC, deleteThrowawayNPCs } from './NPCGeneration/deleteNPC'
import { getLifeEvents } from './NPCGeneration/getLifeEvents'
import { graveStone } from './World/graveStone'
import { urlSeed } from './World/urlSeed'
import { createGeneralStore } from './GeneralStore/JS/createGeneralStore'
import { createGeneralStoreName } from './GeneralStore/JS/createGeneralStoreName'

declare global {
interface Setup {
Expand Down Expand Up @@ -73,6 +75,8 @@ declare global {
getPriceMod: typeof getPriceMod
graveStone: typeof graveStone
urlSeed: typeof urlSeed
createGeneralStore: typeof createGeneralStore
createGeneralStoreName: typeof createGeneralStoreName
}
}

Expand Down Expand Up @@ -113,7 +117,9 @@ Object.assign(setup, {
deleteThrowawayNPCs,
getLifeEvents,
graveStone,
urlSeed
urlSeed,
createGeneralStore,
createGeneralStoreName
})

/**
Expand Down