This commit is contained in:
2023-10-09 22:15:28 +02:00
parent a769ffc8fd
commit 3238cead4d
17 changed files with 310 additions and 236 deletions

21
Account/_login.ts Normal file
View File

@@ -0,0 +1,21 @@
import { userData } from "../Classes/userData";
import { players } from "../Player/players";
import { emitLogin } from "./_emitLogin";
import { users } from "./users";
export function login(socket, data){
let buff = Buffer.from(data, 'base64');
let json : userData = JSON.parse(buff.toString('utf-8'));
if (!json.login || !json.password) return
let result = users.readUser(json.login, json.password);
let player = null
if(result != null){
player = players.readPlayer(result.id)
if(player == null){
player = players.createPlayer(result.id)
}
}
emitLogin(socket, result, player);
}