Add code bodies to the hostGame and joinGame methods

This commit is contained in:
Oliver Akins 2022-03-12 22:14:37 -06:00
parent 826b118548
commit df6b8a0875
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99

View file

@ -1,5 +1,8 @@
<script lang="ts"> <script lang="ts">
import type { ICreateLobby, IJoinLobby } from "common";
import SciFiButton from "../components/SciFi-Button.svelte"; import SciFiButton from "../components/SciFi-Button.svelte";
import { socket } from "../main";
const invalidUsername = /[^A-Z\-\_\ ]/i; const invalidUsername = /[^A-Z\-\_\ ]/i;
@ -15,10 +18,20 @@ function getUsername() {
}; };
function hostGame() { function hostGame() {
let username = getUsername(); let data: ICreateLobby = {
name: getUsername(),
};
socket.once(`res:lobby.create`, (data) => {console.log(data)});
socket.emit(`req:lobby.create`, data)
}; };
function joinGame() {}; function joinGame() {
let data: IJoinLobby = {
name: getUsername(),
game_code: prompt("Enter the lobby's room ID:")
};
socket.emit(`req:lobby.players.join`, data)
};
function singleplayerGame() {}; function singleplayerGame() {};
</script> </script>