mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 02:10:18 +01:00
Implemented player login
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import { Socket } from "socket.io";
|
||||
|
||||
export default class Game {
|
||||
constructor() {
|
||||
this.teams = [];
|
||||
@@ -31,7 +29,8 @@ export default class Game {
|
||||
chased: null,
|
||||
currentLocation: [0, 0],
|
||||
lastSentLocation: [0, 0],
|
||||
enemyLocation: [0, 0]
|
||||
enemyLocation: [0, 0],
|
||||
sockets: []
|
||||
});
|
||||
this.updateTeamChasing();
|
||||
return true;
|
||||
|
||||
@@ -158,7 +158,9 @@ io.of("player").on("connection", (socket) => {
|
||||
|
||||
socket.on("disconnect", () => {
|
||||
console.log("user disconnected");
|
||||
game.getTeam(teamId).sockets = game.getTeam(teamId).sockets.filter(s => s !== socket.id);
|
||||
if(teamId !== null && game.getTeam(teamId) !== undefined){
|
||||
game.getTeam(teamId).sockets = game.getTeam(teamId).sockets.filter(s => s !== socket.id);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("login", (teamId) => {
|
||||
@@ -175,7 +177,6 @@ io.of("player").on("connection", (socket) => {
|
||||
});
|
||||
|
||||
socket.on("send_position", () => {
|
||||
console.log("send_position", position);
|
||||
game.sendLocation(teamId);
|
||||
game.getTeam(teamId).sockets.forEach(s => {
|
||||
io.of("player").to(s).emit("enemy_position", game.getTeam(teamId).enemyLocation);
|
||||
|
||||
Reference in New Issue
Block a user