-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #586 from ryceg:Fix-life-events
Add custom images
- Loading branch information
Showing
51 changed files
with
689 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,39 @@ | ||
import { Town } from '../town/_common' | ||
|
||
type Illustration = | ||
| 'general-store-illustration' | ||
| 'tavern-illustration' | ||
| 'town-illustration' | ||
| 'city-illustration' | ||
|
||
export const getIllustration = (illustration: Illustration, alt: string) => { | ||
let img = '<img ' | ||
img += 'id="illustration" ' | ||
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="${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 addLocalSourceSet = (illustration: Illustration, sizes: string[] = ['360', '411', '500', '576', '768', '992', '1200']) => { | ||
let img = '' | ||
const path = getPath() | ||
for (const size of sizes) { | ||
img += `${path}src/Resources/img/hero/${illustration}-x${size}.jpg ${size}w, ` | ||
} | ||
return img | ||
} | ||
|
||
export const getCustomImage = (url: URL) => { | ||
const img = document.createElement('img') | ||
img.id = 'illustration' | ||
img.src = url as unknown as string | ||
img.alt = 'A custom-defined image.' | ||
return img.outerHTML | ||
} | ||
|
||
export const getLocalImage = (illustration: Illustration) => { | ||
const img = document.createElement('img') | ||
const path = getPath() | ||
img.id = 'illustration' | ||
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` | ||
if (process.env.NODE_ENV === 'production' && location.origin !== 'file://') img.srcset = `${addLocalSourceSet(illustration)} ${path}src/Resources/img/hero/${illustration}.jpg` | ||
img.alt = `An image depicting ${lib.articles.output(illustration)}, created by artist Juho Huttunen.` | ||
return img | ||
} | ||
|
||
export const townOrCity = (town: Town) => { | ||
if (town.type === 'city' || town.type === 'town') return 'city-illustration' | ||
return 'town-illustration' | ||
return img.outerHTML | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
|
||
:: AlchemistOutput [alchemist] | ||
\<<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]>> | ||
\<h1 class="interactive-only">$building.name</h1> | ||
\<<include "TownMicroEventsOutput">> | ||
<<nobr>><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> | ||
:: AlchemistOutput [alchemist nobr] | ||
<<include "PrintImage">> | ||
<<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]>> | ||
<h1 class="interactive-only">$building.name</h1><<button "Edit $building.name" $building.initPassage>><</button>><<include "TownMicroEventsOutput">><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 "<h4>Talk with $associatedNPC.name</h4>" t8n>> | ||
<<linkreplace "Talk with $associatedNPC.name" t8n>> | ||
<h6>$associatedNPC.name</h6><<include "ChemistTalk">><</linkreplace>></section> | ||
<span class="interactive-only"><<link "<h4>Generate plothook</h4>">><<set $associatedNPC.plot to setup.alchemistMission($town)>><</link>></span><<liveblock>><<if def $associatedNPC.plot>><div id="plothook"><<print ["When you say that you're adventurers, $associatedNPC.hisher $associatedNPC.eyes eyes light up, and $associatedNPC.heshe says", "You chat for a while, and then $associatedNPC.firstName says ", "You discuss business, and when you talk about your adventures, $associatedNPC.firstName asks "].random()>> "$associatedNPC.plot"</div><</if>><</liveblock>> | ||
<span class="interactive-only"><<link "Generate plothook">><<set $associatedNPC.plot to setup.alchemistMission($town)>><</link>></span><<liveblock>><<if def $associatedNPC.plot>><div id="plothook"><<print ["When you say that you're adventurers, $associatedNPC.hisher $associatedNPC.eyes eyes light up, and $associatedNPC.heshe says", "You chat for a while, and then $associatedNPC.firstName says ", "You discuss business, and when you talk about your adventures, $associatedNPC.firstName asks "].random()>> "$associatedNPC.plot"</div><</if>><</liveblock>> | ||
<<include "RandomPotion">> | ||
<<include "AlchemistSell">> | ||
<<details "CreateNewNpc" "Customers">><</nobr>> | ||
<<details "CreateNewNpc" "Customers">> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
:: ChemistTalk | ||
$associatedNPC.firstName looks <<print $associatedNPC.currentMood.random()>>, and idly shifts a box of <<print lib.alchemistData.ingredients.random()>> as $associatedNPC.heshe talks. The $associatedNPC.raceNote <<print $associatedNPC.chitchat.random()>> as you peruse the shop. $associatedNPC.firstName tells you that $associatedNPC.heshe is working on <<print lib.articles.output($building.brew.potionPurpose)>>, and points to the <<linkappend $building.brew.containerDescription t8n>>. Looking inside the $building.brew.vesselType, you see <<print lib.articles.output( $building.brew.liquidDescription)>> bubbling away<</linkappend>>. | ||
:: ChemistTalk [nobr] | ||
$associatedNPC.firstName looks <<print $associatedNPC.currentMood.random()>>, and idly shifts a box of <<print lib.alchemistData.ingredients.random()>> as $associatedNPC.heshe talks. The $associatedNPC.raceNote <<print $associatedNPC.chitchat.random()>> as you peruse the shop. $associatedNPC.firstName tells you that $associatedNPC.heshe is working on <<print lib.articles.output($building.brew.potionPurpose)>>, and points to the <<linkappend $building.brew.containerDescription t8n>>. Looking inside the $building.brew.vesselType, you see <<print lib.articles.output($building.brew.liquidDescription)>> bubbling away<</linkappend>>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
|
||
:: SmithyOutput | ||
:: SmithyOutput [nobr] | ||
<<include "PrintImage">> | ||
<<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>> | ||
<<nobr>><h1 class="interactive-only">$building.name</h1> | ||
<h1 class="interactive-only">$building.name</h1> | ||
<<button "Edit $building.name" $building.initPassage>><</button>><br> | ||
<<include "TownMicroEventsOutput">><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)>> | ||
<section><h3>Blacksmith</h3><p>The blacksmith <<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 smithy, and asks what $associatedNPC.heshe can do for you.</p> | ||
<<include "BlacksmithTalk">></section> | ||
<span class="temporarily-removed click-and-remove-link"><<link "<h4>Generate plothook</h4>">><<set $associatedNPC.plot to setup.blacksmithMission($town)>><<update>><</link>></span><<liveblock>><<if def $associatedNPC.plot>><div id="plothook"><<print ["When you say that you're adventurers, $associatedNPC.hisher $associatedNPC.eyes eyes light up, and $associatedNPC.heshe says", "You chat for a while, and then $associatedNPC.firstName says ", "You discuss business, and when you talk about your adventures, $associatedNPC.firstName asks "].random()>> "$associatedNPC.plot"</div><</if>><</liveblock>> | ||
<<include "SmithySell">> | ||
<<details "CreateNewNpc" "Customers">><</nobr>> | ||
<<details "CreateNewNpc" "Customers">> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.