From 9c949e274d26b5baedffd38cebd97bf9a9ca060b Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sun, 30 Jun 2024 20:41:51 +0200 Subject: [PATCH] feat: update routes --- src/App.svelte | 7 ++++--- src/lib/spells.ts | 30 +++++++++++++-------------- src/pages/Canvas.svelte | 10 +++++---- src/pages/Effects.svelte | 1 + src/pages/Spellbook.svelte | 42 ++++++++++++++++++-------------------- src/pages/Strokes.svelte | 1 + 6 files changed, 47 insertions(+), 44 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 1ad6af0..ec92695 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -7,9 +7,10 @@ const routes = { "/": Canvas, - "/spellbook/:spell": Spellbook, - "/strokes/:stroke": Strokes, - "/effects/:effect": Effects + "/spellbook/:id?": Spellbook, + "/strokes": Strokes, + "/effects": Effects, + "*": Canvas // 404 }; diff --git a/src/lib/spells.ts b/src/lib/spells.ts index a0a7a82..a4d518a 100644 --- a/src/lib/spells.ts +++ b/src/lib/spells.ts @@ -18,98 +18,98 @@ type Spell = export type SpellConfig = {name: Spell; stroke: Stroke; effect: Effect; minScore: number; description: string}; -const spells: SpellConfig[] = [ - { +const spells: Record = { + fireball: { name: "Fireball", stroke: "circle", minScore: 0.2, effect: "fireball", description: "A ball of fire that explodes on impact." }, - { + dessintegrate: { name: "Dessintegrate", stroke: "x", minScore: 0.2, effect: "wildMagic", description: "A beam of energy that disintegrates anything in its path." }, - { + earthenShield: { name: "Earthen Shield", stroke: "rectangle", minScore: 0.2, effect: "shield", description: "A shield of earth that protects the caster." }, - { + lightningBolt: { name: "Lightning Bolt", stroke: "zig-zag", minScore: 0.2, effect: "lightning", description: "A bolt of lightning that strikes the target." }, - { + frostWave: { name: "Frost Wave", stroke: "triangle", minScore: 0.2, effect: "frostWave", description: "A wave of frost that freezes the target." }, - { + windGust: { name: "Wind Gust", stroke: "pigtail", minScore: 0.2, effect: "wind", description: "A gust of wind that pushes the target." }, - { + novaBlast: { name: "Nova Blast", stroke: "pentagon", minScore: 0.2, effect: "novaBlast", description: "A blast of energy that damages all enemies." }, - { + missiles: { name: "Missiles", stroke: "arrow", minScore: 0.2, effect: "missiles", description: "A barrage of missiles that strike the target." }, - { + healingLight: { name: "Healing Light", stroke: "check", minScore: 0.2, effect: "heal", description: "A light that heals the target." }, - { + summonDemon: { name: "Summon Demon", stroke: "pentagram", minScore: 0.2, effect: "star", description: "A demon that fights for the caster." }, - { + chronoshift: { name: "Chronoshift", stroke: "hourglass", minScore: 0.2, effect: "wind", description: "A shift in time that slows the target." }, - { + shadowStep: { name: "Shadow Step", stroke: "ankh", minScore: 0.2, effect: "shadowStep", description: "A step into the shadows that teleports the caster." }, - { + pillarOfFlame: { name: "Pillar of Flame", stroke: "left square bracket", minScore: 0.2, effect: "pillar", description: "A pillar of flame that burns the target." } -]; +}; export default spells; diff --git a/src/pages/Canvas.svelte b/src/pages/Canvas.svelte index 4f73a43..1f5822c 100644 --- a/src/pages/Canvas.svelte +++ b/src/pages/Canvas.svelte @@ -127,7 +127,9 @@ const unistroke = Recognize(drawnPoints, false); console.info(unistroke); - const spell = spells.find(spell => spell.stroke === unistroke.Name && unistroke.Score >= spell.minScore); + const spell = Object.values(spells).find( + spell => spell.stroke === unistroke.Name && unistroke.Score >= spell.minScore + ); if (!spell) { comment = "You failed to cast a spell!"; @@ -215,9 +217,9 @@
{comment}
Clear all - Spellbook - Strokes - Effects + Spellbook + Strokes + Effects
{quote} diff --git a/src/pages/Effects.svelte b/src/pages/Effects.svelte index 0e47877..03bac38 100644 --- a/src/pages/Effects.svelte +++ b/src/pages/Effects.svelte @@ -2,6 +2,7 @@ import {onMount} from "svelte"; import PageContainer from "~components/PageContainer.svelte"; import PrimaryButton from "~components/PrimaryButton.svelte"; + import PrimaryLinkButton from "~components/PrimaryLinkButton.svelte"; import {PI2} from "~lib/config"; import {createEffect, type Effect, effectsMap, type Particle} from "~lib/effects"; diff --git a/src/pages/Spellbook.svelte b/src/pages/Spellbook.svelte index d51703e..f70884e 100644 --- a/src/pages/Spellbook.svelte +++ b/src/pages/Spellbook.svelte @@ -1,14 +1,16 @@ @@ -17,7 +19,7 @@ id="book" class="flex flex-col gap-2 p-5 w-[90%] h-[90%] rounded-lg bg-[#eae5de] shadow-glow overflow-y-auto bg-[url('/book.webp')] bg-[size:100%_100%]" > -

{currentSpell.name}

+

{spell.name}

@@ -25,8 +27,8 @@ id="spell-description" class="first-letter:[initial-letter:3] first-letter:text-primary first-letter:pr-2 first-letter:font-serif" > - {currentSpell.name} is a fundamental chronomancy spell that freezes a target in time. When cast successfully, - the target becomes immobilized and unaware of the passage of time. + {spell.name} is a fundamental chronomancy spell that freezes a target in time. When cast successfully, the target + becomes immobilized and unaware of the passage of time.

@@ -39,11 +41,11 @@
-

- {currentSpell.name} is often considered the cornerstone of chronomancy. Its ability to halt the flow of time - for a single target makes it invaluable in both combat and non-combat situations. When casting {currentSpell.name}, + {spell.name} is often considered the cornerstone of chronomancy. Its ability to halt the flow of time for a + single target makes it invaluable in both combat and non-combat situations. When casting {spell.name}, visualize time as a river flowing around your target. Your goal is to create a perfectly still eddy in that river, isolating your target from the timestream.

-

Common applications of {currentSpell.name} include:

+

Common applications of {spell.name} include:

  • Freezing an opponent in combat
  • Preserving a dying creature until healing can be administered
  • @@ -68,11 +70,11 @@
  • Creating "living statues" for artistic or strategic purposes

- Warning: overuse of {currentSpell.name} on living beings can have unforeseen consequences. Always release the - spell carefully, allowing the target to gradually reintegrate with the normal flow of time. + Warning: overuse of {spell.name} on living beings can have unforeseen consequences. Always release the spell + carefully, allowing the target to gradually reintegrate with the normal flow of time.

-
- {spellIndex + 1} -
+
- {Object.values(spells).indexOf(spell) + 1} -
@@ -88,13 +90,9 @@