ColorShapeLinks
An assignment for the AI course unit of the Bachelor in Videogames at Lusófona University
SessionController Class Reference

Script which controls ColorShapeLinks sessions, which can include one or more matches. More...

Inheritance diagram for SessionController:
Inheritance graph
Collaboration diagram for SessionController:
Collaboration graph

Public Member Functions

IPlayer GetPlayer (PColor player)
 Get player of the specified color. More...
 

Public Attributes

Board Board => currentBoard
 The game board. More...
 
IPlayer CurrentPlayer => currentMatch[currentBoard.Turn]
 The current player. More...
 
float AITimeLimit => aITimeLimit
 Maximum real time in seconds that AI can take to play. More...
 
float MinAIGameMoveTime => minAIGameMoveTime
 Even if the AI plays immediately, this time (in seconds) gives the illusion that the AI took some minimum time to play. More...
 
float LastMoveAnimLength => lastMoveAnimLength
 Last move animation length in seconds. More...
 
SessionState State => state
 State of the current session. More...
 
string PlayerWhite => currentMatch[PColor.White].PlayerName
 Name of player playing as white. More...
 
string PlayerRed => currentMatch[PColor.Red].PlayerName
 Name of player playing as red. More...
 
IEnumerable< MatchMatches => allMatches.Keys
 All matches played or to be played in current session. More...
 
IEnumerable< KeyValuePair< Match, Winner > > Results
 Results of matches played so far in current session. More...
 
IEnumerable< KeyValuePair< IPlayer, int > > Standings
 Standings (classification, ranking) of players in current session. More...
 
Winner LastMatchResult => matchController?.Result ?? Winner.None
 Result of last match. More...
 
string WinnerString => matchController?.WinnerString
 The winner's name and color. More...
 
bool WhoPlaysFirst => uiWhoPlaysFirst
 Ask who plays first? More...
 
bool BlockStartNextMatch => uiBlockStartNextMatch
 Start of next match screen needs to be unlocked with a button? More...
 
bool BlockShowResult => uiBlockShowResult
 Show result screen needs to be unlocked with a button? More...
 
float UnblockedScreenDuration => unblockedScreenDuration
 Duration of unblocked screens (start of next match, show result). More...
 

Private Attributes

int rows = 7
 Number of rows in the game board. More...
 
int cols = 7
 Number of columns in the game board. More...
 
int winSequence = 4
 How many pieces in a row are required to win. More...
 
int roundPiecesPerPlayer = 10
 Initial number of round pieces per player. More...
 
int squarePiecesPerPlayer = 11
 Initial number of square pieces per player. More...
 
float lastMoveAnimLength = 1f
 Last move animation length in seconds. More...
 
float aITimeLimit = 0.5f
 Maximum time in seconds that AI can take to play. More...
 
float minAIGameMoveTime = 0.25f
 Minimum apparent AI move time. More...
 
int pointsPerWin = 3
 Tournament points per win. More...
 
int pointsPerDraw = 1
 Tournament points per draw. More...
 
int pointsPerLoss = 0
 Tournament points per loss. More...
 
bool pressButtonBeforeMatch = false
 Press a button before tournament match starts? More...
 
bool pressButtonAfterMatch = false
 Press a button after tournament match ends? More...
 
float unblockedScreenDuration = 1.5f
 Duration of a screen if no button needs to be pressed in order to continue. More...
 

Additional Inherited Members

- Properties inherited from IMatchDataProvider
Board Board [get]
 The game board. More...
 
IPlayer CurrentPlayer [get]
 The current player. More...
 
float AITimeLimit [get]
 Maximum real time in seconds that AI can take to play. More...
 
float MinAIGameMoveTime [get]
 Even if the AI plays immediately, this time (in seconds) gives the illusion that the AI took some minimum time to play. More...
 
float LastMoveAnimLength [get]
 Last move animation length in seconds. More...
 
- Properties inherited from ISessionDataProvider
SessionState State [get]
 State of the current session. More...
 
string PlayerWhite [get]
 Name of player playing as white. More...
 
string PlayerRed [get]
 Name of player playing as red. More...
 
IEnumerable< MatchMatches [get]
 All matches played or to be played in current session. More...
 
IEnumerable< KeyValuePair< Match, Winner > > Results [get]
 Results of matches played so far in current session. More...
 
IEnumerable< KeyValuePair< IPlayer, int > > Standings [get]
 Standings (classification, ranking) of players in current session. More...
 
Winner LastMatchResult [get]
 Result of last match. More...
 
string WinnerString [get]
 The winner's name and color. More...
 
bool WhoPlaysFirst [get]
 Ask who plays first? More...
 
bool BlockStartNextMatch [get]
 Start of next match screen needs to be unlocked with a button? More...
 
bool BlockShowResult [get]
 Show result screen needs to be unlocked with a button? More...
 
float UnblockedScreenDuration [get]
 Duration of unblocked screens (start of next match, show result). More...
 

Detailed Description

Script which controls ColorShapeLinks sessions, which can include one or more matches.

Based on the MVC design pattern, composed in this case by the following classes:

  • Model - A list of Match instances can be considered the model, although there isn't a well defined model in this case.
  • View - SessionView.
  • Controller - This class.

Definition at line 25 of file SessionController.cs.

Member Function Documentation

◆ GetPlayer()

IPlayer GetPlayer ( PColor  player)

Get player of the specified color.

Parameters
playerColor of the player to get.
Returns
Player of the specified color.
See also
IMatchDataProvider.GetPlayer(PColor)

Implements IMatchDataProvider.

Member Data Documentation

◆ aITimeLimit

float aITimeLimit = 0.5f
private

Maximum time in seconds that AI can take to play.

Definition at line 67 of file SessionController.cs.

◆ AITimeLimit

float AITimeLimit => aITimeLimit

Maximum real time in seconds that AI can take to play.

Maximum real time in seconds that AI can take to play.

See also
IMatchDataProvider.AITimeLimit

Definition at line 385 of file SessionController.cs.

◆ BlockShowResult

bool BlockShowResult => uiBlockShowResult

Show result screen needs to be unlocked with a button?

true if show result screen needs to be unlocked with a button, false otherwise.

See also
ISessionDataProvider.BlockShowResult

Definition at line 447 of file SessionController.cs.

◆ BlockStartNextMatch

bool BlockStartNextMatch => uiBlockStartNextMatch

Start of next match screen needs to be unlocked with a button?

true if start of next match screen needs to be unlocked with a button, false otherwise.

See also
ISessionDataProvider.BlockStartNextMatch

Definition at line 443 of file SessionController.cs.

◆ Board

Board Board => currentBoard

The game board.

The game board.

See also
IMatchDataProvider.Board

Definition at line 377 of file SessionController.cs.

◆ cols

int cols = 7
private

Number of columns in the game board.

Definition at line 46 of file SessionController.cs.

◆ CurrentPlayer

IPlayer CurrentPlayer => currentMatch[currentBoard.Turn]

The current player.

The current player.

See also
IMatchDataProvider.CurrentPlayer

Definition at line 381 of file SessionController.cs.

◆ LastMatchResult

Winner LastMatchResult => matchController?.Result ?? Winner.None

Result of last match.

One of the values of the Winner enumeration.

See also
ISessionDataProvider.LastMatchResult

Definition at line 431 of file SessionController.cs.

◆ lastMoveAnimLength

float lastMoveAnimLength = 1f
private

Last move animation length in seconds.

Definition at line 58 of file SessionController.cs.

◆ LastMoveAnimLength

float LastMoveAnimLength => lastMoveAnimLength

Last move animation length in seconds.

Last move animation length in seconds.

See also
IMatchDataProvider.LastMoveAnimLength

Definition at line 393 of file SessionController.cs.

◆ Matches

IEnumerable<Match> Matches => allMatches.Keys

All matches played or to be played in current session.

Collection of matches.

See also
ISessionDataProvider.Matches

Definition at line 417 of file SessionController.cs.

◆ minAIGameMoveTime

float minAIGameMoveTime = 0.25f
private

Minimum apparent AI move time.

Even if the AI plays immediately, this time (in seconds) gives the illusion that the AI took some minimum time to play.

Definition at line 76 of file SessionController.cs.

◆ MinAIGameMoveTime

float MinAIGameMoveTime => minAIGameMoveTime

Even if the AI plays immediately, this time (in seconds) gives the illusion that the AI took some minimum time to play.

Minimum apparent AI play time.

See also
IMatchDataProvider.MinAIGameMoveTime

Definition at line 389 of file SessionController.cs.

◆ PlayerRed

string PlayerRed => currentMatch[PColor.Red].PlayerName

Name of player playing as red.

A string containing the player's name.

See also
ISessionDataProvider.PlayerRed

Definition at line 413 of file SessionController.cs.

◆ PlayerWhite

string PlayerWhite => currentMatch[PColor.White].PlayerName

Name of player playing as white.

A string containing the player's name.

See also
ISessionDataProvider.PlayerWhite

Definition at line 409 of file SessionController.cs.

◆ pointsPerDraw

int pointsPerDraw = 1
private

Tournament points per draw.

Definition at line 87 of file SessionController.cs.

◆ pointsPerLoss

int pointsPerLoss = 0
private

Tournament points per loss.

Definition at line 90 of file SessionController.cs.

◆ pointsPerWin

int pointsPerWin = 3
private

Tournament points per win.

Definition at line 84 of file SessionController.cs.

◆ pressButtonAfterMatch

bool pressButtonAfterMatch = false
private

Press a button after tournament match ends?

Definition at line 96 of file SessionController.cs.

◆ pressButtonBeforeMatch

bool pressButtonBeforeMatch = false
private

Press a button before tournament match starts?

Definition at line 93 of file SessionController.cs.

◆ Results

IEnumerable<KeyValuePair<Match, Winner> > Results
Initial value:
=>
allMatches.Where(kvp => kvp.Value != Winner.None)

Results of matches played so far in current session.

Collection of match-winner pairs.

See also
ISessionDataProvider.Results

Definition at line 421 of file SessionController.cs.

◆ roundPiecesPerPlayer

int roundPiecesPerPlayer = 10
private

Initial number of round pieces per player.

Definition at line 52 of file SessionController.cs.

◆ rows

int rows = 7
private

Number of rows in the game board.

Definition at line 43 of file SessionController.cs.

◆ squarePiecesPerPlayer

int squarePiecesPerPlayer = 11
private

Initial number of square pieces per player.

Definition at line 55 of file SessionController.cs.

◆ Standings

IEnumerable<KeyValuePair<IPlayer, int> > Standings
Initial value:
=>
standings.OrderByDescending(kvp => kvp.Value)

Standings (classification, ranking) of players in current session.

Descending ordered collection of player-points pairs.

See also
ISessionDataProvider.Standings

Definition at line 426 of file SessionController.cs.

◆ State

SessionState State => state

State of the current session.

One of the values defined in the SessionState enumeration.

See also
ISessionDataProvider.State

Definition at line 405 of file SessionController.cs.

◆ unblockedScreenDuration

float unblockedScreenDuration = 1.5f
private

Duration of a screen if no button needs to be pressed in order to continue.

Definition at line 102 of file SessionController.cs.

◆ UnblockedScreenDuration

float UnblockedScreenDuration => unblockedScreenDuration

Duration of unblocked screens (start of next match, show result).

Duration in seconds.

See also
ISessionDataProvider.UnblockedScreenDuration

Definition at line 451 of file SessionController.cs.

◆ WhoPlaysFirst

bool WhoPlaysFirst => uiWhoPlaysFirst

Ask who plays first?

true if UI is to ask who plays first, false otherwise.

See also
ISessionDataProvider.WhoPlaysFirst

Definition at line 439 of file SessionController.cs.

◆ WinnerString

string WinnerString => matchController?.WinnerString

The winner's name and color.

A string containing the winner's name and color.

See also
ISessionDataProvider.WinnerString

Definition at line 435 of file SessionController.cs.

◆ winSequence

int winSequence = 4
private

How many pieces in a row are required to win.

Definition at line 49 of file SessionController.cs.


The documentation for this class was generated from the following file:
Winner
Winner
Winner or result of match.
Definition: Winner.cs:9