Numbers

0.0.1-alpha2

CellComp

Component that renders the value of a Cell.

CellComp
Parameters
props (object)
Name Description
props.onClick function Function to be triggered when component is clicked.
props.value number Value of Cell .
props.isSelectable boolean Whether the cell is selectable.
props.turn string Current turn, one of TURNS .
props.taken boolean Whether the cell is taken.
props.undefined any (default 'cell-comp')

CellEffectsComp

Functional Component that renders the Token in a Game.

CellEffectsComp
Parameters
props (object)
Name Description
props.rowIndex number Row index of the Token .
props.colIndex number Column index of the Token .
props.turn number Current turn, one of TURNS .
props.soundEnabled boolean Whether sound is enabled.
props.soundLocked boolean Whether sound is locked.
props.undefined any (default 'cell-effects-comp')

ControlsComp

Functional Component that renders the game controls.

ControlsComp
Parameters
props (object)
Name Description
props.soundEnabled boolean Whether sound is enabled.
props.controlsLocked boolean Whether controls are locked.
props.toggleSound function Function to toggle sound.
props.reset function Function to reset the game.
props.undefined any

GameComp

Functional Component that renders a Game.

GameComp
Parameters
props (object)
Name Description
props.board array 2 dimensional array of numbers representing the values of Cells in a Board .
props.player1Direction string Direction of player 1, one of PLAYER_DIRECTIONS .
props.player2Direction string Direction of player 2, one of PLAYER_DIRECTIONS .
props.undefined any (default 'game-comp')

GameEndComp

Functional Component that renders an overlay when a Game ends.

GameEndComp
Parameters
props (object)
Name Description
props.isOver boolean Whether the game is over.
props.result number The result of the game.
props.soundEnabled boolean Whether sound is enabled.
props.soundLocked boolean Whether sound is locked.
props.reset function Function to reset the Game .
props.undefined any (default 'game-end-comp')

ScoreComp

Functional Component that renders the score of a Player.

ScoreComp
Parameters
props (object)
Name Description
props.score number Score of a Player .
props.name string Name to identify the Player .
props.direction string Direction of the Player .
props.undefined any (default 'score-comp')

WildCardComp

Functional Component that renders the Token in a Game.

WildCardComp
Parameters
props (object)
Name Description
props.rowIndex number Row index of the Token .
props.colIndex number Column index of the Token .
props.undefined any (default 'wild-card-comp')

CellCont

Container to connect a CellComp.

CellCont
Parameters
props (object)
Name Description
props.rowIndex number Row index of the Cell in a Board .
props.colIndex number Column index of the Cell in a Board .
props.value number Value of the Cell .

CellEffectsCont

Container to connect a CellEffectsComp.

CellEffectsCont
Parameters
props (object)

ControlsCont

Container to connect a ControlsComp.

ControlsCont
Parameters
props (object)

GameCont

Container to connect a GameComp.

GameCont
Parameters
props (object)
Name Description
props.boardSize number Size of a Board .

GameEndCont

Container to connect a GameEndComp.

GameEndCont
Parameters
props (object)
Name Description
props.boardSize number Size of a Board .

ScoreCont

Container to connect a ScoreComp.

ScoreCont
Parameters
props (object)
Name Description
props.playerName number Flag to identify a Player . See flags.TURNS .
props.direction number Flag to identify a Player 's direction. See flags.PLAYER_DIRECTIONS .

WildCardCont

Container to connect a WildCardComp.

WildCardCont
Parameters
props (object)

LocalStorageManager

Class to save and retrieve the state of the application in local storage. It is based on this code.

new LocalStorageManager()
Instance Members
▸ getGameState()
▸ setGameState(gameState)
▸ clearGameState()

Agent

Class representing an agent. An agent is a Player that plays the game following a certain criteria. It is considered a type of AI.

new Agent()

Extends Player

Instance Members
▸ getMaxValuePosition(token, boardMatrix)
▸ getPositionToEndGameWithVictory(token, boardMatrix, scores)
▸ getMaxGainValuePosition(token, boardMatrix, scores)
▸ getBestAverageValuePosition(token, boardMatrix)

Board

Class representing a board. A board has a matrix of Cells.

new Board(boardSize: number, matrix: array?)
Parameters
boardSize (number)
matrix (array?) 2 dimensional array of numbers. If this parameter is given, boardSize is ignored.
Instance Members
▸ updateFromMatrix(matrix)
▸ updateFromVector(vector)
▸ updateFromScratch(boardSize)
▸ isCellSelectable(rowIndex, colIndex)
▸ updateCellsByToken(token)
▸ getValueInCellByToken(token)
▸ canPlayerMakeMove(player, token)
▸ findTokenPosition()
▸ serialize()
▸ asMatrix()

Cell

Class representing a cell. A cell is a positioned element in the Board that contains a value.

new Cell(value: number, rowIndex: number, colIndex: number)
Parameters
value (number)
rowIndex (number)
colIndex (number)
Instance Members
▸ updateValue(value)
▸ isSelectable()
▸ updateFromObject(cell)

flags

Flags used in the logic's game.

flags
Static Members
▸ GAME_STATUSES
▸ TURNS
▸ PLAYER_DIRECTIONS
▸ GAME_CONTINUITY
▸ GAME_RESULT

Game

Class representing a game. A game is made of a Board a Token and 2 Players, one of them is an Agent.

new Game(boardSize: number)
Parameters
boardSize (number) Defines a square Board .
Instance Members
▸ updateFromScratch(boardSize)
▸ moveToken(rowIndex, colIndex)
▸ updateLastValueInCellWhereTokenIs()
▸ updateStatus(status)
▸ updateCellsWhereTokenIs()
▸ updateCurrentPlayerScore()
▸ passToken()
▸ updateContinuity()
▸ getCurrentPlayer()
▸ getNextPlayer()
▸ serialize()
▸ updateFromObject(game)

Player

Class representing a player. A player has a direction of playing and a score.

new Player()
Instance Members
▸ incrementScore(value)
▸ serialize()
▸ toString()
▸ updateFromObject(player)

Token

Class representing a token. A token is the element that moves in the Board to select a Cell.

new Token(boardSize: number)
Parameters
boardSize (number) The size of the Board .
Instance Members
▸ moveTo(rowIndex, colIndex)
▸ set(rowIndex, colIndex)
▸ serialize()
▸ toString()
▸ updateFromObject(token)

utils

Utility functions for the logic's game.

utils
Static Members
▸ rotateClockwise(matrix)
▸ rotateCounterClockwise(matrix)
▸ rotateIndicesClockwise(rowIndex, colIndex, size)
▸ rotateIndicesCounterClockwise(rowIndex, colIndex, size)
▸ getRowsReadinessToEndGame(boardMatrix, tokenColIndex)
▸ getGainsMatrix(tokenColIndex, gameMatrix)
▸ getRowsIndicesByOrderedGain(tokenRowIndex, tokenColIndex, boardMatrix, gainsMatrix, rowsReadinessToEndGame)
▸ getAvailableCellsPerColumn(tokenRowIndex, tokenColIndex, boardMatrix)
▸ randomInteger(min, max)
▸ updateObjectFromJsonString(object, jsonString)
▸ updateObjectFromLiteral(object, literal)
▸ vectorToMatrix(vector)
▸ generateRandomNumber()

gameActions

Game actions to be dispatched.

gameActions
Static Members
▸ moveToken(rowIndex, colIndex)
▸ updateScores()
▸ resetGame(boardSize)

gameActionTypes

Type of game actions to be dispatched.

gameActionTypes
Static Members
▸ TOKEN_MOVED
▸ SCORES_UPDATED
▸ GAME_RESET

reduce

Update the state of the game based on the received gameActions

reduce
Parameters
state (object = initialState) Game state of the application.
action (object) Action with relevant data to update the state of the application.
Returns
Object: New game state after applying the action.

reduce

Update settings state. on the received settingsActions

reduce
Parameters
state (any = initialState) Settings state of the application.
action (any) Action to update the state.
Returns
Object: New settings state after applying the action.

settingsActions

Settings actions to be dispatched.

settingsActions
Static Members
▸ toggleSound()
▸ lockSound()
▸ unlockSound()
▸ lockControls()
▸ unlockControls()

settingsActionTypes

Type of settings actions to be dispatched.

settingsActionTypes
Static Members
▸ SOUND_TOGGLE
▸ LOCK_SOUND
▸ UNLOCK_SOUND
▸ LOCK_CONTROLS
▸ UNLOCK_CONTROLS