class Match extends UrlModel implements NamedModel

A match played between two teams

Traits

A timestamp column

Constants

OFFICIAL

SPECIAL

FUN

TABLE

The name of the database table used for queries

CREATE_PERMISSION

EDIT_PERMISSION

SOFT_DELETE_PERMISSION

HARD_DELETE_PERMISSION

Methods

static string
getRouteName(string $action = 'show')

Get the name of the route that shows the object

string
getMatchDescription(int|string|TeamInterface $teamID)

Get a one word description of a match relative to a team (i.e. win, loss, or draw)

string
getMatchLetter(int|string|TeamInterface $teamID)

Get a one letter description of a match relative to a team (i.e. W, L, or T)

int
getScore(int|string|TeamInterface $teamID)

Get the score of a specific team

int
getOpponentScore(int|string|TeamInterface $teamID)

Get the score of the opponent relative to a team

getOpponent(int|string|TeamInterface $teamID)

Get the opponent of a match relative to a team ID

getUpdated()

Get the timestamp of the last update of the match

$this
setTimestamp(mixed $timestamp)

Set the timestamp of the match

getTeamA()

Get the first team involved in the match

getTeamB()

Get the second team involved in the match

string
getTeamAColor()

Get the color of Team A

string
getTeamBColor()

Get the color of Team B

Player[]|null
getTeamAPlayers()

Get the list of players on Team A who participated in this match

Player[]|null
getTeamBPlayers()

Get the list of players on Team B who participated in this match

Player[]|null
getPlayers(Team|int|null $team = null)

Get the list of players for a team in a match

setTeamPlayers(int[] $teamAPlayers = array(), int[] $teamBPlayers = array())

Set the players of the match's teams

int
getTeamAPoints()

Get the first team's points

int
getTeamBPoints()

Get the second team's points

setTeamPoints(int $teamAPoints, int $teamBPoints)

Set the match team points

setTeamColors(ColorTeam|string $teamAColor, ColorTeam|string $teamBColor)

Set the match team colors

int
getEloDiff()

Get the ELO difference applied to each team's old ELO

int
getTeamAEloNew()

Get the first team's new ELO

int
getTeamBEloNew()

Get the second team's new ELO

int
getTeamAEloOld()

Get the first team's old ELO

int
getTeamBEloOld()

Get the second team's old ELO

int|null
getTeamEloNew(Team $team)

Get the team's new ELO

int|null
getTeamEloOld(Team $team)

Get the team's old ELO

Map
getMap()

Get the map where the match was played on

setMap(int $map)

Set the map where the match was played

string
getMatchType()

Get the match type

setMatchType(string $matchType)

Set the match type

mixed|null
getMatchDetails()

Get a JSON decoded array of events that occurred during the match

string|null
getServerAddress()

Get the server address of the server where this match took place

setServerAddress($server = null)

Set the server address of the server where this match took place

string
getReplayFileName(int $length)

Get the name of the replay file for this specific map

int
getDuration()

Get the match duration

setDuration(int $duration)

Set the match duration

getEnteredBy()

Get the user who entered the match

getLoser()

Get the loser of the match

getWinner()

Get the winner of a match

bool
isDraw()

Determine whether the match was a draw

bool
involvesTeam(TeamInterface $team)

Find out whether the match involves a team

isOfficial()

Find out if the match is played between official teams

resetELOs()

Reset the ELOs of the teams participating in the match

float
getActivity()

Calculate the match's contribution to the team activity

static Match
enterMatch($a, $b, $a_points, $b_points, $duration, $entered_by, $timestamp = 'now', $a_players = array(), $b_players = array(), $server = null, $replayFile = null, $map = null, $matchType = 'official', $a_color = null, $b_color = null)

Enter a new match to the database

static int
calculateEloDiff(int $a_elo, int $b_elo, int $a_points, int $b_points, int $duration)

Calculate the ELO score difference

isEloCorrect()

Find if a match's stored ELO is correct

recalculateElo()

Recalculate the match's elo and adjust the team ELO values

static 
getMatches()

Get all the matches in the database

getQueryBuilder()

Get a query builder for matches

void
delete()

Delete the object

static string[]
getActiveStatuses()

Get the possible statuses representing an active model (visible to everyone)

string
getName()

Get the name of the entity

Details

at line line 186
static string getRouteName(string $action = 'show')

Get the name of the route that shows the object

Parameters

string $action The route's suffix

Return Value

string

at line line 198
string getMatchDescription(int|string|TeamInterface $teamID)

Get a one word description of a match relative to a team (i.e. win, loss, or draw)

Parameters

int|string|TeamInterface $teamID The team ID we want the noun for

Return Value

string Either "win", "loss", or "draw" relative to the team

at line line 216
string getMatchLetter(int|string|TeamInterface $teamID)

Get a one letter description of a match relative to a team (i.e. W, L, or T)

Parameters

int|string|TeamInterface $teamID The team ID we want the noun for

Return Value

string Either "W", "L", or "T" relative to the team

at line line 228
int getScore(int|string|TeamInterface $teamID)

Get the score of a specific team

Parameters

int|string|TeamInterface $teamID The team we want the score for

Return Value

int The score that team received

at line line 252
int getOpponentScore(int|string|TeamInterface $teamID)

Get the score of the opponent relative to a team

Parameters

int|string|TeamInterface $teamID The opponent of the team we want the score for

Return Value

int The score of the opponent

at line line 264
TeamInterface getOpponent(int|string|TeamInterface $teamID)

Get the opponent of a match relative to a team ID

Parameters

int|string|TeamInterface $teamID The team who is known in a match

Return Value

TeamInterface The opponent team

at line line 284
TimeDate getUpdated()

Get the timestamp of the last update of the match

Return Value

TimeDate The match's update timestamp

at line line 295
$this setTimestamp(mixed $timestamp)

Set the timestamp of the match

Parameters

mixed $timestamp The match's new timestamp

Return Value

$this

at line line 306
TeamInterface getTeamA()

Get the first team involved in the match

Return Value

TeamInterface Team A

at line line 319
TeamInterface getTeamB()

Get the second team involved in the match

Return Value

TeamInterface Team B

at line line 332
string getTeamAColor()

Get the color of Team A

Return Value

string

at line line 341
string getTeamBColor()

Get the color of Team B

Return Value

string

at line line 350
Player[]|null getTeamAPlayers()

Get the list of players on Team A who participated in this match

Return Value

Player[]|null Returns null if there were no players recorded for this match

at line line 359
Player[]|null getTeamBPlayers()

Get the list of players on Team B who participated in this match

Return Value

Player[]|null Returns null if there were no players recorded for this match

at line line 369
Player[]|null getPlayers(Team|int|null $team = null)

Get the list of players for a team in a match

Parameters

Team|int|null $team The team or team ID

Return Value

Player[]|null Returns null if there were no players recorded for this match

at line line 391
Match setTeamPlayers(int[] $teamAPlayers = array(), int[] $teamBPlayers = array())

Set the players of the match's teams

Parameters

int[] $teamAPlayers An array of player IDs
int[] $teamBPlayers An array of player IDs

Return Value

Match

at line line 417
int getTeamAPoints()

Get the first team's points

Return Value

int Team A's points

at line line 426
int getTeamBPoints()

Get the second team's points

Return Value

int Team B's points

at line line 438
Match setTeamPoints(int $teamAPoints, int $teamBPoints)

Set the match team points

Parameters

int $teamAPoints Team A's points
int $teamBPoints Team B's points

Return Value

Match

at line line 453
Match setTeamColors(ColorTeam|string $teamAColor, ColorTeam|string $teamBColor)

Set the match team colors

Parameters

ColorTeam|string $teamAColor The color of team A
ColorTeam|string $teamBColor The color of team B

Return Value

Match

at line line 474
int getEloDiff()

Get the ELO difference applied to each team's old ELO

Return Value

int The ELO difference

at line line 483
int getTeamAEloNew()

Get the first team's new ELO

Return Value

int Team A's new ELO

at line line 492
int getTeamBEloNew()

Get the second team's new ELO

Return Value

int Team B's new ELO

at line line 501
int getTeamAEloOld()

Get the first team's old ELO

Return Value

int

at line line 510
int getTeamBEloOld()

Get the second team's old ELO

Return Value

int

at line line 521
int|null getTeamEloNew(Team $team)

Get the team's new ELO

Parameters

Team $team The team whose new ELO to return

Return Value

int|null The new ELO, or null if the team provided has not participated in the match

at line line 538
int|null getTeamEloOld(Team $team)

Get the team's old ELO

Parameters

Team $team The team whose old ELO to return

Return Value

int|null The old ELO, or null if the team provided has not participated in the match

at line line 553
Map getMap()

Get the map where the match was played on

Return Value

Map Returns an invalid map if no map was found

at line line 563
Match setMap(int $map)

Set the map where the match was played

Parameters

int $map The ID of the map

Return Value

Match

at line line 573
string getMatchType()

Get the match type

Return Value

string 'official', 'fm', or 'special'

at line line 585
Match setMatchType(string $matchType)

Set the match type

Parameters

string $matchType A valid match type; official, fm, special

Return Value

Match

at line line 594
mixed|null getMatchDetails()

Get a JSON decoded array of events that occurred during the match

Return Value

mixed|null Returns null if there were no events recorded for the match

at line line 603
string|null getServerAddress()

Get the server address of the server where this match took place

Return Value

string|null Returns null if there was no server address recorded

at line line 615
Match setServerAddress($server = null)

Set the server address of the server where this match took place

Parameters

$server

Return Value

Match

at line line 627
string getReplayFileName(int $length)

Get the name of the replay file for this specific map

Parameters

int $length The length of the replay file name; it will be truncated

Return Value

string Returns null if there was no replay file name recorded

at line line 640
int getDuration()

Get the match duration

Return Value

int The duration of the match in minutes

at line line 651
Match setDuration(int $duration)

Set the match duration

Parameters

int $duration The new duration of the match in minutes

Return Value

Match

at line line 660
Player getEnteredBy()

Get the user who entered the match

Return Value

Player

at line line 670
TeamInterface getLoser()

Get the loser of the match

Return Value

TeamInterface The team that was the loser or the team with the lower elo if the match was a draw

at line line 684
TeamInterface getWinner()

Get the winner of a match

Return Value

TeamInterface The team that was the victor or the team with the lower elo if the match was a draw

at line line 706
bool isDraw()

Determine whether the match was a draw

Return Value

bool True if the match ended without any winning teams

at line line 717
bool involvesTeam(TeamInterface $team)

Find out whether the match involves a team

Parameters

TeamInterface $team The team to check

Return Value

bool

at line line 725
isOfficial()

Find out if the match is played between official teams

at line line 735
Match resetELOs()

Reset the ELOs of the teams participating in the match

Return Value

Match

at line line 750
float getActivity()

Calculate the match's contribution to the team activity

Return Value

float

at line line 784
static Match enterMatch($a, $b, $a_points, $b_points, $duration, $entered_by, $timestamp = 'now', $a_players = array(), $b_players = array(), $server = null, $replayFile = null, $map = null, $matchType = 'official', $a_color = null, $b_color = null)

Enter a new match to the database

Parameters

$a
$b
$a_points
$b_points
$duration
$entered_by
$timestamp
$a_players
$b_players
$server
$replayFile
$map
$matchType
$a_color
$b_color

Return Value

Match An object representing the match that was just entered

at line line 859
static int calculateEloDiff(int $a_elo, int $b_elo, int $a_points, int $b_points, int $duration)

Calculate the ELO score difference

Computes the ELO score difference on each team after a match, based on GU League's rules.

Parameters

int $a_elo Team A's current ELO score
int $b_elo Team B's current ELO score
int $a_points Team A's match points
int $b_points Team B's match points
int $duration The match duration in minutes

Return Value

int The ELO score difference

at line line 886
isEloCorrect()

Find if a match's stored ELO is correct

at line line 900
recalculateElo()

Recalculate the match's elo and adjust the team ELO values

at line line 929
static getMatches()

Get all the matches in the database

at line line 938
static MatchQueryBuilder getQueryBuilder()

Get a query builder for matches

Return Value

MatchQueryBuilder

at line line 957
void delete()

Delete the object

Please note that this does not delete the object entirely from the database, it only hides it from users. You should overload this function if your object does not have a 'status' column which can be set to 'deleted'.

Return Value

void

at line line 967
static string[] getActiveStatuses()

Get the possible statuses representing an active model (visible to everyone)

Return Value

string[]

at line line 975
string getName()

Get the name of the entity

Return Value

string