Class Game

Class for handling user game event

Hierarchy

  • Game

Constructors

  • Game class constructor

    Parameters

    • gameData: {
          allPlayers: {}[];
          bannedPlayers: {}[];
          cards: {}[];
          playerOrders: {}[];
      } & {}

      Game document by specific user

    • chat: Chat

      Chat message instance

    Returns Game

Properties

chat: Chat

Chat message instance

game: {
    allPlayers: {}[];
    bannedPlayers: {}[];
    cards: {}[];
    playerOrders: {}[];
} & {}

Game document by specific user

Type declaration

  • allPlayers: {}[]
  • bannedPlayers: {}[]
  • cards: {}[]
  • playerOrders: {}[]

Type declaration

    Accessors

    • get NotFound(): boolean
    • Get if this game is not found

      Returns boolean

    • get created_at(): Date
    • Get this game a time when it's created

      Returns Date

    • get currentCard(): null | string
    • Get current card of this game

      Returns null | string

    • get currentPlayerIsAuthor(): boolean
    • Get if current player is an author of this game

      Returns boolean

    • get currentPositionId(): null | number
    • Get this game current position id

      Returns null | number

    • get gameID(): string
    • Get this game session human readable id

      Returns string

    • get isCurrentChatTurn(): boolean
    • Get if current chatter is it turn to play

      Returns boolean

    • get isGameCreator(): boolean
    • Get if current chatter is game creator or not

      Returns boolean

    • get playersOrderIds(): number[]
    • Get list of all players order id

      Returns number[]

    • get state(): {
          ENDED: boolean;
          PLAYING: boolean;
          WAITING: boolean;
      }
    • Get this game current state

      Returns {
          ENDED: boolean;
          PLAYING: boolean;
          WAITING: boolean;
      }

      • ENDED: boolean
      • PLAYING: boolean
      • WAITING: boolean
    • get translatedStatus(): "Menunggu Pemain" | "Sedang Bermain" | "Selesai Bermain" | "N/A"
    • Get this game human readable status

      Returns "Menunggu Pemain" | "Sedang Bermain" | "Selesai Bermain" | "N/A"

    • get winner(): null | number
    • Get this game winner player id if there is a winner

      Returns null | number

    Methods

    • Abstract function that used for checking specific player is it turn or not

      Parameters

      • user: {}

        The specific player

        Returns boolean

        Boolean that indicate is player turn or not

      • Function for adding user on banned player array

        Parameters

        • id: number

          Specific user id

        Returns Promise<void>

      • Function for end current game

        Returns Promise<void>

      • Get all player user document

        Returns Promise<(null | {})[]>

      • Get user document that created this game

        Returns Promise<null | {}>

      • Get current player user document

        Returns Promise<null | {}>

      • Function for retrieve elapsed since game started and ended

        Returns string

        Human readable elapsed time

      • Function that will retrieve user next position

        Parameters

        • increment: number = 1

          What is N-Position next player (default 1)

        Returns undefined | {}

        User specific id document

      • Function for retrieve if given player was already banned

        Parameters

        • id: number

          Specific user id

        Returns boolean

        True or false boolean

      • Function for joining current game

        Returns Promise<void>

      • Function for updating user gameProperty for not joining game session anymore

        Parameters

        • id: number

          Specific user id

        Returns Promise<void>

      • Function for removing user from player array (leaving, get kicked)

        Parameters

        • id: number

          Specific user id

        Returns Promise<void>

      • Function for reversing players order (uno reverse card)

        Returns Promise<void>

      • Send message or message with image caption to desired players list

        Parameters

        • message: MessageContent | MessageSendOptions

          Text that will sended

        • players: {}[]

          Desired player list

        • Optional image: MessageMedia

          Image that will send (optional)

        Returns Promise<void>

      • Function for set game creator

        Parameters

        • id: number

        Returns Promise<void>

      • Function for set game winner

        Parameters

        • id: number

        Returns Promise<void>

      • Function for starting current game

        Returns Promise<void>

      • Function for updating game current card and current position

        Parameters

        • card: allCard

          Valid given card

        • position: number

          User specific id

        Returns Promise<void>

      • Function for updating game current position

        Parameters

        • position: number

          User specific id

        Returns Promise<void>

      Generated using TypeDoc