From 7cba61a92f1a1fb9237debdae98749e880f345c2 Mon Sep 17 00:00:00 2001 From: vvandenb Date: Fri, 10 Mar 2023 10:25:56 +0100 Subject: [PATCH] * (again) Modifications for fake users in pong game --- front/volume/src/App.svelte | 25 +++++++++++-- front/volume/src/FakeLogin.svelte | 36 +++++++++++++++++++ .../src/components/Pong/GameCreation.svelte | 4 +-- front/volume/src/components/Pong/Pong.svelte | 3 +- 4 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 front/volume/src/FakeLogin.svelte diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte index 3396572..f52486c 100644 --- a/front/volume/src/App.svelte +++ b/front/volume/src/App.svelte @@ -14,8 +14,8 @@ import type { ChannelsType } from "./components/Channels.svelte"; import Leaderboard from "./components/Leaderboard.svelte"; import type { Player } from "./components/Leaderboard.svelte"; - import { store, getUser, login, logout, API_URL } from "./Auth"; + import FakeLogin from "./FakeLogin.svelte"; // PROFILE @@ -145,6 +145,20 @@ isLeaderboardOpen = true; leaderboard = await getLeader(); } + + let usernameFake = "test"; + let ftIdFake = "42"; + let fakemenu = true; + let fakeUser = false; + function impersonate() { + const user = { + username: "test", + socketKey: "42", + }; + store.set(user) + fakeUser = true + fakemenu = false + }
@@ -236,7 +250,14 @@ {/if} - + + {#if fakemenu} + + + + {:else} + + {/if} {/if}
diff --git a/front/volume/src/FakeLogin.svelte b/front/volume/src/FakeLogin.svelte new file mode 100644 index 0000000..12fc985 --- /dev/null +++ b/front/volume/src/FakeLogin.svelte @@ -0,0 +1,36 @@ + + +
+ + + +

Result: {result}

+
+ \ No newline at end of file diff --git a/front/volume/src/components/Pong/GameCreation.svelte b/front/volume/src/components/Pong/GameCreation.svelte index ac042f4..4f970d6 100644 --- a/front/volume/src/components/Pong/GameCreation.svelte +++ b/front/volume/src/components/Pong/GameCreation.svelte @@ -4,8 +4,8 @@ import { DEFAULT_MAP_SIZE, GAME_EVENTS } from "./constants"; import MapCustomization from "./MapCustomization.svelte"; import type { GameCreationDto } from "./dtos/GameCreationDto"; + import { store } from "../../Auth"; - export let username: string; export let socket: WebSocket; let map: Map = new Map(DEFAULT_MAP_SIZE.clone(), []); @@ -13,7 +13,7 @@ function createGame() { const data: GameCreationDto = { - playerNames: [username, otherUsername], + playerNames: [$store.username, otherUsername], map, }; socket.send(formatWebsocketData(GAME_EVENTS.CREATE_GAME, data)); diff --git a/front/volume/src/components/Pong/Pong.svelte b/front/volume/src/components/Pong/Pong.svelte index 2a76ee2..fdc744c 100644 --- a/front/volume/src/components/Pong/Pong.svelte +++ b/front/volume/src/components/Pong/Pong.svelte @@ -11,6 +11,8 @@ import { getUser, store } from "../../Auth"; import ColorPicker from "./ColorPicker.svelte"; + export let fakeUser; + const SERVER_URL = `ws://${import.meta.env.VITE_HOST}:${ import.meta.env.VITE_BACK_PORT }`; @@ -166,7 +168,6 @@
- {:else if createMatchWindow}
(createMatchWindow = false)}