A game between two players

### Hierarchy

- Game

## Index

### Constructors

- constructor

### Properties

- currentPlayerIndex
- events
- game
- gamePromise
- gameStart
- gameTime
- log
- options
- playerMoveTimeout
- players
- resolve
- timedoutPlayer
- winnerIndex

### Methods

- askForMove
- handleGameEnd
- handleGameTied
- handleGameWon
- handlePlayerMove
- handlePlayerTimeout
- parseMove
- playGame
- resetPlayers
- switchPlayer
- writeMove

## Constructors

### constructor

- new Game(players: Player[], options: IGameOptions, events: ITournamentEvents, log: any): Game

- - Defined in tournament/match/game/Game.ts:29

  Create a game between two players

  - @param options Options for gameplay

  #### Parameters

  - ##### players: Player[]

  - ##### options: IGameOptions

  - ##### events: ITournamentEvents

  - ##### log: any

  #### Returns Game

## Properties

### Private currentPlayerIndex

currentPlayerIndex: PlayerNumber

- Defined in tournament/match/game/Game.ts:25

### Private events

events: ITournamentEvents

- Defined in tournament/match/game/Game.ts:35

### Private game

game: UTTT

- Defined in tournament/match/game/Game.ts:24

### Private gamePromise

gamePromise: Promise<boolean>

- Defined in tournament/match/game/Game.ts:27

### Private gameStart

gameStart: [number, number]

- Defined in tournament/match/game/Game.ts:26

### gameTime

gameTime: number

- Defined in tournament/match/game/Game.ts:22

### Private log

log: any

- Defined in tournament/match/game/Game.ts:35

### Private options

options: IGameOptions

- Defined in tournament/match/game/Game.ts:35

### Private playerMoveTimeout

playerMoveTimeout: Timer

- Defined in tournament/match/game/Game.ts:29

### Private players

players: Player[]

- Defined in tournament/match/game/Game.ts:35

### Private resolve

resolve: function

- Defined in tournament/match/game/Game.ts:28

#### Type declaration

- - (state: boolean): void

  - #### Parameters

    - ##### state: boolean

    #### Returns void

### timedoutPlayer

timedoutPlayer: PlayerNumber

- Defined in tournament/match/game/Game.ts:23

### winnerIndex

winnerIndex: PlayerOrTie

- Defined in tournament/match/game/Game.ts:21

## Methods

### Private askForMove

- askForMove(move?: string): void

- - Defined in tournament/match/game/Game.ts:72

  Send a request for a move to the current player index It will also start the timeout that will make the player lose if they haven't answered in time

  #### Parameters

  - ##### Optional move: string

  #### Returns void

### Private handleGameEnd

- handleGameEnd(delay?: number): void

- - Defined in tournament/match/game/Game.ts:171

  Process all the required stuff about a game end

  #### Parameters

  - ##### Optional delay: number

    Wait before continuing - this should give players the chance to reset themselves

  #### Returns void

### Private handleGameTied

- handleGameTied(): void

- - Defined in tournament/match/game/Game.ts:158

  #### Returns void

### Private handleGameWon

- handleGameWon(winnerIndex: PlayerNumber, delay?: number): void

- - Defined in tournament/match/game/Game.ts:149

  Handle a game win

  #### Parameters

  - ##### winnerIndex: PlayerNumber

    Game's winner, used to update the state

  - ##### Optional delay: number

  #### Returns void

### Private handlePlayerMove

- handlePlayerMove(playerIndex: number): (Anonymous function)

- - Defined in tournament/match/game/Game.ts:90

  Handles a specific player move - this returns a function configured for the specified player, it's intended to be used as the callback for the player socket.

  #### Parameters

  - ##### playerIndex: number

  #### Returns (Anonymous function)

  Move handler with the player number embedded for logging

### Private handlePlayerTimeout

- handlePlayerTimeout(playerIndex: PlayerNumber): void

- - Defined in tournament/match/game/Game.ts:138

  #### Parameters

  - ##### playerIndex: PlayerNumber

  #### Returns void

### Private parseMove

- parseMove(data: string): Coords

- - Defined in tournament/match/game/Game.ts:208

  Receive a move from a player and convert it to an object of board and move

  #### Parameters

  - ##### data: string

    String received from the client

  #### Returns Coords

### playGame

- playGame(): Promise<boolean>

- - Defined in tournament/match/game/Game.ts:47

  Play an individual game between two players

  #### Returns Promise<boolean>

### Private resetPlayers

- resetPlayers(): void

- - Defined in tournament/match/game/Game.ts:60

  #### Returns void

### Private switchPlayer

- switchPlayer(playerNumber: PlayerNumber): PlayerNumber

- - Defined in tournament/match/game/Game.ts:227

  Type safe way of switching from one player to another

  #### Parameters

  - ##### playerNumber: PlayerNumber

  #### Returns PlayerNumber

### Private writeMove

- writeMove(coords: Coords): string

- - Defined in tournament/match/game/Game.ts:219

  Encode a move received from a player to be sent to the opponent

  #### Parameters

  - ##### coords: Coords

  #### Returns string

Generated using TypeDoc