diff --git a/src/components/Log.svelte b/src/components/Log.svelte
index 5aa3809..9d35236 100644
--- a/src/components/Log.svelte
+++ b/src/components/Log.svelte
@@ -2,42 +2,40 @@
import { Message, MessageType } from "../shark/Message";
import { SharkGame } from "../shark/SharkGame";
- export function addMessage(
+ export let messages: Message[];
+
+ function addMessage(
message: string,
- type: MessageType = MessageType.message
- ): void {
- SharkGame.messages = [
- ...SharkGame.messages.slice(
- -Math.max(...SharkGame.Settings.logLength.options)
- ),
- new Message(message, type),
- ];
+ messageType: MessageType = MessageType.message
+ ) {
+ messages = [...messages, new Message(message, messageType)];
}
$: logLength = SharkGame.Settings.logLength.current;
- $: displaymessages = [...SharkGame.messages].slice(-logLength).reverse();
+ $: displaymessages = messages.slice(-logLength).reverse();
Add Message
Add Warning
Add Error
diff --git a/src/components/Wrapper.svelte b/src/components/Wrapper.svelte
index e099ba2..811048f 100644
--- a/src/components/Wrapper.svelte
+++ b/src/components/Wrapper.svelte
@@ -1,4 +1,5 @@
@@ -6,7 +7,7 @@
-
+
diff --git a/src/shark/Log.ts b/src/shark/Log.ts
new file mode 100644
index 0000000..6c7892c
--- /dev/null
+++ b/src/shark/Log.ts
@@ -0,0 +1,15 @@
+import type { Message } from "./Message";
+import { SharkGame } from "./SharkGame";
+import { StaticClass } from "./StaticClass";
+
+export class Log extends StaticClass {
+ static #messages: Message[] = [];
+ static get messages(): Message[] {
+ return this.#messages;
+ }
+ static set messages(messages: Message[]) {
+ this.#messages = messages.slice(
+ -Math.max(...SharkGame.Settings.logLength.options)
+ );
+ }
+}
diff --git a/src/shark/SharkGame.ts b/src/shark/SharkGame.ts
index a9de521..f728b71 100644
--- a/src/shark/SharkGame.ts
+++ b/src/shark/SharkGame.ts
@@ -1,4 +1,4 @@
-import { Message } from "./Message";
+import { Log } from "./Log";
import { Settings } from "./Settings";
import { StaticClass } from "./StaticClass";
@@ -54,7 +54,7 @@ export class SharkGame extends StaticClass {
static title: string;
static readonly Settings = Settings;
- static messages: Message[] = [new Message("Welcome to Sharg!")];
+ static readonly Log = Log;
static init(): void {
for (const setting of Object.values(Settings)) {