aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-04-23 11:28:40 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-04-23 11:28:40 +0200
commit8cda16d1c9b57ce2b49983b79afd09c8d2320477 (patch)
tree7092212f73df2e224ebe228e084b34f7e09d463d /web/pw-server/src
parent6a39dc214a877515bc2d5494b5975b513f4c1628 (diff)
downloadplanetwars.dev-8cda16d1c9b57ce2b49983b79afd09c8d2320477.tar.xz
planetwars.dev-8cda16d1c9b57ce2b49983b79afd09c8d2320477.zip
show rules on first visit
Diffstat (limited to 'web/pw-server/src')
-rw-r--r--web/pw-server/src/lib/bot_code.ts6
-rw-r--r--web/pw-server/src/routes/index.svelte5
2 files changed, 9 insertions, 2 deletions
diff --git a/web/pw-server/src/lib/bot_code.ts b/web/pw-server/src/lib/bot_code.ts
index 088db72..688587e 100644
--- a/web/pw-server/src/lib/bot_code.ts
+++ b/web/pw-server/src/lib/bot_code.ts
@@ -2,7 +2,7 @@ import defaultBotCode from "../assets/bot_template.txt?raw";
const BOT_CODE_KEY = "bot_code";
-export function getBotCode() {
+export function getBotCode(): string {
let botCode = localStorage.getItem(BOT_CODE_KEY);
if (!botCode) {
botCode = defaultBotCode;
@@ -10,6 +10,10 @@ export function getBotCode() {
return botCode;
}
+export function hasBotCode(): boolean {
+ return !!localStorage.getItem(BOT_CODE_KEY);
+}
+
export function saveBotCode(botCode: string) {
localStorage.setItem(BOT_CODE_KEY, botCode);
}
diff --git a/web/pw-server/src/routes/index.svelte b/web/pw-server/src/routes/index.svelte
index 055112a..32efe69 100644
--- a/web/pw-server/src/routes/index.svelte
+++ b/web/pw-server/src/routes/index.svelte
@@ -8,7 +8,7 @@
import type { Ace } from "ace-builds";
import ace from "ace-builds/src-noconflict/ace?client";
import * as AcePythonMode from "ace-builds/src-noconflict/mode-python?client";
- import { getBotCode, saveBotCode } from "$lib/bot_code";
+ import { getBotCode, saveBotCode, hasBotCode } from "$lib/bot_code";
import { debounce } from "$lib/utils";
import SubmitPane from "$lib/components/SubmitPane.svelte";
import OutputPane from "$lib/components/OutputPane.svelte";
@@ -29,6 +29,9 @@
let editSession: Ace.EditSession;
onMount(() => {
+ if (!hasBotCode()) {
+ viewMode = ViewMode.Rules;
+ }
init_editor();
});