37 lines
961 B
TypeScript
37 lines
961 B
TypeScript
|
|
import { WebSocket } from "../wsServer.js";
|
|
import { Racket } from "../../shared_js/class/Rectangle.js";
|
|
import { GameSession } from "./GameSession.js";
|
|
import * as ev from "../../shared_js/class/Event.js"
|
|
import * as en from "../../shared_js/enums.js"
|
|
|
|
class Client {
|
|
socket: WebSocket;
|
|
id: string; // Pas indispensable si "socket" a une copie de "id"
|
|
isAlive: boolean = true;
|
|
gameSession: GameSession = null;
|
|
matchOptions: en.MatchOptions = 0;
|
|
constructor(socket: WebSocket, id: string) {
|
|
this.socket = socket;
|
|
this.id = id;
|
|
}
|
|
}
|
|
|
|
class ClientPlayer extends Client {
|
|
inputBuffer: ev.EventInput = new ev.EventInput();
|
|
lastInputId: number = 0;
|
|
racket: Racket;
|
|
constructor(socket: WebSocket, id: string, racket: Racket) {
|
|
super(socket, id);
|
|
this.racket = racket;
|
|
}
|
|
}
|
|
|
|
class ClientSpectator extends Client { // Wip, unused
|
|
constructor(socket: WebSocket, id: string) {
|
|
super(socket, id);
|
|
}
|
|
}
|
|
|
|
export {Client, ClientPlayer, ClientSpectator}
|