No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.circleci
dist
docs
out
src
.DS_Store
.esdoc.json
.gitignore
.gitingore
README.md
app.js
package-lock.json
package.json
webpack.config.js

README.md

Classes

GameBoard
ScoreBoard
Tictactoe

GameBoard

Kind: global class
Member{char[9]}: squares - Represents the tic tac toe board.
Member{integer}: filledSquares - Stores how many squares in the board are filled with either 'X' or 'O'.

new GameBoard()

GameBoard constructor that initializes and array of characters that represents a game board for a tic tac toe game.

gameBoard.isValidInput()

Checks if input has a value between 1-9 and therefor valid.

Kind: instance method of GameBoard
Param{int}: input - An integer value from 1-9 representing a square in the scoreboard.
Return{bool}: Returns true if input has a value between 1-9, otherwise false.

gameBoard.fillSquare()

Fills a square in the game board with either 'X' or 'O' depending on the value of sign and increments squaresFilled if the value of input is between 1-9.

Kind: instance method of GameBoard
Param{input}: - An integer value from 1-9 representing a square in the scoreboard.
Param{sign}: - A char which has the value 'X' or 'O' depending on which players' turn it is.
Return{bool}: - Returns true if the square was successfully filled, otherwise false.

gameBoard.isFull()

Checks if the game board is full. If filledSquares is equal to 9 then the board is full.

Kind: instance method of GameBoard
Return{bool}: Return true if filledSquares is equals to 9, otherwise false.

gameBoard.clearBoard()

Clears the game board by setting filledSquares to 0 and every index in squares to " ".

Kind: instance method of GameBoard

gameBoard.isWinner()

Checks if the current player has won the game.

Kind: instance method of GameBoard
Param{char}: sign - Represents the current player either 'X' or 'O'.
Return{bool}: Returns true is there is a winner, otherwise false.

gameBoard.isWinnerHorizontal()

Checks the game board horizontally for any three horizontal squares that have the same value as sign.

Kind: instance method of GameBoard
Param{char}: sign - Represents the current player either 'X' or 'O'.
Return{bool}: Returns true if three horizontal squares have the same value as sign, otherwise false.

gameBoard.isWinnerVertical()

Checks the game board vertically for any three vertical squares that have the same value as sign.

Kind: instance method of GameBoard
Param{char}: sign - Represents the current player either 'X' or 'O'.
Return{bool}: Returns true if three vertically squares have the same value as sign, otherwise false.

gameBoard.isWinnerDiagonal()

Checks the game board diagonally for any three diagonal squares that have the same value as sign.

Kind: instance method of GameBoard
Param{char}: sign - Represents the current player either 'X' or 'O'.
Return{bool}: Returns true if three diagonal squares have the same value as sign, otherwise false.

gameBoard.isThreeFilled()

Checks if three squares are filled with the same sign value.

Kind: instance method of GameBoard
Param{char}: sign - Represents the current player either 'X' or 'O'.
Param{int}: index1 - An index in the square array.
Param{int}: index1 - An index in the square array.
Param{int}: index1 - An index in the square array.
Return{bool}: Returns true if there are three squares filled with the sign value, otherwise false.

ScoreBoard

Kind: global class

new ScoreBoard()

ScoreBoard constructor the initializes xWins and oWins as 0.

scoreBoard.raiseWins()

Increments either xWins or oWins depending on whether the value of sign is "X" or "O".

Kind: instance method of ScoreBoard

scoreBoard.clearScores()

Sets xWins and oWins to 0.

Kind: instance method of ScoreBoard

Tictactoe

Kind: global class
Member{gameboard}: gameBoard - Represents the tic tac toe gameboard.
Member{scoreboard}: scoreBoard - Represents the tic tac toe scoreboard.
Member{char}: sign - Represents the current player either 'X' or 'O'.

new Tictactoe()

Tictactoe constructor that intializes the starting player a 'X' and initalizes an empty game board and score board.

tictactoe.takeInput()

Takes in an integer as a parameter and filles a square in the gameboard with the value of sign beetween 1-9 corresponding to the value of input and then swaps the value of sign to 'X' or 'O' depending on the current value of sign.

Kind: instance method of Tictactoe
Param{int}: input - An integer value from 1-9 representing a square in the scoreboard.
Return{bool}: Returns whether or not input was a success.

tictactoe.showBoard()

Prints out the tic tac toe board to the console.

Kind: instance method of Tictactoe

tictactoe.startNewGame()

Sets the current player as 'X' and clears the game board and the score board

Kind: instance method of Tictactoe

tictactoe.play()

Starts a tic tac toe game, and calls itself recursively until either player wins or the game ends in a draw. If either player wins raise either xWins og oWins in the score board depending if 'X' or 'O' won.

Kind: instance method of Tictactoe