TicTacToe  1.0.0
TickTackToe.Game Class Reference

Game logic for tic tac toe game More...

Public Member Functions

bool SetMarker ()
 Places marker of the current player at current cursor position More...
 
void MoveCursor (int x, int y)
 Moves the cursor by increment of 1 in x / y direction More...
 
bool GetWinner ()
 Checks if a player has won and returns that player More...
 
void CheckGameStatus ()
 Checks if the game is won by either player and sets the winner property if winner is found. More...
 

Public Attributes

bool currentPlayer = false
 
int [][] winnables
 

Properties

char [] playerSymbols [get]
 
bool [,] field = { 'X', 'O', ' ' } [get]
 
int [] cursor = new bool?[3, 3] [get]
 
bool winner [get]
 
bool isGameRunning = null [get]
 

Detailed Description

Game logic for tic tac toe game

Definition at line 8 of file Game.cs.

Member Function Documentation

◆ CheckGameStatus()

void TickTackToe.Game.CheckGameStatus ( )

Checks if the game is won by either player and sets the winner property if winner is found.

Definition at line 80 of file Game.cs.

◆ GetWinner()

bool TickTackToe.Game.GetWinner ( )

Checks if a player has won and returns that player

Returns
The winning player. Has no value when no player has won.

Definition at line 70 of file Game.cs.

◆ MoveCursor()

void TickTackToe.Game.MoveCursor ( int  x,
int  y 
)

Moves the cursor by increment of 1 in x / y direction

Parameters
xMove the x position
yMove the y position

Does nothing if x or y are more than 1 / -1 or would move the cursor outside of the field

Definition at line 54 of file Game.cs.

◆ SetMarker()

bool TickTackToe.Game.SetMarker ( )

Places marker of the current player at current cursor position

Returns
false if already a marker at cursor position or game is won, true otherwise

Definition at line 36 of file Game.cs.

Member Data Documentation

◆ currentPlayer

bool TickTackToe.Game.currentPlayer = false

Definition at line 15 of file Game.cs.

◆ winnables

int [][] TickTackToe.Game.winnables
Initial value:
=
{
new int[]{0,1,2},
new int[]{3,4,5},
new int[]{6,7,8},
new int[]{0,3,6},
new int[]{1,4,7},
new int[]{2,5,8},
new int[]{0,4,8},
new int[]{2,4,6}
}

Definition at line 19 of file Game.cs.

Property Documentation

◆ cursor

int [] TickTackToe.Game.cursor = new bool?[3, 3]
get

Definition at line 13 of file Game.cs.

◆ field

bool [,] TickTackToe.Game.field = { 'X', 'O', ' ' }
get

Definition at line 12 of file Game.cs.

◆ isGameRunning

bool TickTackToe.Game.isGameRunning = null
get

Definition at line 17 of file Game.cs.

◆ playerSymbols

char [] TickTackToe.Game.playerSymbols
get

Definition at line 10 of file Game.cs.

◆ winner

bool TickTackToe.Game.winner
get

Definition at line 16 of file Game.cs.


The documentation for this class was generated from the following file: