mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-26 18:09:40 +08:00
rework race end flow
This commit is contained in:
parent
8fe32e7873
commit
93078352bf
2 changed files with 9 additions and 33 deletions
|
|
@ -116,8 +116,8 @@ function backToLobbyOut(): void {
|
|||
Socket.emit("room_back_to_lobby");
|
||||
}
|
||||
|
||||
function destroyTest(callback: (data: { reason: string }) => void): void {
|
||||
Socket.on("room_destroy_test", callback);
|
||||
function raceForceFinish(callback: (data: { reason: string }) => void): void {
|
||||
Socket.on("room_race_force_finish", callback);
|
||||
}
|
||||
|
||||
function joined(callback: (data: { room: TribeTypes.Room }) => void): void {
|
||||
|
|
@ -229,20 +229,12 @@ function userResult(
|
|||
Socket.on("room_user_result", callback);
|
||||
}
|
||||
|
||||
function raceFinished(callback: () => void): void {
|
||||
Socket.on("room_race_finished", callback);
|
||||
}
|
||||
|
||||
function finishTimerCountdown(
|
||||
callback: (data: { time: number }) => void,
|
||||
): void {
|
||||
Socket.on("room_finishTimer_countdown", callback);
|
||||
}
|
||||
|
||||
function finishTimerOver(callback: () => void): void {
|
||||
Socket.on("room_finishTimer_over", callback);
|
||||
}
|
||||
|
||||
function readyTimerCountdown(callback: (data: { time: number }) => void): void {
|
||||
Socket.on("room_readyTimer_countdown", callback);
|
||||
}
|
||||
|
|
@ -292,16 +284,14 @@ export default {
|
|||
countdown,
|
||||
usersUpdate,
|
||||
raceStarted,
|
||||
raceFinished,
|
||||
progressUpdate,
|
||||
userResult,
|
||||
finishTimerCountdown,
|
||||
finishTimerOver,
|
||||
readyTimerCountdown,
|
||||
readyTimerOver,
|
||||
backToLobby,
|
||||
finalPositions,
|
||||
destroyTest,
|
||||
raceForceFinish,
|
||||
},
|
||||
out: {
|
||||
getPublicRooms,
|
||||
|
|
|
|||
|
|
@ -106,9 +106,13 @@ function updateRoomState(state: TribeTypes.RoomState): void {
|
|||
} else {
|
||||
TribeResults.updateTimerText("Time left for everyone to finish");
|
||||
}
|
||||
} else if (state === TribeTypes.ROOM_STATE.RACE_AWAITING_RESULTS) {
|
||||
//
|
||||
} else if (state === TribeTypes.ROOM_STATE.SHOWING_RESULTS) {
|
||||
TribeResults.hideTimer();
|
||||
TribeCountdown.hide();
|
||||
TribeResults.updateTimerText("Time left for everyone to get ready");
|
||||
void TribeChartController.drawAllCharts();
|
||||
if (TribeState.getAutoReady()) {
|
||||
TribeSocket.out.room.readyUpdate();
|
||||
}
|
||||
|
|
@ -717,14 +721,6 @@ TribeSocket.in.room.userResult((data) => {
|
|||
}
|
||||
});
|
||||
|
||||
TribeSocket.in.room.raceFinished(() => {
|
||||
if (!TestState.isActive) {
|
||||
setTimeout(() => {
|
||||
void TribeChartController.drawAllCharts();
|
||||
}, 250);
|
||||
}
|
||||
});
|
||||
|
||||
TribeSocket.in.room.finishTimerCountdown((data) => {
|
||||
if (TestState.isActive) {
|
||||
TribeCountdown.update(data.time.toString());
|
||||
|
|
@ -733,19 +729,9 @@ TribeSocket.in.room.finishTimerCountdown((data) => {
|
|||
}
|
||||
});
|
||||
|
||||
TribeSocket.in.room.finishTimerOver(() => {
|
||||
TribeCountdown.hide();
|
||||
TribeResults.hideTimer();
|
||||
TribeSocket.in.room.raceForceFinish((data) => {
|
||||
if (TestState.isActive) {
|
||||
TimerEvent.dispatch("fail", "out of time");
|
||||
}
|
||||
});
|
||||
|
||||
TribeSocket.in.room.destroyTest((data) => {
|
||||
if (TestState.isActive) {
|
||||
if (data.reason === "afk") {
|
||||
TimerEvent.dispatch("fail", "afk");
|
||||
}
|
||||
TimerEvent.dispatch("fail", data.reason);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue