import * as en from "../enums.js"; /* From Server */ export class ServerEvent { constructor(type = 0) { this.type = type; } } export class EventAssignId extends ServerEvent { constructor(id) { super(en.EventTypes.assignId); this.id = id; } } export class EventMatchmakingComplete extends ServerEvent { constructor(side) { super(en.EventTypes.matchmakingComplete); this.side = side; } } export class EventGameUpdate extends ServerEvent { constructor() { super(en.EventTypes.gameUpdate); this.playerLeft = { y: 0 }; this.playerRight = { y: 0 }; this.ballsArr = []; this.wallTop = { y: 0 }; this.wallBottom = { y: 0 }; this.lastInputId = 0; } } export class EventScoreUpdate extends ServerEvent { constructor(scoreLeft, scoreRight) { super(en.EventTypes.scoreUpdate); this.scoreLeft = scoreLeft; this.scoreRight = scoreRight; } } export class EventMatchEnd extends ServerEvent { constructor(winner, forfeit = false) { super(en.EventTypes.matchEnd); this.winner = winner; this.forfeit = forfeit; } } /* From Client */ export class ClientEvent { constructor(type = 0) { this.type = type; } } export class ClientAnnounce extends ClientEvent { constructor(role) { super(en.EventTypes.clientAnnounce); this.role = role; } } export class ClientAnnouncePlayer extends ClientAnnounce { constructor(matchOptions, clientId = "") { super(en.ClientRole.player); this.clientId = clientId; this.matchOptions = matchOptions; } } export class ClientAnnounceSpectator extends ClientAnnounce { constructor(gameSessionId) { super(en.ClientRole.spectator); this.gameSessionId = gameSessionId; } } export class EventInput extends ClientEvent { constructor(input = en.InputEnum.noInput, id = 0) { super(en.EventTypes.clientInput); this.input = input; this.id = id; } }