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 docks #568

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
57 changes: 49 additions & 8 deletions src/Docks/docks.d.ts → lib/docks/_common.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Ship } from './createDocks'
import { Town, NPC } from '@lib'
import { Building } from 'lib/buildings/_common'

export interface Setup {
initDocks(): void
docks: {
// TODO DocksData is currently not being used.
export interface DocksData {
rollData: {
cleanliness: {
description: string
Expand Down Expand Up @@ -38,21 +38,62 @@ export interface Setup {
hullDesc: string[]
shipDetail: string[]
eventDetail: string[]
type: Record<string, ShipType>
type: Record<string, ShipTypeData>
captain: Record<string, Partial<NPC>>
rollData: {
cleanliness: [number, string][]
size: [number, string][]
}
}
}
}

interface ShipType {
export interface ShipTypeData {
masts: number,
rigging: string,
length: number,
purpose: string[],
hasOars: boolean,
crewMen: number
}

export interface Docks extends Building {
notableFeature: string
notice: string
passageName: string
initPassage: string
buildingType: string
associatedNPC: NPC
wordNoun: string
ships: Record<string, Ship>
}

export interface Ship {
name: string
type: string
captainType: string
hull: string
detail: string
event: string
roll: {
size: number
cleanliness: number
}
captain: NPC
size: string
cleanliness: string
}

interface Customer {
relationshipDescription: string
relationships: {
building?: {
relationship: string
reciprocalRelationship?: string
}
associatedNPC?: {
relationship: string
reciprocalRelationship: string
}
}
base?: Partial<NPC>
description(docks: Docks, npc: NPC): string
}
723 changes: 723 additions & 0 deletions lib/docks/docksData.ts

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export * from './constructs/spider'
export * from './constructs/tree'
export * from './constructs/wolf'

export * from './docks/_common'
export * from './docks/docksData'

export * from './faction/_common'
export * from './faction/createAllies'
export * from './faction/createLeaderGroup'
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