Add code bodies to the hostGame and joinGame methods
This commit is contained in:
parent
826b118548
commit
df6b8a0875
1 changed files with 15 additions and 2 deletions
|
|
@ -1,5 +1,8 @@
|
|||
<script lang="ts">
|
||||
import type { ICreateLobby, IJoinLobby } from "common";
|
||||
|
||||
import SciFiButton from "../components/SciFi-Button.svelte";
|
||||
import { socket } from "../main";
|
||||
|
||||
const invalidUsername = /[^A-Z\-\_\ ]/i;
|
||||
|
||||
|
|
@ -15,10 +18,20 @@ function getUsername() {
|
|||
};
|
||||
|
||||
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() {};
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue