diff --git a/.prettierrc b/.prettierrc
index e69de29..963354f 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -0,0 +1,3 @@
+{
+ "printWidth": 120
+}
diff --git a/public/index.html b/public/index.html
index c891c58..3dac725 100644
--- a/public/index.html
+++ b/public/index.html
@@ -16,16 +16,9 @@
-->
-
+
-
+
-
-
+
+
@@ -69,13 +56,9 @@
Shark Game??
Oh dear! It seems you have Javascript disabled, or that your current
- browser does not support scripts.
- Shark Game requires scripts to work. Otherwise it's just a static
- webpage that doesn't do much. Oh dear! It seems you have Javascript disabled, or that your current browser does not support scripts.
+ Shark Game requires scripts to work. Otherwise it's just a static webpage that doesn't do much.
In fact, it only displays this Shark asking you for scripts.
diff --git a/src/App.svelte b/src/App.svelte
index 43ec107..5895184 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -17,15 +17,9 @@
root = document.documentElement;
SharkGame.Settings.settings.subscribe((settings) => {
- root.classList.toggle(
- "no-theme",
- !settings.appearance.enableThemes.current
- );
+ root.classList.toggle("no-theme", !settings.appearance.enableThemes.current);
settings.appearance.theme.options.forEach((theme) => {
- root.classList.toggle(
- theme,
- theme === settings.appearance.theme.current
- );
+ root.classList.toggle(theme, theme === settings.appearance.theme.current);
});
});
});
diff --git a/src/components/Header.svelte b/src/components/Header.svelte
index 6ca3334..46440b6 100644
--- a/src/components/Header.svelte
+++ b/src/components/Header.svelte
@@ -14,11 +14,7 @@
game.SaveHandler.save(game);
},
settings() {
- openModal(
- SettingsModal,
- { settings: game.Settings.settings },
- { replace: true }
- );
+ openModal(SettingsModal, { settings: game.Settings.settings }, { replace: true });
},
help() {
console.log("help");
diff --git a/src/components/Log.svelte b/src/components/Log.svelte
index 6a9c764..448c86e 100644
--- a/src/components/Log.svelte
+++ b/src/components/Log.svelte
@@ -6,11 +6,7 @@
import type { Writable } from "svelte/store";
import { slide } from "svelte/transition";
- import type {
- AddMessageEvent,
- ResetMessagesEvent,
- Message,
- } from "../shark/Message";
+ import type { AddMessageEvent, ResetMessagesEvent, Message } from "../shark/Message";
import { MessageType } from "../shark/Message";
export let messages: Writable;
diff --git a/src/components/Modals/SettingsModal.svelte b/src/components/Modals/SettingsModal.svelte
index 0b8357b..68021a6 100644
--- a/src/components/Modals/SettingsModal.svelte
+++ b/src/components/Modals/SettingsModal.svelte
@@ -14,18 +14,10 @@
{categoryName.toUpperCase()}
{#each Object.entries(categorySettings) as [settingId, setting] (settingId)}
-
-
+
+
{setting.name}
- ({setting.description})
+ ({setting.description})
{#each setting.options as option}
{#if !collapsed}
{#each resources as [resourceName, resource], index}
-
+
{resourceName}
{resource.amount}
{Math.round(100 * (resource.change + Number.EPSILON)) / 100}/s
diff --git a/src/components/Tabs/Home.svelte b/src/components/Tabs/Home.svelte
index c7ec947..2cafdee 100644
--- a/src/components/Tabs/Home.svelte
+++ b/src/components/Tabs/Home.svelte
@@ -10,9 +10,7 @@
function homeActionClick(homeAction: HomeAction) {
if (homeAction.effect.resource) {
- const resources = Resources.getResources(
- Object.keys(homeAction.effect.resource)
- );
+ const resources = Resources.getResources(Object.keys(homeAction.effect.resource));
if (resources !== null) {
for (const [resourceName, resource] of Object.entries(resources)) {
@@ -23,10 +21,7 @@
if (homeAction.outcomes) {
dispatch("addMessage", {
- message:
- homeAction.outcomes[
- Math.floor(Math.random() * homeAction.outcomes.length)
- ],
+ message: homeAction.outcomes[Math.floor(Math.random() * homeAction.outcomes.length)],
});
}
}
diff --git a/src/components/Wrapper.svelte b/src/components/Wrapper.svelte
index 9686bbc..6df2dd4 100644
--- a/src/components/Wrapper.svelte
+++ b/src/components/Wrapper.svelte
@@ -26,18 +26,9 @@
-
+
-
+
toggleSidebar(false)}>
@@ -56,10 +47,7 @@
-
+
{
const dict: Record = {};
@@ -17,29 +14,19 @@ export class LZString extends StaticClass {
}
static compressToBase64(input: string): string {
- const result = LZString.#compress(input, 6, (a) =>
- LZString.#KeyStrBase64.charAt(a)
- );
+ const result = LZString.#compress(input, 6, (a) => LZString.#KeyStrBase64.charAt(a));
return result + "=".repeat((4 - (result.length % 4)) % 4);
}
static decompressFromBase64(input: string | null): string | null {
if (input === null || input === "") return null;
- return LZString.#decompress(
- input.length,
- 32,
- (index) => LZString.#KeyStrBase64Dict[input.charAt(index)]
- );
+ return LZString.#decompress(input.length, 32, (index) => LZString.#KeyStrBase64Dict[input.charAt(index)]);
}
static compress(uncompressed: string): string {
return LZString.#compress(uncompressed);
}
static #compress(uncompressed: string): string;
- static #compress(
- uncompressed: string,
- bitsPerChar: number,
- getCharFromInt: (index: number) => string
- ): string;
+ static #compress(uncompressed: string, bitsPerChar: number, getCharFromInt: (index: number) => string): string;
static #compress(
uncompressed: string,
bitsPerChar = 16,
@@ -255,15 +242,9 @@ export class LZString extends StaticClass {
static decompress(compressed: string | null): string | null {
if (compressed === null || compressed === "") return null;
- return LZString.#decompress(compressed.length, 32768, (index) =>
- compressed.charCodeAt(index)
- );
+ return LZString.#decompress(compressed.length, 32768, (index) => compressed.charCodeAt(index));
}
- static #decompress(
- length: number,
- resetValue: number,
- getNextValue: (index: number) => number
- ): string | null {
+ static #decompress(length: number, resetValue: number, getNextValue: (index: number) => number): string | null {
const dictionary: (number | string)[] = [];
let enlargeIn = 4;
diff --git a/src/shark/Log.ts b/src/shark/Log.ts
index c6bfe11..8da5e9a 100644
--- a/src/shark/Log.ts
+++ b/src/shark/Log.ts
@@ -14,14 +14,9 @@ export class Log extends StaticClass {
})();
}
- static addMessage(
- message: string,
- messageType: MessageType = MessageType.message
- ): void {
+ static addMessage(message: string, messageType: MessageType = MessageType.message): void {
this.messages.update((oldMessages) =>
- [...oldMessages, new Message(message, messageType)].slice(
- -Log.#maxLogLength
- )
+ [...oldMessages, new Message(message, messageType)].slice(-Log.#maxLogLength)
);
}
diff --git a/src/shark/SaveHandler.ts b/src/shark/SaveHandler.ts
index 86d9fbb..3148566 100644
--- a/src/shark/SaveHandler.ts
+++ b/src/shark/SaveHandler.ts
@@ -29,15 +29,11 @@ export class SaveHandler extends StaticClass {
})();
});
- const allTabsEntries = Object.entries(
- game.TabHandler.AllTabs
- ) as unknown as [
+ const allTabsEntries = Object.entries(game.TabHandler.AllTabs) as unknown as [
keyof typeof TabHandler["AllTabs"],
typeof TabHandler["AllTabs"][keyof typeof TabHandler["AllTabs"]]
][];
- const selectedTabIndex = allTabsEntries.findIndex(
- ([, tab]) => tab === game.TabHandler.currentTab
- );
+ const selectedTabIndex = allTabsEntries.findIndex(([, tab]) => tab === game.TabHandler.currentTab);
const selectedTabName = allTabsEntries[selectedTabIndex][0];
const currentSettings = game.Settings.getSaveable();
@@ -65,11 +61,8 @@ export class SaveHandler extends StaticClass {
const stringifiedSave = JSON.stringify(save);
const encodedSave = LZString.compressToBase64(stringifiedSave);
console.debug(
- `${new Date(
- Date.now()
- ).toISOString()} - saving ${stringifiedSave} - encoded to ${
- Math.round((encodedSave.length / stringifiedSave.length) * 100 * 100) /
- 100
+ `${new Date(Date.now()).toISOString()} - saving ${stringifiedSave} - encoded to ${
+ Math.round((encodedSave.length / stringifiedSave.length) * 100 * 100) / 100
}% size`
);
@@ -77,9 +70,7 @@ export class SaveHandler extends StaticClass {
}
static async load(game: typeof SharkGame): Promise {
- const localSave = LZString.decompressFromBase64(
- localStorage.getItem(SaveHandler.saveName)
- );
+ const localSave = LZString.decompressFromBase64(localStorage.getItem(SaveHandler.saveName));
const loadedSave = JSON.parse(localSave ?? "{}");
const saveVersion = loadedSave.version ?? 0;
@@ -91,11 +82,7 @@ export class SaveHandler extends StaticClass {
let save = loadedSave;
for (let i = 0; i < migrators.length; i++) {
- console.debug(
- `Executing save migrator ${i + 1} / ${migrators.length} (${
- saveVersion + i + 1
- })`
- );
+ console.debug(`Executing save migrator ${i + 1} / ${migrators.length} (${saveVersion + i + 1})`);
save = migrators[i](save);
}
@@ -104,9 +91,7 @@ export class SaveHandler extends StaticClass {
game.Settings.settings.update((settings) => {
Object.entries(settings).forEach(([categoryName, categorySettings]) => {
Object.entries(categorySettings).forEach(([settingName, setting]) => {
- setting.current =
- fullSave.settings[`${categoryName};${settingName}`] ??
- setting.default;
+ setting.current = fullSave.settings[`${categoryName};${settingName}`] ?? setting.default;
});
});
return settings;
diff --git a/src/shark/Settings.ts b/src/shark/Settings.ts
index 122dd16..22f8b9d 100644
--- a/src/shark/Settings.ts
+++ b/src/shark/Settings.ts
@@ -20,26 +20,15 @@ export class Settings extends StaticClass {
current: true,
default: true as const,
name: "Enable Planet-dependent Styles" as const,
- description:
- "Whether page colors should change for different planets" as const,
+ description: "Whether page colors should change for different planets" as const,
options: [true, false] as const,
},
theme: {
current: "marine",
default: "marine" as const,
name: "Currently enabled theme" as const,
- description:
- "Only applied if planet-dependent styles are enabled" as const,
- options: [
- "abandoned",
- "chaotic",
- "frigid",
- "haven",
- "marine",
- "shrouded",
- "tempestuous",
- "violent",
- ],
+ description: "Only applied if planet-dependent styles are enabled" as const,
+ options: ["abandoned", "chaotic", "frigid", "haven", "marine", "shrouded", "tempestuous", "violent"],
},
},
};
@@ -67,8 +56,4 @@ export type Setting = {
readonly description: unknown;
readonly options: readonly unknown[];
};
-export type SettingsRecord = typeof Settings["settings"] extends Writable<
- infer X
->
- ? X
- : never;
+export type SettingsRecord = typeof Settings["settings"] extends Writable ? X : never;
diff --git a/src/shark/SharkGame.ts b/src/shark/SharkGame.ts
index 1476904..3d16d1f 100644
--- a/src/shark/SharkGame.ts
+++ b/src/shark/SharkGame.ts
@@ -75,10 +75,7 @@ export class SharkGame extends StaticClass {
SaveHandler.load(this);
- SharkGame.title =
- SharkGame.#GAME_NAMES[
- Math.floor(Math.random() * SharkGame.#GAME_NAMES.length)
- ];
+ SharkGame.title = SharkGame.#GAME_NAMES[Math.floor(Math.random() * SharkGame.#GAME_NAMES.length)];
}
}
diff --git a/src/shark/TabHandler.ts b/src/shark/TabHandler.ts
index 0fc0bb0..7e7268e 100644
--- a/src/shark/TabHandler.ts
+++ b/src/shark/TabHandler.ts
@@ -7,6 +7,5 @@ export class TabHandler extends StaticClass {
Home,
Lab,
} as const;
- static currentTab: typeof TabHandler.AllTabs[keyof typeof TabHandler.AllTabs] =
- TabHandler.AllTabs.Home;
+ static currentTab: typeof TabHandler.AllTabs[keyof typeof TabHandler.AllTabs] = TabHandler.AllTabs.Home;
}
diff --git a/src/shark/data/HomeActions.ts b/src/shark/data/HomeActions.ts
index 6cb813a..3de13ba 100644
--- a/src/shark/data/HomeActions.ts
+++ b/src/shark/data/HomeActions.ts
@@ -10,11 +10,11 @@ export type HomeAction = {
};
export class HomeActions extends StaticClass {
- static getActionTable(): { [actionName: string]: HomeAction } {
+ static getActionTable(): Record {
return HomeActions.actionTable;
}
- static actionTable = {
+ static readonly actionTable = Object.seal({
catchFish: {
name: "Catch fish",
effect: {
@@ -72,13 +72,7 @@ export class HomeActions extends StaticClass {
shark: 1,
},
},
- outcomes: [
- "S h a r k",
- "s.h.a.r.k.",
- "shark",
- "sharg",
- "that was probably a shark",
- ],
+ outcomes: ["S h a r k", "s.h.a.r.k.", "shark", "sharg", "that was probably a shark"],
},
- };
+ });
}
diff --git a/src/shark/data/Resources.ts b/src/shark/data/Resources.ts
index d1c5ba6..69423cc 100644
--- a/src/shark/data/Resources.ts
+++ b/src/shark/data/Resources.ts
@@ -38,20 +38,15 @@ export class Resources extends StaticClass {
static getResource(resourceName: string): Resource | null {
let result: null | Resource = null;
Resources.Resources.update((res) => {
- if (Object.hasOwnProperty.call(res, resourceName))
- result = res[resourceName];
+ if (Object.hasOwnProperty.call(res, resourceName)) result = res[resourceName];
return res;
});
return result;
}
static getResources(resourceNames: string[]): Record | null;
- static getResources(
- ...resourceNames: string[]
- ): Record | null;
- static getResources(
- ...resourceNames: string[] | string[][]
- ): Record | null {
+ static getResources(...resourceNames: string[]): Record | null;
+ static getResources(...resourceNames: string[] | string[][]): Record | null {
if (Array.isArray(resourceNames[0])) {
resourceNames = resourceNames[0];
}
diff --git a/src/styles/themes.scss b/src/styles/themes.scss
index 5cbc374..40c50c7 100644
--- a/src/styles/themes.scss
+++ b/src/styles/themes.scss
@@ -82,12 +82,7 @@ $color-text: white;
--color-med: #{$color-med-marine};
--color-dark: #{$color-dark-marine};
--color-darker: #{$color-darker-marine};
- --color-title: #{rgba(
- red($color-med-marine),
- green($color-med-marine),
- blue($color-med-marine),
- 0.2
- )};
+ --color-title: #{rgba(red($color-med-marine), green($color-med-marine), blue($color-med-marine), 0.2)};
&:not(.no-theme) {
&.abandoned {
@@ -96,12 +91,7 @@ $color-text: white;
--color-med: #{$color-med-abandoned};
--color-dark: #{$color-dark-abandoned};
--color-darker: #{$color-darker-abandoned};
- --color-title: #{rgba(
- red($color-med-abandoned),
- green($color-med-abandoned),
- blue($color-med-abandoned),
- 0.2
- )};
+ --color-title: #{rgba(red($color-med-abandoned), green($color-med-abandoned), blue($color-med-abandoned), 0.2)};
}
&.chaotic {
--color-lighter: #{$color-lighter-chaotic};
@@ -109,12 +99,7 @@ $color-text: white;
--color-med: #{$color-med-chaotic};
--color-dark: #{$color-dark-chaotic};
--color-darker: #{$color-darker-chaotic};
- --color-title: #{rgba(
- red($color-med-chaotic),
- green($color-med-chaotic),
- blue($color-med-chaotic),
- 0.2
- )};
+ --color-title: #{rgba(red($color-med-chaotic), green($color-med-chaotic), blue($color-med-chaotic), 0.2)};
}
&.frigid {
--color-lighter: #{$color-lighter-frigid};
@@ -122,12 +107,7 @@ $color-text: white;
--color-med: #{$color-med-frigid};
--color-dark: #{$color-dark-frigid};
--color-darker: #{$color-darker-frigid};
- --color-title: #{rgba(
- red($color-med-frigid),
- green($color-med-frigid),
- blue($color-med-frigid),
- 0.2
- )};
+ --color-title: #{rgba(red($color-med-frigid), green($color-med-frigid), blue($color-med-frigid), 0.2)};
}
&.haven {
--color-lighter: #{$color-lighter-haven};
@@ -135,12 +115,7 @@ $color-text: white;
--color-med: #{$color-med-haven};
--color-dark: #{$color-dark-haven};
--color-darker: #{$color-darker-haven};
- --color-title: #{rgba(
- red($color-med-haven),
- green($color-med-haven),
- blue($color-med-haven),
- 0.2
- )};
+ --color-title: #{rgba(red($color-med-haven), green($color-med-haven), blue($color-med-haven), 0.2)};
}
&.shrouded {
--color-lighter: #{$color-lighter-shrouded};
@@ -148,12 +123,7 @@ $color-text: white;
--color-med: #{$color-med-shrouded};
--color-dark: #{$color-dark-shrouded};
--color-darker: #{$color-darker-shrouded};
- --color-title: #{rgba(
- red($color-med-shrouded),
- green($color-med-shrouded),
- blue($color-med-shrouded),
- 0.2
- )};
+ --color-title: #{rgba(red($color-med-shrouded), green($color-med-shrouded), blue($color-med-shrouded), 0.2)};
}
&.tempestuous {
--color-lighter: #{$color-lighter-tempestuous};
@@ -174,12 +144,7 @@ $color-text: white;
--color-med: #{$color-med-violent};
--color-dark: #{$color-dark-violent};
--color-darker: #{$color-darker-violent};
- --color-title: #{rgba(
- red($color-med-violent),
- green($color-med-violent),
- blue($color-med-violent),
- 0.2
- )};
+ --color-title: #{rgba(red($color-med-violent), green($color-med-violent), blue($color-med-violent), 0.2)};
}
}
}