dataType.ts 883 Bytes
import {
  Boolean,
  Number,
  String,
  Literal,
  Array,
  Tuple,
  Record,
  Union,
  Static,
} from "runtypes";

export const UserDataRecord = Record({
  username: String,
});

export type UserData = Static<typeof UserDataRecord>;

/**
 * 방 리스트에서 사용됩니다.
 */
export const RoomDescriptionRecord = Record({
  uuid: String,
  name: String,
  currentUsers: Number,
  maxUsers: Number,
});

export type RoomDescription = Static<typeof RoomDescriptionRecord>;

/**
 * 방에 접속했을 때 사용됩니다.
 */
export const RoomInfoRecord = Record({
  uuid: String,
  name: String,
  maxUsers: Number,
  users: Array(
    Record({
      username: String,
      nickname: String,
      admin: Boolean,
      ready: Boolean,
    })
  ),
});

export type RoomInfo = Static<typeof RoomInfoRecord>;

export type Role = "drawer" | "guesser" | "winner" | "spectator";