economy and rematch
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
insertMatchForNewRoom,
|
||||
insertRematchMatch,
|
||||
loadUsernamesForUserPair,
|
||||
computeRcPrizeFromEntryFee,
|
||||
MATCH_ENTRY_FEE_RC,
|
||||
registerMatchRoutes,
|
||||
updateMatchUserBlue,
|
||||
@@ -98,17 +99,20 @@ function roomResponseForViewer(room: Room, viewerUserId: number): Room {
|
||||
const idx = room.Players.findIndex((p) => p.UserId === viewerUserId);
|
||||
const your_team: 'red' | 'blue' | null = idx === 0 ? 'red' : idx === 1 ? 'blue' : null;
|
||||
const entry_fee = room.entry_fee ?? MATCH_ENTRY_FEE_RC;
|
||||
return { ...room, entry_fee, your_team };
|
||||
const rc_prize = computeRcPrizeFromEntryFee(entry_fee);
|
||||
return { ...room, entry_fee, rc_prize, your_team };
|
||||
}
|
||||
|
||||
/** Same envelope as `POST /internal/rematch` success: both sides when seated, else `null` for open slot. */
|
||||
function roomMatchSuccessEnvelope(room: Room): MatchRoomSuccessEnvelope {
|
||||
const entry_fee = room.entry_fee ?? MATCH_ENTRY_FEE_RC;
|
||||
const rc_prize = computeRcPrizeFromEntryFee(entry_fee);
|
||||
const redId = room.Players[0]?.UserId;
|
||||
const blueId = room.Players[1]?.UserId;
|
||||
return {
|
||||
ok: true,
|
||||
entry_fee,
|
||||
rc_prize,
|
||||
for_red: redId != null ? roomResponseForViewer(room, redId) : null,
|
||||
for_blue: blueId != null ? roomResponseForViewer(room, blueId) : null,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user