Skip to content

Commit

Permalink
Minor-fixes (#567)
Browse files Browse the repository at this point in the history
### Added
- Button to edit pantheon in dropdown religion percentage list
- Clearer delineation of what is and isn't Patron content.
- Automatic removal of analytics for local-run copies
- Automatic unlocking of Patreon content on local copies

### Changed
- Made Patreon paywall deactivate if being run locally.
- Fixed error with town editing
- Fixed sidebar popups not showing up
- Fixed error with faction editing
- Fixed error with editing town biome
  • Loading branch information
ryceg authored Apr 11, 2021
1 parent e73da11 commit 161a88c
Show file tree
Hide file tree
Showing 28 changed files with 357 additions and 147 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ 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.1

### Added
- Button to edit pantheon in dropdown religion percentage list
- Clearer delineation of what is and isn't Patron content.
- Automatic removal of analytics for local-run copies
- Automatic unlocking of Patreon content on local copies
- Prepositions for terrain, to make it sound more natural.

### Changed
- Made Patreon paywall deactivate if being run locally.
- Fixed error with town editing
- Fixed sidebar popups not showing up
- Fixed error with faction editing
- Fixed error with editing town biome
- Fixed local / online hosting images error (hopefully)

## 2.8

### Added
Expand Down
3 changes: 2 additions & 1 deletion lib/buildings/deleteBuildingRelationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { NPC } from '../npc-generation/_common'
import { Town } from '../town/_common'
import { Building } from './_common'
import { findReciprocalRelationships } from './findReciprocalRelationships'
import { Faction } from '@lib'

export function deleteReciprocalRelationship (town: Town, building: Building | null, npc: NPC | null) {
export function deleteReciprocalRelationship (town: Town, building: Building | Faction | null, npc: NPC | null) {
const relationships = findReciprocalRelationships(town, building, npc, 'building')

for (const relationship of relationships) {
Expand Down
35 changes: 19 additions & 16 deletions lib/religion/getPantheon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,62 @@ import { Town } from '../../lib/town/_common'
import { compileWeightToPercentile, getDeityPercentagesList, getTownDeityWeightings } from './createTownReligion'
import { Pantheon, religion } from './religion'

export const getDeity = (town: Town, deity: string) => {
export const getDeity = (town: Town, deity: string, customPantheon?: Pantheon) => {
return findInArray(
getPantheon(town).gods, 'name', deity)
getPantheon(town, customPantheon).gods, 'name', deity)
}

export const getPantheon = (town: Town): Pantheon => {
if (isUsingCustomPantheon(town)) return getCustomPantheon(town)
export const getPantheon = (town: Town, customPantheon?: Pantheon): Pantheon => {
if (isUsingCustomPantheon(town)) return getCustomPantheon(town, customPantheon)
return religion.pantheon[town.religion.pantheon]
}

export const getPantheonNames = (town: Town) => {
return Object.keys(getAllPantheons(town))
export const getPantheonNames = (town: Town, customPantheon?: Pantheon) => {
return Object.keys(getAllPantheons(town, customPantheon))
}

export const getAllPantheons = (town: Town) => {
export const getAllPantheons = (town: Town, customPantheon?: Pantheon) => {
const pantheons: Record<string, Pantheon> = Object.assign({}, religion.pantheon)
if (seeIfCustomPantheonExists(town)) pantheons[getCustomPantheon(town).name] = getCustomPantheon(town)
if (seeIfCustomPantheonExists(town, customPantheon)) pantheons[getCustomPantheon(town, customPantheon).name] = getCustomPantheon(town, customPantheon)
return pantheons
}

/** If the pantheon being used doesn't exist in the data, it's obviously custom. */
export const isUsingCustomPantheon = (town: Town) => {
if (religion.pantheon[town.religion.pantheon]) return false
return true
}

export const seeIfCustomPantheonExists = (town: Town): boolean => {
export const seeIfCustomPantheonExists = (town: Town, customPantheon?: Pantheon): boolean => {
if (customPantheon) return true
if (town.religion.customPantheon) return true
return false
}

export const getCustomPantheon = (town: Town): Pantheon => {
export const getCustomPantheon = (town: Town, customPantheon?: Pantheon): Pantheon => {
if (town.religion.customPantheon) return town.religion.customPantheon
if (customPantheon) return customPantheon
throw new Error('Custom panthon not defined!')
}

export const getPantheonPercentages = (town: Town) => {
export const getPantheonPercentages = (town: Town, customPantheon?: Pantheon) => {
console.log('Getting pantheon percentages...')
return compileWeightToPercentile(
getTownDeityWeightings(town, getPantheon(town).gods)
getTownDeityWeightings(town, getPantheon(town, customPantheon).gods)
)
}

export const getCulledPantheonPercentages = (town: Town) => {
export const getCulledPantheonPercentages = (town: Town, customPantheon?: Pantheon) => {
console.log('Getting pantheon percentages...')
const temp = compileWeightToPercentile(
getTownDeityWeightings(town, getPantheon(town).gods)
getTownDeityWeightings(town, getPantheon(town, customPantheon).gods)
)
return Object.fromEntries(
Object.entries(temp).filter(([, value]) => value > 0))
}

export const getPantheonPercentagesReadout = (town: Town) => {
const deities: [string, number][] = getDeityPercentagesList(getPantheonPercentages(town))
export const getPantheonPercentagesReadout = (town: Town, customPantheon?: Pantheon) => {
const deities: [string, number][] = getDeityPercentagesList(getPantheonPercentages(town, customPantheon))
let text = ''
for (const [deity, percentage] of deities) {
if (percentage > 0) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/badges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export const badges = {
},
commitsSinceLastUpdate: {
alt: 'Commits since last update',
source: '/github/commits-since/ryceg/Eigengrau-s-Essential-Establishment-Generator/2.7',
source: '/github/commits-since/ryceg/Eigengrau-s-Essential-Establishment-Generator/2.8',
logo: 'github',
color: '6cc644'
},
Expand Down
18 changes: 14 additions & 4 deletions lib/src/getIllustration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,31 @@ type Illustration =
export const getIllustration = (illustration: Illustration, alt: string) => {
let img = '<img '
img += 'id="illustration" '
img += `src="../src/Resources/img/hero/${illustration}.jpg" `
const path = getPath()

img += `src="${path}src/Resources/img/hero/${illustration}.jpg" `
// If it's in production, then we can add the srcset options, otherwise we might as well omit it.
if (process.env.NODE_ENV === 'production' && location.origin !== 'file://') img += `srcset="../src/Resources/img/hero/${illustration}-x360.jpg 360w, ../src/Resources/img/hero/${illustration}-x411.jpg 411w, ../src/Resources/img/hero/${illustration}-x500.jpg 500w, ../src/Resources/img/hero/${illustration}-x576.jpg 576w, ../src/Resources/img/hero/${illustration}-x768.jpg 768w, ../src/Resources/img/hero/${illustration}-x992.jpg 992w, ../src/Resources/img/hero/${illustration}-x1200.jpg 1200w, ../src/Resources/img/hero/${illustration}.jpg" `
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" `
img += `alt="${alt || `An image depicting ${lib.articles.output(illustration)}, created by artist Juho Huttunen.`}" `
img += '/>'
return img
}

const getPath = () => {
if (process.env.NODE_ENV === 'production' && location.origin !== 'file://') {
return './'
}
return '../'
}

// It would obviously be preferable to output actual <img>s instead of having it render via SugarCube.
// Unfortunately, I am not a clever man, and cannot figure it out.
export const getImage = (illustration: Illustration) => {
const img = document.createElement('img')
const path = getPath()
img.id = 'illustration'
img.src = `../src/Resources/img/hero/${illustration}.jpg`
img.srcset = `../src/Resources/img/hero/${illustration}-x360.jpg 360w, ../src/Resources/img/hero/${illustration}-x411.jpg 411w, ../src/Resources/img/hero/${illustration}-x500.jpg 500w, ../src/Resources/img/hero/${illustration}-x576.jpg 576w, ../src/Resources/img/hero/${illustration}-x768.jpg 768w, ../src/Resources/img/hero/${illustration}-x992.jpg 992w, ../src/Resources/img/hero/${illustration}-x1200.jpg 1200w, ../src/Resources/img/hero/${illustration}.jpg`
img.src = `${path}src/Resources/img/hero/${illustration}.jpg`
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`
img.alt = `An image depicting ${lib.articles.output(illustration)}, created by artist Juho Huttunen.`
return img
}
Expand Down
Loading

0 comments on commit 161a88c

Please sign in to comment.