WIP, tout est en chantier, très content :)

This commit is contained in:
LuckyLaszlo
2022-11-20 15:46:45 +01:00
parent 023b5ed485
commit 48665cfe30
22 changed files with 580 additions and 302 deletions

View File

@@ -1,37 +1,66 @@
/* Server */
enum EventTypes {
gameUpdate = 1,
start,
pause,
resume
import * as en from "../enums.js"
/* From Server */
class ServerEvent {
type: en.EventTypes;
constructor(type: en.EventTypes = 0) {
this.type = type;
}
}
interface EventData {
type: EventTypes;
class EventAssignId extends ServerEvent {
id: string;
constructor(id: string) {
super(en.EventTypes.assignId);
this.id = id;
}
}
class EventGameUpdate implements EventData {
type: EventTypes = EventTypes.gameUpdate;
player1 = {y: 0};
player2 = {y: 0};
class EventMatchmakingComplete extends ServerEvent {
side: en.PlayerSide;
constructor(side: en.PlayerSide) {
super(en.EventTypes.matchmakingComplete);
this.side = side;
}
}
class EventGameUpdate extends ServerEvent {
playerLeft = {y: 0};
playerRight = {y: 0};
ball = {x: 0, y: 0, speed: 0};
constructor() {
super(en.EventTypes.gameUpdate);
}
}
/* Client */
enum InputEnum {
up = 1,
down
/* From Client */
class ClientEvent {
type: en.EventTypes;
constructor(type: en.EventTypes = 0) {
this.type = type;
}
}
class EventInput {
input: InputEnum;
constructor(input: InputEnum = 0) {
class ClientAnnounce extends ClientEvent {
role: en.ClientRole;
id: string;
constructor(role: en.ClientRole, id: string = "") {
super(en.EventTypes.clientAnnounce);
this.role = role;
}
}
class EventInput extends ClientEvent {
input: en.InputEnum;
constructor(input: en.InputEnum = 0) {
super(en.EventTypes.clientInput);
this.input = input;
}
}
export {
EventTypes, EventData, EventGameUpdate,
InputEnum, EventInput
ServerEvent, EventAssignId, EventMatchmakingComplete, EventGameUpdate,
ClientEvent, ClientAnnounce, EventInput
}