Skip to content

Commit

Permalink
2 folder added, 1 file mooved, 2 file added, 1 file renamed, 1 file e…
Browse files Browse the repository at this point in the history
…dited
  • Loading branch information
Croc-Prog-github authored May 14, 2024
1 parent 0e2bc45 commit bfc0339
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
File renamed without changes.
14 changes: 14 additions & 0 deletions game/multiP/CreaSq/CreaSq_client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Funzione per gestire la creazione di una nuova stanza
function createNewRoom() {
// Fai una richiesta al server per creare una nuova stanza
fetch('http://localhost:2567/createRoom')
.then(response => response.json())
.then(data => {
// Aggiorna l'interfaccia utente con RoomId e SessionId ottenuti dal server
document.getElementById('roomId').textContent = data.roomId;
document.getElementById('sessionId').textContent = data.sessionId;
})
.catch(error => {
console.error('Error creating room:', error);
});
}
30 changes: 30 additions & 0 deletions game/multiP/CreaSq/CreaSq_server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Importa Colyseus
const { Server } = require("colyseus");

// Crea una nuova istanza del server Colyseus
const server = new Server();

// Definisci una classe per la tua stanza di gioco
class MyRoom extends Room {
// Implementa la logica per la creazione della stanza
onCreate(options) {
// Genera un RoomId univoco
const roomId = generateUniqueId();

// Crea la stanza con il RoomId generato
this.setState({ roomId });

// Assegna un SessionId al giocatore
const sessionId = generateUniqueId();
this.assignSessionId(this.connectedClients[0], sessionId);

// Invia RoomId e SessionId al giocatore
this.sendToClient(this.connectedClients[0], { roomId, sessionId });
}
}

// Registra la tua stanza con il server Colyseus
server.define("my_room", MyRoom);

// Avvia il server sulla porta desiderata
server.listen(2567);
File renamed without changes.
7 changes: 3 additions & 4 deletions game/multiP/onlineUser.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@
<div name="account ospite">
<div style="width: -webkit-fill-available; margin-top: 0.5em; display: flex;flex-direction: column;align-items: center;">
<div style="display: flex;">
<button class="NewButt" style="margin-inline: 5px;border: solid 1px black;border-bottom: solid 2px black;border-radius: 3px;text-shadow: 0px 1.4px 0px black;box-shadow: 0 2px 1px 0px #0000004d;color: white;background: dodgerblue;text-transform: uppercase;/*font-weight: bold;*/ cursor: pointer;">Crea codice squadra</button>
<button class="NewButt" onclick="CreaCodSq()" style="margin-inline: 5px;border: solid 1px black;border-bottom: solid 2px black;border-radius: 3px;text-shadow: 0px 1.4px 0px black;box-shadow: 0 2px 1px 0px #0000004d;color: white;background: dodgerblue;text-transform: uppercase;/*font-weight: bold;*/ cursor: pointer;">Crea codice squadra</button>
<button class="NewButt" style="margin-inline: 5px;border: solid 1px black;border-bottom: solid 2px black;border-radius: 3px;text-shadow: 0px 1.4px 0px black;box-shadow: 0 2px 1px 0px #0000004d;color: white;background: dodgerblue;text-transform: uppercase;/*font-weight: bold;*/ cursor: pointer;">Entra con codice</button>
</div>

<input type="text" maxlength="6" id="SquadInp" oninput="ToggleButton();" autocomplete="off" placeholder="ABC123" style="margin-top: 10px; width: 50%; font-size: 1.5em; text-transform: uppercase; user-select: all; outline-style: none; letter-spacing: 6px; text-align: center; font-weight: bold;">
<input type="text" hidden maxlength="6" id="SquadInp" oninput="ToggleButton();" autocomplete="off" placeholder="ABC123" style="margin-top: 10px; width: 50%; font-size: 1.5em; text-transform: uppercase; user-select: all; outline-style: none; letter-spacing: 6px; text-align: center; font-weight: bold;">

<div style="display: flex; margin-top: 0.5em;">
<button hidden id="EsciDaSquad" style="margin-inline: 5px;border: solid 1px black;border-bottom: solid 2px black;border-radius: 3px;text-shadow: 0px 1.4px 0px black;box-shadow: 0 2px 1px 0px #0000004d;color: white; background: indianred; text-transform: uppercase;/*font-weight: bold;*/ cursor: pointer;">Esci dalla squadra</button>
Expand Down Expand Up @@ -103,8 +103,7 @@
let regex = /^[a-zA-Z]{3}[0-9]{3}$/; // Verifica se ci sono 3 lettere seguite da 3 numeri
if (regex.test(SquadInp.value)) {
console.log("Controllo formato codice superato, inizializzo...");

ConnectWithCode();
//Continua da qui
} else {
window.alert('Formato non valido');
}
Expand Down

0 comments on commit bfc0339

Please sign in to comment.