Add initial Shark

only init function that sets title
This commit is contained in:
Tobias Berger 2021-09-27 08:38:26 +02:00
parent 0d569904a0
commit 4bf5ca8d3f
4 changed files with 81 additions and 2 deletions

View file

@ -1,7 +1,10 @@
<script lang="ts"> <script lang="ts">
import Footer from "./components/Footer.svelte"; import Footer from "./components/Footer.svelte";
import Header from "./components/Header.svelte"; import Header from "./components/Header.svelte";
import Wrapper from "./components/WrappFooter.svelte"; import Wrapper from "./components/Wrapper.svelte";
import { SharkGame } from "./shark";
SharkGame.init();
</script> </script>
<Header /> <Header />

View file

@ -1,4 +1,6 @@
<script> <script lang="ts">
import { SharkGame } from "../shark";
const discordLink = "https://discord.gg/eYqApFkFPY"; const discordLink = "https://discord.gg/eYqApFkFPY";
const mainHeaderButtons = { const mainHeaderButtons = {
@ -35,12 +37,17 @@
}; };
</script> </script>
<svelte:head>
<title>{SharkGame.title}</title>
</svelte:head>
<header> <header>
<ul id="main-header-buttons"> <ul id="main-header-buttons">
{#each Object.entries(mainHeaderButtons) as [name, onClick]} {#each Object.entries(mainHeaderButtons) as [name, onClick]}
<li><a on:click={onClick} href={"javascript:;"}>{name}</a></li> <li><a on:click={onClick} href={"javascript:;"}>{name}</a></li>
{/each} {/each}
</ul> </ul>
{SharkGame.title}
<ul id="other-header-buttons"> <ul id="other-header-buttons">
{#each Object.entries(otherHeaderButtons) as [name, onClick]} {#each Object.entries(otherHeaderButtons) as [name, onClick]}
<li> <li>

7
src/shark/StaticClass.ts Normal file
View file

@ -0,0 +1,7 @@
export class StaticClass {
constructor() {
if (this instanceof StaticClass) {
throw new Error("A static class cannot be instantiated");
}
}
}

62
src/shark/index.ts Normal file
View file

@ -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;