Table of Contents

Class ArenaRules

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

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

groupSize int
teamSize int

Returns

bool

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

ownerTeam int

Current owner, or -1 for neutral.

progressTeam int

Team whose capture is in progress, or -1.

progress int

Interactions accumulated by that team.

actorTeam int

The interacting player's team, or -1 when not seated.

interactionsToCapture int

Interactions needed to take the point.

Returns

ArenaControlPointResult

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

flagTeam int

Team the flag belongs to.

actorTeam int

The touching player's team, or -1 when not seated.

actorCarriesFlag bool

Whether the player is already carrying an enemy flag.

Returns

ArenaFlagAction

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

standTeam int

Team whose flag rests on the stand.

standFlag ArenaFlagState

Where that team's flag currently is.

actorTeam int

The interacting player's team, or -1 when not seated.

actorCarriesFlag bool

Whether the player is carrying an enemy flag.

Returns

ArenaFlagAction

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

template ArenaTemplate

The arena. Null is not playable.

format int

Format index.

sceneMaxClients int

The 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

teamScores IReadOnlyList<int>

Score per team.

scoreLimit int

Score that ends it at once, or 0 for none.

timeUp bool

Whether the clock has run out.

teamsWithPlayers int

How many teams still have at least one player in the match.

winnerTeam int

Winning 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

members IReadOnlyList<ArenaPlacement>

Returns

List<ArenaPlacement>

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

currentRank int

Rank before the match.

team int

The player's team.

winnerTeam int

Winning team, or -1 for a draw.

winPoints int

Points for a win.

lossPoints int

Points lost for a loss.

Returns

int

Signed delta such that currentRank + delta is 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

respawnKeys IEnumerable<string>

All respawn point names in the scene.

prefix string

The team's prefix, or null.

Returns

List<string>

Matching names, or every name when the prefix matches nothing or is null.