Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Player } from './player';
  2.  
  3. export function makeMessage(type: string, payload: object | null = null): ETTPOutgoingMsg {
  4.   return payload ? { type, payload } : { type };
  5. }
  6.  
  7. export interface BaseMsg {};
  8.  
  9. export const LOBBY_MESSAGE = 0;
  10. export const ROOM_MESSAGE = 1;
  11. export const PRIVATE_MESSAGE = 2;
  12.  
  13. export interface ChartMsg extends BaseMsg {
  14.   title: string;
  15.   subtitle: string;
  16.   artist: string;
  17.   filehash: string;
  18.   chartkey: string;
  19.   rate: number;
  20.   difficulty: number;
  21.   meter: number;
  22. }
  23.  
  24. export interface ChatMsg extends BaseMsg {
  25.   msg: string;
  26.   msgtype: number;
  27.   tab: string;
  28.   [key: string]: string | number;
  29. }
  30.  
  31. export interface RoomMsg extends BaseMsg {
  32.   name: string;
  33.   desc: string;
  34.   pass: string;
  35. }
  36.  
  37. export interface EnterRoomMsg extends BaseMsg {
  38.   name: string;
  39.   pass: string | null;
  40.   desc: string | null;
  41. }
  42.  
  43. export interface LoginMsg extends BaseMsg {
  44.   user: string;
  45.   pass: string;
  46. }
  47.  
  48. export interface StartingChartMsg extends BaseMsg {}
  49.  
  50. export interface MissingChartMsg extends BaseMsg {}
  51.  
  52. export interface HasChartMsg extends BaseMsg {}
  53. export interface GameOverMsg extends BaseMsg {}
  54. export interface PingMsg extends BaseMsg {}
  55. export interface LeaveOptionsMsg extends BaseMsg {}
  56. export interface EnterOptiongMsg extends BaseMsg {}
  57. export interface LogoutMsg extends BaseMsg {}
  58. export interface LeaveRoomMsg extends BaseMsg {}
  59. export type CreateRoomMsg = RoomMsg;
  60. export interface ScoreMsg extends BaseMsg {}
  61. export interface LeaveEvalMsg extends BaseMsg {}
  62. export interface GameplayUpdateMsg extends BaseMsg {
  63.   wife: number;
  64.   jdgstr: string;
  65. }
  66. export interface EnterEvalMsg extends BaseMsg {}
  67.  
  68. export interface HelloMsg extends BaseMsg {
  69.   version: string;
  70.   client: string;
  71.   packs: string[] | null;
  72. }
  73.  
  74. export type ETTPMsgHandler = (player: Player, message: BaseMsg) => void;
  75.  
  76. export interface ETTPMsgHandlers {
  77.   [key: string]: BaseMsg;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement