153 lines
4.3 KiB
JavaScript
153 lines
4.3 KiB
JavaScript
function pickRandom(arr) {
|
|
return arr[Math.floor(Math.random() * arr.length)];
|
|
}
|
|
|
|
export function dungeonTemplate(data) {
|
|
const bodyFonts = [
|
|
"'Lora', serif",
|
|
"'Merriweather', serif",
|
|
"'Libre Baskerville', serif",
|
|
"'Source Serif 4', serif"
|
|
];
|
|
|
|
const headingFonts = [
|
|
"'Cinzel Decorative', cursive",
|
|
"'MedievalSharp', cursive",
|
|
"'Metamorphous', cursive",
|
|
"'Playfair Display', serif"
|
|
];
|
|
|
|
const tableFonts = [
|
|
"'Alegreya Sans', sans-serif",
|
|
"'Cabin', sans-serif",
|
|
"'IBM Plex Sans', sans-serif",
|
|
"'Cormorant Garamond', serif"
|
|
];
|
|
|
|
const quoteFonts = [
|
|
"'Walter Turncoat', cursive",
|
|
"'Uncial Antiqua', serif",
|
|
"'Beth Ellen', cursive",
|
|
"'Pinyon Script', cursive"
|
|
];
|
|
|
|
const bodyFont = pickRandom(bodyFonts);
|
|
const headingFont = pickRandom(headingFonts);
|
|
const tableFont = pickRandom(tableFonts);
|
|
const quoteFont = pickRandom(quoteFonts);
|
|
|
|
return `
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>${data.title}</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative&family=MedievalSharp&family=Metamorphous&family=Playfair+Display&family=Alegreya+Sans&family=Cabin&family=IBM+Plex+Sans&family=Cormorant+Garamond&family=Lora&family=Merriweather&family=Libre+Baskerville&family=Source+Serif+4&family=Walter+Turncoat&family=Uncial+Antiqua&family=Beth+Ellen&family=Pinyon+Script&display=swap" rel="stylesheet">
|
|
<style>
|
|
@page { size: A4 landscape; margin: 0; }
|
|
body {
|
|
margin: 0; padding: 1.5cm;
|
|
background: #f5f5f5;
|
|
font-family: ${bodyFont};
|
|
color: #1a1a1a;
|
|
font-size: 0.7em;
|
|
line-height: 1.25em;
|
|
}
|
|
h1 {
|
|
font-family: ${headingFont};
|
|
text-align: center;
|
|
font-size: 2em;
|
|
margin: 0.2em 0 0.3em;
|
|
color: #1a1a1a;
|
|
border-bottom: 2px solid #1a1a1a;
|
|
padding-bottom: 0.2em;
|
|
letter-spacing: 0.1em;
|
|
}
|
|
.flavor {
|
|
text-align: center;
|
|
font-style: italic;
|
|
font-family: ${quoteFont};
|
|
margin: 0.4em 0 0.8em;
|
|
font-size: 0.9em;
|
|
}
|
|
.columns {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr 1fr;
|
|
gap: 0.5cm;
|
|
align-items: start;
|
|
}
|
|
.col {
|
|
display: flex; flex-direction: column;
|
|
gap: 0.15em;
|
|
}
|
|
h2 {
|
|
font-family: ${headingFont};
|
|
font-size: 1.0em;
|
|
margin: 0.3em 0 0.1em;
|
|
color: #1a1a1a;
|
|
border-bottom: 1px solid #1a1a1a;
|
|
padding-bottom: 0.1em;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
.room h3 { margin: 0.2em 0 0.05em; font-size: 0.95em; font-weight: bold; }
|
|
.room p { text-align: justify; word-wrap: break-word; margin: 0.1em 0 0.3em; }
|
|
ul { padding-left: 1em; margin: 0.1em 0 0.3em; }
|
|
li { margin-bottom: 0.2em; }
|
|
table { width: 100%; border-collapse: collapse; font-family: ${tableFont}; font-size: 0.8em; }
|
|
th, td { border: 1px solid #1a1a1a; padding: 0.2em; text-align: left; vertical-align: top; }
|
|
th { background: #e0e0e0; }
|
|
table tr:hover { background: rgba(0, 0, 0, 0.05); }
|
|
.map-page {
|
|
page-break-before: always;
|
|
text-align: center;
|
|
}
|
|
.map-page img { max-width: 100%; max-height: 27cm; border: 2px solid #1a1a1a; border-radius: 0.2cm; }
|
|
footer {
|
|
text-align: center; font-size: 0.65em; color: #555; margin-top: 0.5em; font-style: italic;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>${data.title}</h1>
|
|
<p class="flavor">${data.flavor}</p>
|
|
|
|
<div class="columns">
|
|
<div class="col">
|
|
<h2>Adventure Hooks & Rumors</h2>
|
|
<ul>${data.hooksRumors.map(item => `<li>${item}</li>`).join("")}</ul>
|
|
|
|
<h2>Locations</h2>
|
|
${data.rooms.map((room, i) => `<div class="room"><h3>${i + 1}. ${room.name}</h3><p>${room.description}</p></div>`).join("")}
|
|
</div>
|
|
|
|
<div class="col">
|
|
<h2>Encounters</h2>
|
|
<table><tr><th>Name</th><th>Details</th></tr>
|
|
${data.encounters.map(e => `<tr><td>${e.name}</td><td>${e.details}</td></tr>`).join("")}
|
|
</table>
|
|
|
|
<h2>Treasure</h2>
|
|
<ul>${data.treasure.map(t => `<li>${t}</li>`).join("")}</ul>
|
|
</div>
|
|
|
|
<div class="col">
|
|
<h2>NPCs</h2>
|
|
<ul>${data.npcs.map(n => `<li><b>${n.name}</b>: ${n.trait}</li>`).join("")}</ul>
|
|
|
|
<h2>Plot Resolutions</h2>
|
|
<ul>${data.plotResolutions.map(p => `<li>${p}</li>`).join("")}</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="map-page">
|
|
<h2>Dungeon Map</h2>
|
|
<img src="file://${data.map}" alt="Dungeon Map">
|
|
</div>
|
|
|
|
<footer>Generated with Scrollsmith • © ${new Date().getFullYear()}</footer>
|
|
</body>
|
|
</html>
|
|
`;
|
|
}
|