authoritative server OK

+ TODO actual matchmaking
This commit is contained in:
LuckyLaszlo
2022-11-21 19:46:25 +01:00
parent 48665cfe30
commit add08c216f
20 changed files with 485 additions and 240 deletions

View File

@@ -29,11 +29,28 @@ class EventGameUpdate extends ServerEvent {
playerLeft = {y: 0};
playerRight = {y: 0};
ball = {x: 0, y: 0, speed: 0};
constructor() {
constructor() { // TODO: constructor that take GameComponentsServer maybe ?
super(en.EventTypes.gameUpdate);
}
}
class EventScoreUpdate extends ServerEvent {
scoreLeft: number;
scoreRight: number;
constructor(scoreLeft: number, scoreRight: number) {
super(en.EventTypes.scoreUpdate);
this.scoreLeft = scoreLeft;
this.scoreRight = scoreRight;
}
}
class EventMatchEnd extends ServerEvent {
winner: en.PlayerSide;
constructor(winner: en.PlayerSide) {
super(en.EventTypes.matchEnd);
}
}
/* From Client */
class ClientEvent {
@@ -49,6 +66,7 @@ class ClientAnnounce extends ClientEvent {
constructor(role: en.ClientRole, id: string = "") {
super(en.EventTypes.clientAnnounce);
this.role = role;
this.id = id;
}
}
@@ -61,6 +79,7 @@ class EventInput extends ClientEvent {
}
export {
ServerEvent, EventAssignId, EventMatchmakingComplete, EventGameUpdate,
ServerEvent, EventAssignId, EventMatchmakingComplete,
EventGameUpdate, EventScoreUpdate, EventMatchEnd,
ClientEvent, ClientAnnounce, EventInput
}