finished lobby

This commit is contained in:
Djalim Simaila 2023-01-11 11:44:52 +01:00
parent 18e2a3f30b
commit 403dbc5683
2 changed files with 16 additions and 2 deletions

View File

@ -100,7 +100,7 @@ function hideInvalidRoundsCountErrorMessage(invalidRoundsCountMessageElement) {
// Start game functions // Start game functions
function startHistoryGame() { function startHistoryGame() {
//TODO: start the history game and handle server errors + connection errors makeAPIRequest("startGame");
} }
function startChallengeGame() { function startChallengeGame() {
@ -329,6 +329,9 @@ function initSock(){
console.log("Connected !") console.log("Connected !")
}) })
socket.on("gamestart",()=>{
window.location.href = "/multi";
})
socket.on("playersjoin", (username) => { socket.on("playersjoin", (username) => {
console.log(`${username} joined`); console.log(`${username} joined`);
player_list = document.getElementsByClassName("player_names")[0]; player_list = document.getElementsByClassName("player_names")[0];
@ -341,7 +344,7 @@ function initSock(){
/** /**
* Initialize the lobby page. * Initialize the lobby page.
* *
* <p> * p>
* If the player has joined the room, the room view will be shown. In the case the player is the * If the player has joined the room, the room view will be shown. In the case the player is the
* owner of the room, the room code and the multi player mode choice will be shown and the * owner of the room, the room code and the multi player mode choice will be shown and the
* listeners to the game buttons will be done. * listeners to the game buttons will be done.

View File

@ -208,6 +208,17 @@ function changeTheme() {
} }
} }
async function startSoloGame(){
username = document.getElementById("game_username").value;
let data = {}
data["username"] = username;
await makeAPIRequest("createGame",data);
start = makeAPIRequest("startGame");
start.then(()=>{
window.location.href = "/solo";
})
}
async function startGame(){ async function startGame(){
username = document.getElementById("game_username").value; username = document.getElementById("game_username").value;
let data = {} let data = {}