149 lines
4.0 KiB
JavaScript
149 lines
4.0 KiB
JavaScript
function pickRandom(arr) {
|
|
return arr[Math.floor(Math.random() * arr.length)];
|
|
}
|
|
|
|
export function dungeonTemplate(data) {
|
|
const bodyFonts = [
|
|
"'Libre Baskerville', serif",
|
|
"'Cardo', serif",
|
|
"'Merriweather', serif",
|
|
"'Fraunces', serif",
|
|
"'Source Serif 4', serif",
|
|
"'Lora', serif"
|
|
];
|
|
|
|
const headingFonts = [
|
|
"'Cinzel Decorative', cursive",
|
|
"'MedievalSharp', cursive",
|
|
"'Metamorphous', cursive",
|
|
"'Playfair Display', serif",
|
|
"'Alegreya Sans SC', sans-serif"
|
|
];
|
|
|
|
const tableFonts = [
|
|
"'Alegreya Sans', sans-serif",
|
|
"'Cabin', sans-serif",
|
|
"'IBM Plex Sans', sans-serif",
|
|
"'Cormorant Garamond', serif",
|
|
"'Special Elite', monospace"
|
|
];
|
|
|
|
const quoteFonts = [
|
|
"'Walter Turncoat', cursive",
|
|
"'Uncial Antiqua', serif",
|
|
"'Beth Ellen', cursive",
|
|
"'Pinyon Script', cursive",
|
|
"'Dela Gothic One', sans-serif"
|
|
];
|
|
|
|
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=Libre+Baskerville&family=Lora&family=Cinzel+Decorative&family=MedievalSharp&family=Alegreya+Sans+SC&family=Alegreya+Sans&family=Cabin&family=Walter+Turncoat&display=swap" rel="stylesheet">
|
|
<style>
|
|
@page { size: A4 landscape; margin: 0; }
|
|
body {
|
|
margin: 0; padding: 1cm;
|
|
background: #d6c5a3;
|
|
font-family: ${bodyFont};
|
|
color: #2b2118;
|
|
font-size: 0.8em;
|
|
line-height: 1.3em;
|
|
}
|
|
h1 {
|
|
font-family: ${headingFont};
|
|
text-align: center;
|
|
font-size: 2em;
|
|
margin: 0.2em 0 0.3em;
|
|
color: #3e1f0e;
|
|
border-bottom: 2px solid #3e1f0e;
|
|
padding-bottom: 0.2em;
|
|
}
|
|
.flavor {
|
|
text-align: center;
|
|
font-style: italic;
|
|
font-family: ${quoteFont};
|
|
margin: 0.4em 0 1em;
|
|
font-size: 0.95em;
|
|
}
|
|
.columns {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr 1fr;
|
|
gap: 0.8cm;
|
|
align-items: start;
|
|
}
|
|
.col {
|
|
display: flex; flex-direction: column;
|
|
gap: 0.4em;
|
|
}
|
|
h2 {
|
|
font-family: ${headingFont};
|
|
font-size: 1em;
|
|
margin: 0.3em 0 0.1em;
|
|
color: #3e1f0e;
|
|
border-bottom: 1px solid #3e1f0e;
|
|
padding-bottom: 0.1em;
|
|
}
|
|
.map img { max-width: 100%; border: 2px solid #3e1f0e; border-radius: 0.2cm; }
|
|
.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.4em; }
|
|
li { margin-bottom: 0.2em; }
|
|
table { width: 100%; border-collapse: collapse; font-family: ${tableFont}; font-size: 0.8em; }
|
|
th, td { border: 1px solid #3e1f0e; padding: 0.2em; text-align: left; vertical-align: top; }
|
|
th { background: #d9c6a5; }
|
|
table tr:hover { background: rgba(62,31,14,0.05); }
|
|
footer {
|
|
text-align: center; font-size: 0.7em; color: #5a4632; 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>Map</h2>
|
|
<div class="map"><img src="file://${data.map}" alt="Dungeon Map"></div>
|
|
|
|
<h2>Adventure Hooks</h2>
|
|
<ul>${data.hooks.map(h => `<li>${h}</li>`).join("")}</ul>
|
|
|
|
<h2>Rumors</h2>
|
|
<ul>${data.rumors.map(r => `<li>${r}</li>`).join("")}</ul>
|
|
</div>
|
|
|
|
<div class="col">
|
|
<h2>Keyed Rooms</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>
|
|
|
|
<h2>NPCs</h2>
|
|
<ul>${data.npcs.map(n => `<li><b>${n.name}</b>: ${n.trait}</li>`).join("")}</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<footer>Generated with Scrollsmith • © ${new Date().getFullYear()}</footer>
|
|
</body>
|
|
</html>
|
|
`;
|
|
}
|