Skip to content

Commit 0b1a500

Browse files
authored
Merge pull request #586 from ryceg:Fix-life-events
Add custom images
2 parents 95e353b + 75eeba8 commit 0b1a500

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+689
-376
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
## 2.8.5
88

9+
### Added
10+
- Edit button to buildings that have an editor (it's still rather terrible, but at least now it's more visible)
11+
- Custom image uploading for Hero patrons accessible in the settings.
12+
13+
### Changed
14+
- Fixed issue with Patreon thanks list sometimes breaking.
15+
- Modified formatting
16+
- Shifted notification down slightly so it does not collide with the header
17+
- Fixed an issue with Tippy not initialising for elements created in a table.
18+
19+
### Removed
20+
- Obsolete 'Show Sliders' setting.
21+
22+
## 2.8.5
23+
924
### Added
1025
- Disable NSFW setting which removes slavery and brothels from being generated.
1126
- Unlocked GMBinder exporting for everyone because we hit 100 Patrons! Thanks!

lib/buildings/_common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface Location {
66
objectType: 'building'
77
/** The type of building- 'castle', 'townSquare', 'generalStore', etc. */
88
type: string
9+
buildingType: string
910
passageName?: string
1011
parentKey?: string
1112
name?: string

lib/npc-generation/createDescriptors.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { articles } from '../src/articles'
22
import { NPC } from './_common'
33

4+
const getHumanOrRaceDescription = (npc: NPC) => {
5+
if (npc.race === 'human') return `${lib.random([npc.weight, npc.height])} ${npc.manwoman}`
6+
return `${lib.random([npc.weight, npc.height])} ${npc.malefemale} ${npc.raceName}`
7+
}
8+
49
export function createDescriptors (npc: NPC): string[] {
510
console.log(`assigning descriptors to ${npc.name}...`)
611

@@ -9,9 +14,9 @@ export function createDescriptors (npc: NPC): string[] {
914
* @see https://github.com/ryceg/Eigengrau-s-Essential-Establishment-Generator/wiki/Style-Guide#adjectives
1015
*/
1116
const descriptors = [
12-
`${npc.age || npc.ageStage} ${npc.raceName}`,
17+
`${npc.age || npc.ageStage} ${npc.raceName} with ${npc.physicalTrait}`,
1318
`${npc.skinColour} skinned ${lib.random([npc.weight, npc.height])} ${npc.raceName}`,
14-
`${lib.random([npc.weight, npc.height])} ${npc.raceName}`,
19+
`${getHumanOrRaceDescription(npc)} with ${npc.physicalTrait}`,
1520
`${lib.random([npc.height, npc.age])} ${npc.gender} with ${npc.physicalTrait}`
1621
]
1722

@@ -22,11 +27,12 @@ export function createDescriptors (npc: NPC): string[] {
2227
default:
2328
switch (npc.race) {
2429
case 'human':
25-
descriptors.push(`${lib.random([npc.weight, npc.height])} ${npc.manwoman}`)
2630
break
2731
default:
28-
descriptors.push(`${lib.random([npc.weight, npc.height])} ${npc.malefemale} ${npc.raceName}`)
29-
descriptors.push(`${lib.random([npc.weight, npc.height])} ${lib.raceTraits[npc.race].raceWords.raceAdjective} ${npc.manwoman}`)
32+
descriptors.push(
33+
getHumanOrRaceDescription(npc),
34+
`${lib.random([npc.weight, npc.height])} ${lib.raceTraits[npc.race].raceWords.raceAdjective} ${npc.manwoman}`
35+
)
3036
}
3137
}
3238

lib/npc-generation/familyRelationships.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { roads } from '../town/roads'
22
import { Town } from '../town/_common'
33
import { Family, NPC } from './_common'
4+
import { random } from '../src/random'
45

56
export const familyRelationships = {
67
/**
@@ -107,15 +108,14 @@ export function createFamily (town: Town, npc: NPC) {
107108
road: ''
108109
}
109110
}
110-
createFamilyHouse(town, family)
111111
town.families[key] = family
112112
npc.family = key
113113
}
114114

115115
export function createFamilyHouse (town: Town, family: Family) {
116116
const road = town.roads[family.home.road] ||
117117
roads.findExisting(town) ||
118-
lib.random(Object.keys(town.roads))
118+
random(Object.keys(town.roads))
119119
// roads.assign(town)
120120

121121
for (const member in family.members) {

lib/religion/religion.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ export interface Deity {
262262
* @usage 'Hades resides in ______'
263263
*/
264264
realm?: string
265+
customImage?: URL
265266
followers: Partial<Followers>
266267
/**
267268
* If a deity particularly embodies a virtue or vice, it can be specified.

lib/src/createMagic.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { magicData, MagicType } from './magicData'
33
import { random } from './random'
44
import { assign } from './utils'
55

6-
export function createMagic <T extends MagicType> (type: T | 'ring') {
6+
export function createMagic <T extends MagicType> (type: T | 'ring'): MagicItem {
77
console.log(`Type: ${type}`)
88

99
if (type === 'ring') {
@@ -33,3 +33,13 @@ export function createMagic <T extends MagicType> (type: T | 'ring') {
3333
console.log(magic)
3434
return magic
3535
}
36+
37+
export interface MagicItem {
38+
type: string
39+
description: string
40+
name: string
41+
prefix?: string
42+
suffix?: string
43+
prefixProperty?: string
44+
suffixProperty?: string
45+
}

lib/src/createRing.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { MagicItem } from '@lib'
12
import { articles } from './articles'
23
import { getRandomValue } from './getRandomValue'
34
import { random } from './random'
@@ -9,7 +10,21 @@ interface Options {
910
activation: string
1011
}
1112

12-
export function createRing (base?: Partial<Options>) {
13+
interface MagicRing extends MagicItem {
14+
works: string
15+
material: string
16+
decoration: string
17+
gemstone: string
18+
intendedowner: string
19+
importance: string
20+
setting: string
21+
cut: string
22+
power: string
23+
cost: string
24+
activation: string
25+
}
26+
27+
export function createRing (base?: Partial<Options>): MagicRing {
1328
const ringData = createRingData()
1429

1530
const ring = {
@@ -193,6 +208,11 @@ export function createRing (base?: Partial<Options>) {
193208
])
194209
})
195210

211+
assign(ring, {
212+
type: 'ring',
213+
name: `${ring.gemstone} Ring`,
214+
description: ring.firstOutputs
215+
})
196216
return ring
197217
}
198218

lib/src/getIllustration.ts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
1-
import { Town } from '../town/_common'
2-
31
type Illustration =
42
| 'general-store-illustration'
53
| 'tavern-illustration'
64
| 'town-illustration'
75
| 'city-illustration'
86

9-
export const getIllustration = (illustration: Illustration, alt: string) => {
10-
let img = '<img '
11-
img += 'id="illustration" '
12-
const path = getPath()
13-
14-
img += `src="${path}src/Resources/img/hero/${illustration}.jpg" `
15-
// If it's in production, then we can add the srcset options, otherwise we might as well omit it.
16-
if (process.env.NODE_ENV === 'production' && location.origin !== 'file://') img += `srcset="${path}src/Resources/img/hero/${illustration}-x360.jpg 360w, ${path}src/Resources/img/hero/${illustration}-x411.jpg 411w, ${path}src/Resources/img/hero/${illustration}-x500.jpg 500w, ${path}src/Resources/img/hero/${illustration}-x576.jpg 576w, ${path}src/Resources/img/hero/${illustration}-x768.jpg 768w, ${path}src/Resources/img/hero/${illustration}-x992.jpg 992w, ${path}src/Resources/img/hero/${illustration}-x1200.jpg 1200w, ${path}src/Resources/img/hero/${illustration}.jpg" `
17-
img += `alt="${alt || `An image depicting ${lib.articles.output(illustration)}, created by artist Juho Huttunen.`}" `
18-
img += '/>'
19-
return img
20-
}
21-
227
const getPath = () => {
238
if (process.env.NODE_ENV === 'production' && location.origin !== 'file://') {
249
return './'
2510
}
2611
return '../'
2712
}
2813

29-
// It would obviously be preferable to output actual <img>s instead of having it render via SugarCube.
30-
// Unfortunately, I am not a clever man, and cannot figure it out.
31-
export const getImage = (illustration: Illustration) => {
14+
const addLocalSourceSet = (illustration: Illustration, sizes: string[] = ['360', '411', '500', '576', '768', '992', '1200']) => {
15+
let img = ''
16+
const path = getPath()
17+
for (const size of sizes) {
18+
img += `${path}src/Resources/img/hero/${illustration}-x${size}.jpg ${size}w, `
19+
}
20+
return img
21+
}
22+
23+
export const getCustomImage = (url: URL) => {
24+
const img = document.createElement('img')
25+
img.id = 'illustration'
26+
img.src = url as unknown as string
27+
img.alt = 'A custom-defined image.'
28+
return img.outerHTML
29+
}
30+
31+
export const getLocalImage = (illustration: Illustration) => {
3232
const img = document.createElement('img')
3333
const path = getPath()
3434
img.id = 'illustration'
3535
img.src = `${path}src/Resources/img/hero/${illustration}.jpg`
36-
img.srcset = `${path}src/Resources/img/hero/${illustration}-x360.jpg 360w, ${path}src/Resources/img/hero/${illustration}-x411.jpg 411w, ${path}src/Resources/img/hero/${illustration}-x500.jpg 500w, ${path}src/Resources/img/hero/${illustration}-x576.jpg 576w, ${path}src/Resources/img/hero/${illustration}-x768.jpg 768w, ${path}src/Resources/img/hero/${illustration}-x992.jpg 992w, ${path}src/Resources/img/hero/${illustration}-x1200.jpg 1200w, ${path}src/Resources/img/hero/${illustration}.jpg`
36+
if (process.env.NODE_ENV === 'production' && location.origin !== 'file://') img.srcset = `${addLocalSourceSet(illustration)} ${path}src/Resources/img/hero/${illustration}.jpg`
3737
img.alt = `An image depicting ${lib.articles.output(illustration)}, created by artist Juho Huttunen.`
38-
return img
39-
}
40-
41-
export const townOrCity = (town: Town) => {
42-
if (town.type === 'city' || town.type === 'town') return 'city-illustration'
43-
return 'town-illustration'
38+
return img.outerHTML
4439
}

lib/town/_common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export interface TownProfessions extends Profession {
6868
}
6969

7070
export interface Town extends TownBasics {
71+
localImage: string
7172
taxes: {
7273
welfare: number
7374
military: number

lib/town/townRender.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import { Town } from './_common'
22
import { getPolice } from './getPolice'
33

4+
export const townOrCity = (town: Town) => {
5+
if (town.type === 'city' || town.type === 'town') return 'city-illustration'
6+
return 'town-illustration'
7+
}
8+
49
export function townRender (town: Town) {
510
console.log(`Rendering ${town.name}...`)
611

12+
town.localImage = townOrCity(town)
13+
714
town.roll.guardFunding = 0
815

916
const police = getPolice(town.factions)

0 commit comments

Comments
 (0)