Interface IArenaMatchService
- Namespace
- FishMMO.Database.Npgsql.Services.Interfaces
- Assembly
- FishMMO-DB.dll
Service interface for arena matches: reading the match a hosting scene server has just loaded, recording its progress and its result.
public interface IArenaMatchService
Remarks
Matches are created by TryFormArenaMatchAsync(long, string, int, int, int, int, DateTime, int, ArenaRatingSource, ArenaComposeOptions, CancellationToken), inside the transaction that takes the players out of the queue; nothing here creates one. The hosting scene server is not necessarily the one that formed the match, so everything it needs to run it is read back from these rows.
Methods
CancelAbandonedAsync(DateTime, int, CancellationToken)
Cancels matches that had not ended by createdBeforeUtc and whose
instance no longer exists.
Task<DatabaseResult<int>> CancelAbandonedAsync(DateTime createdBeforeUtc, int maxRows = 64, CancellationToken cancellationToken = default)
Parameters
createdBeforeUtcDateTimemaxRowsintcancellationTokenCancellationToken
Returns
Remarks
A match whose instance failed to load, or whose hosting server died at any point, would otherwise hold every seat's character out of both finders forever. Called from every scene server's stale sweep, so it does not depend on the server that lost the match.
FetchAsync(long, CancellationToken)
Reads one match by id.
Task<DatabaseResult<ArenaMatchData?>> FetchAsync(long matchId, CancellationToken cancellationToken = default)
Parameters
matchIdlongcancellationTokenCancellationToken
Returns
FetchByInstanceAsync(long, CancellationToken)
Reads the match that runs in one instance.
Task<DatabaseResult<ArenaMatchData?>> FetchByInstanceAsync(long instanceId, CancellationToken cancellationToken = default)
Parameters
instanceIdlongThe
scenesrow of the instance.cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DatabaseResult<ArenaMatchData?>>
The match, or null when the instance is not an arena match.
FetchCharactersInLiveMatchesAsync(IReadOnlyList<long>, CancellationToken)
Which of the given characters hold a seat in a match that has not ended.
Task<DatabaseResult<IReadOnlyList<long>>> FetchCharactersInLiveMatchesAsync(IReadOnlyList<long> characterIds, CancellationToken cancellationToken = default)
Parameters
characterIdsIReadOnlyList<long>cancellationTokenCancellationToken
Returns
Remarks
The arena half of the one-instance-per-party rule, asked at queue time about a whole party so that a party with a member in a live arena cannot open a dungeon, and one with a dungeon open cannot enter an arena. The forming transaction re-asserts it per seat.
FetchMembersAsync(long, CancellationToken)
Reads every seat of a match.
Task<DatabaseResult<IReadOnlyList<ArenaMatchMemberData>>> FetchMembersAsync(long matchId, CancellationToken cancellationToken = default)
Parameters
matchIdlongcancellationTokenCancellationToken
Returns
FetchRecentForCharacterAsync(long, int, CancellationToken)
A character's most recent matches, newest first, each with their own seat.
Task<DatabaseResult<IReadOnlyList<ArenaHistoryData>>> FetchRecentForCharacterAsync(long characterId, int limit, CancellationToken cancellationToken = default)
Parameters
characterIdlonglimitintcancellationTokenCancellationToken
Returns
MarkSeatVacatedAsync(long, long, CancellationToken)
Marks a seat vacated so the backfill may fill it, keeping the leaver's row for history.
Task<DatabaseResult<bool>> MarkSeatVacatedAsync(long matchId, long characterId, CancellationToken cancellationToken = default)
Parameters
matchIdlongcharacterIdlongcancellationTokenCancellationToken
Returns
- Task<DatabaseResult<bool>>
True when the seat was seated and is now vacated.
ReseatAsync(long, long, CancellationToken)
Re-seats a vacated character who came back inside the reconnect grace, if their seat was not filled meanwhile.
Task<DatabaseResult<bool>> ReseatAsync(long matchId, long characterId, CancellationToken cancellationToken = default)
Parameters
matchIdlongcharacterIdlongcancellationTokenCancellationToken
Returns
- Task<DatabaseResult<bool>>
True when the seat was vacated and is theirs again.
SetBackfillWindowAsync(long, DateTime?, CancellationToken)
Opens (or closes, with null) the window during which vacated seats may be backfilled.
Task<DatabaseResult<bool>> SetBackfillWindowAsync(long matchId, DateTime? untilUtc, CancellationToken cancellationToken = default)
Parameters
matchIdlonguntilUtcDateTime?cancellationTokenCancellationToken
Returns
SetRankedAsync(long, long, CancellationToken)
Stamps a match as ranked in a season. Called once, right after it forms, before it goes live.
Task<DatabaseResult<bool>> SetRankedAsync(long matchId, long seasonId, CancellationToken cancellationToken = default)
Parameters
matchIdlongseasonIdlongcancellationTokenCancellationToken
Returns
UpdateMemberRatingDeltasAsync(long, IReadOnlyList<(long characterId, int ratingDelta)>, CancellationToken)
Writes the rating change each seat earned in a ranked match.
Task<DatabaseResult<int>> UpdateMemberRatingDeltasAsync(long matchId, IReadOnlyList<(long characterId, int ratingDelta)> deltas, CancellationToken cancellationToken = default)
Parameters
matchIdlongdeltasIReadOnlyList<(long characterId, int ratingDelta)>cancellationTokenCancellationToken
Returns
UpdateMemberTalliesAsync(long, IReadOnlyList<(long characterId, int kills, int deaths, int score)>, CancellationToken)
Writes the final tallies for a match's seats in one statement.
Task<DatabaseResult<int>> UpdateMemberTalliesAsync(long matchId, IReadOnlyList<(long characterId, int kills, int deaths, int score)> tallies, CancellationToken cancellationToken = default)
Parameters
matchIdlongMatch the seats belong to.
talliesIReadOnlyList<(long characterId, int kills, int deaths, int score)>Per character: kills, deaths and score.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DatabaseResult<int>>
Rows updated.
UpdateStatusAsync(long, ArenaMatchStatus, int, CancellationToken)
Advances a match's status, stamping the start or end time as appropriate.
Task<DatabaseResult<bool>> UpdateStatusAsync(long matchId, ArenaMatchStatus status, int winnerTeam = -1, CancellationToken cancellationToken = default)
Parameters
matchIdlongMatch to update.
statusArenaMatchStatusNew status.
winnerTeamintWinning team for Ended, or -1.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DatabaseResult<bool>>
True when the row moved.
Remarks
Only ever moves forward: the WHERE refuses a status lower than the current one,
so a late write from a server that lost the instance cannot reopen an ended match.