- Tables
- LobbyLobbyGameLobbyParticipantLobbyReadyCheckLobbyReadyCheckUserLobbySetLobbySetParticipantUserUserSubmittedImage
- Calls
- ChatRepositoryScannerIngestRepositoryReportedWeaponRepository
- Imports
- LobbySet
- Used by
- 1 loader1 action1 repository4 modules1 script2 other
Types
A set of the lobby with its games and participants, see {@link findAllSetsByLobbyId}.
export type LobbySetWithGames = Unwrapped<typeof findAllSetsByLobbyId>;
How a set ends when one of its players leaves, see {@link endLeftSet}.
export type LeftSetEnding = "CONFIRMED" | "CALLED_OFF" | "FORFEITED";
Functions & values
functionfindAllSetsByLobbyId
:25 Every set of the lobby, oldest first, with its maps and who played on which side (with their user info).
export function findAllSetsByLobbyId(lobbyId: number, trx?: Transaction<DB>)
functionfindAllTeamChatsByChatRoomIds
:77 Sets owning the given team chat rooms, with the players of the side the chat room is for who are still in the lobby's room. A finished set's team chats are inactive.
export async function findAllTeamChatsByChatRoomIds(chatRoomIds: number[])
Unit tests (2)
Starts a set in the room: who plays on which side (the rest sit out), the maps, the weapons the randomizer rolled and fresh team chats. Returns the set id.
export function insertSet({
lobbyId,
bestOf,
maps,
alpha,
bravo,
sittingOut,
rolledWeapons,
noScreen,
}: {
lobbyId: number;
bestOf: Tables["LobbySet"]["bestOf"];
maps: Array<ModeWithStage & { source: LobbyMapSource }>;
alpha: number[];
bravo: number[];
sittingOut: number[];
rolledWeapons: LobbyRolledWeapons | null;
noScreen: boolean;
})Reports the winner of the set's current map as the actor (reportedByUserId). reportedCount is how many maps the reporter saw reported, a mismatch means someone else reported in between.
export function reportGame({
setId,
winnerSide,
reportedCount,
}: {
setId: number;
winnerSide: LobbySide;
reportedCount: number;
}): Promise<ReportResult>functionundoLatestReport
:275 Undoes the latest map report of the set, with its weapon reports and scanner links. Clears a dispute.
export function undoLatestReport({
setId,
reportedCount,
isHost,
}: {
setId: number;
reportedCount: number;
/** The actor hosts the lobby, undoing for either side */
isHost: boolean;
}): Promise<ReportResult>Confirms the decided result as the actor (confirmedByUserId), of the side asked to confirm.
export function confirmSet(setId: number): Promise<ReportResult>
functionconfirmDisputedSet
:339 Confirms a disputed result as the actor (confirmedByUserId), the host settling the dispute.
export function confirmDisputedSet(setId: number): Promise<ReportResult>
Marks the decided result disputed by the actor's side.
export function disputeSet(setId: number): Promise<ReportResult>
Ends the user's unfinished set because they left: a decided result stands as if confirmed, a set without a map reported is called off (deleted), otherwise their side forfeits. Returns how the set ended, null if they weren't playing an unfinished set.
export async function endLeftSet(
{ setId, userId }: { setId: number; userId: number },
trx?: Transaction<DB>,
): Promise<LeftSetEnding | null>functioninsertReadyCheck
:415 Starts a ready check filling the room's vacant slots from the waitlist (userIds).
export function insertReadyCheck({
lobbyId,
expiresAt,
userIds,
}: {
lobbyId: number;
expiresAt: number;
userIds: number[];
})functionconfirmReadyChecks
:452 The user confirms being ready for the lobby's open ready checks, invited or not (anyone waiting may claim a vacant slot). Returns whether any was confirmed.
export async function confirmReadyChecks({
lobbyId,
userId,
}: {
lobbyId: number;
userId: number;
})Unit tests (1)
functiondeleteReadyCheck
:488 Deletes the ready check, as when the room's open slots have been filled.
export async function deleteReadyCheck(readyCheckId: number)
- Tables
- AssociationAssociationMemberCalendarEventContentVisibilityFriendshipLobbyLobbyApplicationLobbyGameLobbyKickedUserLobbyLeftUserLobbyParticipantLobbyReadyCheckLobbyReadyCheckUserLobbyResultLobbySetLobbySetParticipantPlusTierTenStarWeaponUserUserSubmittedImageUserWeaponPool
- Calls
- ChatRepositoryLobbyMatchRepository
- Imports
- VisibilityLeaderboard
- Used by
- 3 loaders2 actions4 modules1 routine1 script6 other
Types
The lobby with its participants, see {@link findById}.
export type LobbyById = NonNullable<Unwrapped<typeof findById>>;
Functions & values
The lobby with its participants, if the actor may see it: by its visibility, its share key, or as a participant or player of one of its sets or one who left it. leftUsers are those who left it after playing a set and haven't signed up again, they keep its chat until kicked. isViewerKicked is whether the host kicked the actor out of it, hasViewerLeft whether the actor left it at some point and so keeps its chat. While the lobby requires applying, viewerApplication is the state of the actor's application to it and applications the pending ones, for the host. permissions.MANAGE is the host. shareKey goes to the host and, as everyone in a link-only lobby already reached it through the link, to every viewer of one.
export async function findById(
id: number,
{ shareKey = null }: { shareKey?: string | null } = {},
)functionisLinkOnlyById
:226 Whether the lobby exists and is link-only, seen only through its share link by those not participating. No visibility scoping.
export async function isLinkOnlyById(id: number)
functionfindAllVisible
:238 Which of the lobbies the user may see, by visibility or as a participant, and whether a spot in them is free.
export async function findAllVisible({
userId,
lobbyIds,
}: {
userId: number;
lobbyIds: number[];
})functionfindProgressionStateById
:288 The lobby's own columns and participants, for deciding its next transition. No visibility scoping.
export async function findProgressionStateById(id: number)
functionfindAllByChatRoomIds
:348 The lobbies owning the common chat rooms, for resolving who is in them: the participants and those who left without being kicked.
export async function findAllByChatRoomIds(chatRoomIds: number[])
functionfindAllForIndex
:480 Lobbies for the index page: running and upcoming ones visible to the actor, with the actor's own (participating) lobbies first, and ended ones the actor played in. viewerStatus tells apart spectating from playing in the room, hasViewerApplied is whether the actor's application to a lobby requiring one is pending.
export async function findAllForIndex()
Unit tests (4)
functionfindAllUpcomingByUserId
:570 Lobbies the user is signed up for (or hosting) that haven't ended and start within the window.
export function findAllUpcomingByUserId({
userId,
startsBefore,
}: {
userId: number;
startsBefore: number;
})functionfindAllActiveParticipants
:593 Who is active in a lobby (present: checked in or in the room, not dropping) and in which, across unended lobbies. isPlayingSet is whether they play a side of the lobby's unfinished set.
export async function findAllActiveParticipants()
functionfindAllUnconfirmedReadyCheckUsers
:632 Who a lobby's open ready check is waiting on: asked to take a vacant spot in its room and not confirmed yet.
export function findAllUnconfirmedReadyCheckUsers()
functionfindAllUpcomingOfFriendsByUserId
:655 Upcoming lobbies the viewer's friends signed up for that the viewer may see and hasn't signed up for, as invitations to join. One row per friend per lobby.
export function findAllUpcomingOfFriendsByUserId(viewerId: number)
Unit tests (1)
functionfindAllUnendedIdsNearStart
:713 Ids of unended lobbies starting in at most the check-in lead time or started, i.e. that may have something due.
export async function findAllUnendedIdsNearStart()
Inserts the lobby with its chat room and visibility, the host as its first participant. Returns the id.
export function insert({
visibility,
modes,
mapPool,
isApplicationRequired = false,
...args
}: InsertArgs)functioninsertParticipant
:787 Signs the user up, their application to the lobby (if any) done with. Signing up again after leaving starts from the end of the queue.
export function insertParticipant(
args: Pick<
TablesInsertable["LobbyParticipant"],
"lobbyId" | "userId" | "status"
>,
)
functioninsertApplication
:808 Applies to join the lobby, pending until the host approves or denies it.
export async function insertApplication({
lobbyId,
userId,
}: {
lobbyId: number;
userId: number;
})functiondeletePendingApplication
:823 Withdraws the user's pending application to the lobby.
export async function deletePendingApplication({
lobbyId,
userId,
}: {
lobbyId: number;
userId: number;
})functiondenyApplication
:839 Denies the user's pending application to the lobby, keeping them from applying again.
export async function denyApplication({
lobbyId,
userId,
}: {
lobbyId: number;
userId: number;
})functionupdateParticipant
:856 Updates a participant's own columns.
export async function updateParticipant(
{
lobbyId,
userId,
...values
}: {
lobbyId: number;
userId: number;
status?: LobbyParticipantStatus;
isDroppingAfterSet?: boolean;
isSittingOut?: boolean;
},
trx?: Transaction<DB>,
)functionupdateParticipantsStatus
:889 Sets the participants' status.
export async function updateParticipantsStatus({
lobbyId,
userIds,
status,
}: {
lobbyId: number;
userIds: number[];
status: LobbyParticipantStatus;
})functiondeleteParticipants
:909 Removes the users from the lobby and from the lobby's ready checks. Those who played a set keep the lobby's chat as having left it.
export async function deleteParticipants(
{ lobbyId, userIds }: { lobbyId: number; userIds: number[] },
trx?: Transaction<DB>,
)functionremoveParticipant
:956 Removes the user from the lobby right away. If they are playing an unfinished set (unfinishedSetId) it ends: a decided result stands, one without a map reported is called off, otherwise their side forfeits. Returns how that set ended, null if there was none.
export function removeParticipant(args: ParticipantRemoval)
Unit tests (2)
functionkickParticipant
:966 Removes the user from the lobby like {@link removeParticipant}, but without keeping its chat, and keeps them from signing up for it again. For one who already left it only takes the chat away.
export function kickParticipant(args: ParticipantRemoval)
Saves the settings the host can change after creating the lobby, the new audience in effect right away. Its share key keeps working.
export function edit({
id,
ownerId,
visibility,
modes,
mapPool,
isApplicationRequired,
...values
}: EditArgs)functionresetShareKey
:1041 Replaces the lobby's share key, its old invite link no longer working.
export async function resetShareKey(id: number)
functionfindVisibilityRowsById
:1050 The ContentVisibility rows of the lobby in the order they come into effect, with the names of their associations.
export function findVisibilityRowsById(id: number)
Updates the lobby's own bookkeeping columns.
export async function update(
{
id,
...values
}: {
id: number;
hostUserId?: number;
pendingSince?: number | null;
checkInOpenedAt?: number;
},
trx?: Transaction<DB>,
)Deletes the lobby with everything of it, its chat room left to the orphaned rooms cleanup.
export async function deleteById(id: number)
Ends the lobby. Its chat rooms become inactive, nobody counts as active in it anymore, its applications are dropped and so are sets that hadn't got a single map reported. The placements of its leaderboard are saved as the players' results.
export function end(id: number)
Unit tests (2)
functionfindResultPlacementsByUserId
:1179 Placements the user got in the ended lobbies they played a finished set in, one per lobby.
export function findResultPlacementsByUserId(userId: number)
Unit tests not about one export (15)