Class ArenaRules
The decisions an arena match makes, as pure functions: whether a format can be played in a scene, when a match is over and who won, how players place, what a result does to a rank, and what an interaction with an objective does.
public static class ArenaRules
- Inheritance
-
ArenaRules
- Inherited Members
Remarks
Kept free of network, database and Unity state so each rule is a truth table that can be tested without a server. The match coordinator calls these; nothing here decides anything on its own clock.
Methods
GroupFitsFormat(int, int)
Whether a pre-made group may queue for a format: it must fit on one team.
public static bool GroupFitsFormat(int groupSize, int teamSize)
Parameters
Returns
ResolveControlPointInteraction(int, int, int, int, int)
What interacting with a control point does for one player.
public static ArenaControlPointResult ResolveControlPointInteraction(int ownerTeam, int progressTeam, int progress, int actorTeam, int interactionsToCapture)
Parameters
ownerTeamintCurrent owner, or -1 for neutral.
progressTeamintTeam whose capture is in progress, or -1.
progressintInteractions accumulated by that team.
actorTeamintThe interacting player's team, or -1 when not seated.
interactionsToCaptureintInteractions needed to take the point.
Returns
Remarks
A team that already owns the point gains nothing by touching it. Another team's touch advances their own progress; a third team's touch, or a touch by a team other than the one in progress, restarts progress for the toucher's team — contesting is a race, not a tug of war. Reaching the count flips ownership and clears progress.
ResolveDroppedFlagTouch(int, int, bool)
What touching a dropped flag lying on the ground does for one player.
public static ArenaFlagAction ResolveDroppedFlagTouch(int flagTeam, int actorTeam, bool actorCarriesFlag)
Parameters
flagTeamintTeam the flag belongs to.
actorTeamintThe touching player's team, or -1 when not seated.
actorCarriesFlagboolWhether the player is already carrying an enemy flag.
Returns
Remarks
Its own team returns it home with a touch; an enemy not already carrying a flag picks it up and carries on. Nobody carries two.
ResolveFlagInteraction(int, ArenaFlagState, int, bool)
What interacting with a flag stand does for one player.
public static ArenaFlagAction ResolveFlagInteraction(int standTeam, ArenaFlagState standFlag, int actorTeam, bool actorCarriesFlag)
Parameters
standTeamintTeam whose flag rests on the stand.
standFlagArenaFlagStateWhere that team's flag currently is.
actorTeamintThe interacting player's team, or -1 when not seated.
actorCarriesFlagboolWhether the player is carrying an enemy flag.
Returns
Remarks
Classic rules: an enemy takes a flag that is home; the flag's owner delivers a carried enemy flag at their own stand only while their own flag is home, so a team whose flag is out cannot score until they get it back. Nobody takes their own flag, and nobody takes a flag that is already out.
ResolveMatchSize(ArenaTemplate, int, int)
Whether a scene can hold a full match at a format.
public static int ResolveMatchSize(ArenaTemplate template, int format, int sceneMaxClients)
Parameters
templateArenaTemplateThe arena. Null is not playable.
formatintFormat index.
sceneMaxClientsintThe scene's declared capacity.
Returns
- int
The match size when playable, or 0.
ResolveOutcome(IReadOnlyList<int>, int, bool, int, out int)
Decides whether a live match has ended, and who won.
public static bool ResolveOutcome(IReadOnlyList<int> teamScores, int scoreLimit, bool timeUp, int teamsWithPlayers, out int winnerTeam)
Parameters
teamScoresIReadOnlyList<int>Score per team.
scoreLimitintScore that ends it at once, or 0 for none.
timeUpboolWhether the clock has run out.
teamsWithPlayersintHow many teams still have at least one player in the match.
winnerTeamintWinning team index, or -1 for a draw or an undecided match.
Returns
- bool
True when the match is over.
Remarks
A team reaching the limit wins immediately. Time running out gives the match to the highest score, or draws it. A match with only one team left standing — everybody else left or was removed — ends at once in that team's favour, because there is nobody left to score against.
ResolvePlacements(IReadOnlyList<ArenaPlacement>)
Orders players for the results screen: score, then kills, then fewer deaths, then a stable tie-break on character id so two clients agree.
public static List<ArenaPlacement> ResolvePlacements(IReadOnlyList<ArenaPlacement> members)
Parameters
membersIReadOnlyList<ArenaPlacement>
Returns
Remarks
By score only. Team and group are deliberately not part of the order: the pedestal is about who did the most, not who won.
ResolveRankDelta(int, int, int, int, int)
The rank change for one player.
public static int ResolveRankDelta(int currentRank, int team, int winnerTeam, int winPoints, int lossPoints)
Parameters
currentRankintRank before the match.
teamintThe player's team.
winnerTeamintWinning team, or -1 for a draw.
winPointsintPoints for a win.
lossPointsintPoints lost for a loss.
Returns
- int
Signed delta such that
currentRank + deltais never below zero.
ResolveTeamSpawnKeys(IEnumerable<string>, string)
Picks the respawn points that belong to a team from a scene's respawn dictionary.
public static List<string> ResolveTeamSpawnKeys(IEnumerable<string> respawnKeys, string prefix)
Parameters
respawnKeysIEnumerable<string>All respawn point names in the scene.
prefixstringThe team's prefix, or null.