2021-08-14 21:37:30 -04:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { Button } from "sveltestrap";
|
|
|
|
|
import { format as formatDate } from "date-fns";
|
2021-08-18 22:37:42 -04:00
|
|
|
import { createEventDispatcher } from "svelte";
|
2021-08-14 21:37:30 -04:00
|
|
|
|
|
|
|
|
import DungeonCard from "./DungeonCard.svelte";
|
|
|
|
|
import { Dungeon, rollDungeon } from "../rollers/dungeons";
|
|
|
|
|
|
2021-08-18 22:37:42 -04:00
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
2021-08-14 21:37:30 -04:00
|
|
|
export let rollResults: { dungeon: Dungeon; timestamp: string }[] = [];
|
|
|
|
|
|
|
|
|
|
function roll(event: Event) {
|
|
|
|
|
let dungeon = rollDungeon();
|
|
|
|
|
rollResults = [{ dungeon, timestamp: formatDate(new Date(), "P kk:mm:ss") }, ...rollResults];
|
2021-08-18 22:37:42 -04:00
|
|
|
dispatch("roll");
|
2021-08-14 21:37:30 -04:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<main>
|
|
|
|
|
<span class="btn">
|
|
|
|
|
<Button color="primary" on:click={roll}>Roll Dungeon</Button>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
{#each rollResults as { dungeon, timestamp }}
|
|
|
|
|
<DungeonCard {dungeon} {timestamp} />
|
|
|
|
|
{/each}
|
|
|
|
|
</main>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
main {
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
.btn {
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
</style>
|