Class: Game

TicTacToe# Game


new Game(players, msg)

Class that stores the current state of a tic tac toe game.
Parameters:
Name Type Description
players Object The players in this game.
msg Discord~Message The message displaying the current game.
Source:

Members


board :Array.<number>

An array of 9 elements that stores 0, 1, or 2 to signify who owns which space of the board. 0 is nobody, 1 is player 1, 2 is player 2.
Type:
  • Array.<number>
Source:

msg :Discord~Message

The message displaying the current game.
Type:
  • Discord~Message
Source:

players :Object

The players in this game.
Type:
  • Object
Source:

turn :number

Which player's turn it is. Either 1 or 2.
Type:
  • number
Source:

<private, inner, constant> boardString :string

The template string for the game's board.
Type:
  • string
Source:

Methods


print( [winner])

Edit the current message to show the current board.
Parameters:
Name Type Argument Default Description
winner number <optional>
0 The player who has won the game. 0 is game not done, 1 is player 1, 2 is player 2, 3 is draw.
Source: