2021-07-24 21:55:53 -04:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { places } from "./data";
|
|
|
|
|
import * as _ from "lodash";
|
|
|
|
|
import { format as formatDate } from "date-fns";
|
|
|
|
|
import { bodgeString } from "./utils";
|
|
|
|
|
|
|
|
|
|
export let rollResults: { value: string; timestamp: string }[] = [];
|
|
|
|
|
|
|
|
|
|
function addResult(result: string) {
|
|
|
|
|
rollResults = [{ value: result, timestamp: formatDate(new Date(), "P kk:mm:ss") }, ...rollResults];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function roll(event: Event) {
|
|
|
|
|
let template = _.sample(places.templates);
|
|
|
|
|
|
|
|
|
|
addResult(bodgeString(template, places));
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<main>
|
2021-07-25 01:52:33 -04:00
|
|
|
<h2>Random Places</h2>
|
2021-07-24 21:55:53 -04:00
|
|
|
<button type="button" class="btn btn-primary" on:click={roll}>Roll Region</button>
|
|
|
|
|
|
|
|
|
|
{#each rollResults as result}
|
2021-07-25 01:52:33 -04:00
|
|
|
<h4>{result.timestamp}: {result.value}</h4>
|
2021-07-24 21:55:53 -04:00
|
|
|
{/each}
|
|
|
|
|
</main>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
</style>
|