From 4bf5ca8d3fb2b7c0de9438e4e0ebb50a09d59afb Mon Sep 17 00:00:00 2001 From: Tobias Berger Date: Mon, 27 Sep 2021 08:38:26 +0200 Subject: [PATCH] Add initial Shark only init function that sets title --- src/App.svelte | 5 ++- src/components/Header.svelte | 9 +++++- src/shark/StaticClass.ts | 7 ++++ src/shark/index.ts | 62 ++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 src/shark/StaticClass.ts create mode 100644 src/shark/index.ts diff --git a/src/App.svelte b/src/App.svelte index b6230ac..8486938 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,7 +1,10 @@
diff --git a/src/components/Header.svelte b/src/components/Header.svelte index 1eb6f01..939236d 100644 --- a/src/components/Header.svelte +++ b/src/components/Header.svelte @@ -1,4 +1,6 @@ - + + {SharkGame.title} + +
    {#each Object.entries(mainHeaderButtons) as [name, onClick]}
  • {name}
  • {/each}
+ {SharkGame.title}
    {#each Object.entries(otherHeaderButtons) as [name, onClick]}
  • diff --git a/src/shark/StaticClass.ts b/src/shark/StaticClass.ts new file mode 100644 index 0000000..9d58df7 --- /dev/null +++ b/src/shark/StaticClass.ts @@ -0,0 +1,7 @@ +export class StaticClass { + constructor() { + if (this instanceof StaticClass) { + throw new Error("A static class cannot be instantiated"); + } + } +} diff --git a/src/shark/index.ts b/src/shark/index.ts new file mode 100644 index 0000000..9e9699d --- /dev/null +++ b/src/shark/index.ts @@ -0,0 +1,62 @@ +import { StaticClass } from "./StaticClass"; + +export class SharkGame extends StaticClass { + static readonly #GAME_NAMES = [ + "Five Seconds A Shark", + "Next Shark Game", + "Next Shark Game: Barkfest", + "Sharky Clicker", + "Weird Oceans", + "You Have To Name The Shark Game", + "Shark A Lark", + "Bark Shark", + "Fin Idle", + "Ray of Dreams", + "Shark Saver", + "Shoal Sharker", + "Shark Souls", + "Saucy Sharks", + "Sharkfall", + "Heart of Sharkness", + "Sharks and Recreation", + "Alone in the Shark", + "Sharkpocalypse", + "Shark of Darkness", + "Strange Oceans", + "A New Frontier", + "Lobster's Paradise", + "Revenge of the Crabs", + "Shark Box", + "Dolphin Heroes", + "Maws", + "Sharky's Strange Crusade: Part 6", + "Sailor Crab", + "League of Lobsters", + "Eel Team Six", + "Dungeons And Dolphins", + "Gameshark", + "Sharkiplier Plays", + "Five Nights in Frigid", + "The Shark of Wall Street", + ":the shark game:", + "Sharkware Edition", + "Help Wanted", + "NOT FINISHED", + "Deluxe", + "doo doo do-do do-do", + "DUNGEONS", + "The Adventure Continues", + "To Be Continued", + "what the crab doin", + ] as const; + + static title: string; + static init(): void { + SharkGame.title = + SharkGame.#GAME_NAMES[ + Math.floor(Math.random() * SharkGame.#GAME_NAMES.length) + ]; + } +} + +globalThis.SharkGame = SharkGame;