Skip to content

Commit 7a4c386

Browse files
committed
fix kicks
1 parent 7c1293c commit 7a4c386

File tree

1 file changed

+70
-71
lines changed

1 file changed

+70
-71
lines changed

public/js/game.ts

Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -884,77 +884,6 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
884884
}
885885
}
886886
}
887-
else if (eventType === EventType.KICK) {
888-
let kickReason: string = "You have been kicked.\nReason: " + (eventData.message || ""), showAlert: boolean = true;
889-
switch (eventData.type) {
890-
case KickTypes.CLIENT_MOD:
891-
kickReason += "\nThis is probably due to (a) client modification(s). Avoid doing so, as it is against the rules."
892-
break;
893-
case KickTypes.ELIMINATED:
894-
if (room instanceof EliminationRoom) {
895-
room.rewards.push({
896-
text: room.blobs.length + (room.blobs.length === 1
897-
? "st" : (room.blobs.length === 2
898-
? "nd" : (room.blobs.length === 3 ? "rd" : "th"))) + " place",
899-
gain: CoinChangeTable[room.blobs.length] || 0,
900-
gainCurrency: Currency.COINS,
901-
pos: 0
902-
});
903-
room.rewards.push({
904-
text: room.blobs.length + (room.blobs.length === 1
905-
? "st" : (room.blobs.length === 2
906-
? "nd" : (room.blobs.length === 3 ? "rd" : "th"))) + " place",
907-
gain: eventData.result,
908-
gainCurrency: Currency.BR,
909-
pos: 0
910-
});
911-
room.rewards.push({
912-
text: eventData.noms + " noms",
913-
gain: 5 * eventData.noms,
914-
gainCurrency: Currency.COINS,
915-
pos: 0
916-
});
917-
room.state = EliminationRoomState.ENDED;
918-
room.won = false;
919-
}
920-
showAlert = false;
921-
break;
922-
case KickTypes.MOD_KICK:
923-
kickReason += "\nThis is a mod-kick, which means that a moderator has noticed that you have violated the rules and taken action by kicking you from this room.\n";
924-
break;
925-
case KickTypes.WIN:
926-
console.log(eventData);
927-
if (room instanceof EliminationRoom) {
928-
room.rewards.push({
929-
text: "1st place",
930-
gain: CoinChangeTable[room.blobs.length] || 0,
931-
gainCurrency: Currency.COINS,
932-
pos: 0
933-
});
934-
room.rewards.push({
935-
text: "1st place",
936-
gain: eventData.result,
937-
gainCurrency: Currency.BR,
938-
pos: 0
939-
});
940-
room.rewards.push({
941-
text: eventData.noms + " noms",
942-
gain: 5 * eventData.noms,
943-
gainCurrency: Currency.COINS,
944-
pos: 0
945-
});
946-
room.state = EliminationRoomState.ENDED;
947-
room.won = true;
948-
}
949-
showAlert = false;
950-
break;
951-
}
952-
953-
if (showAlert) alert(kickReason)
954-
showWSCloseNotification = false;
955-
ownBlob.ready = false;
956-
room.blobs.splice(room.blobs.findIndex(b => b.username === ownBlob.username), 1);
957-
}
958887
else if (eventType === EventType.STATECHANGE) {
959888
if (room instanceof EliminationRoom) {
960889
room.countdownStarted = eventData.countdownStarted;
@@ -1027,6 +956,76 @@ if (["Android", "iOS"].some(v => window.navigator.userAgent.includes(v))) {
1027956
(ownBlob as any)[prop] = eventData[prop];
1028957
}
1029958
}
959+
} else if (op === OPCODE.CLOSE) {
960+
let kickReason: string = "You have been kicked.\nReason: " + (eventData.message || ""), showAlert: boolean = true;
961+
switch (eventData.type) {
962+
case KickTypes.CLIENT_MOD:
963+
kickReason += "\nThis is probably due to (a) client modification(s). Avoid doing so, as it is against the rules."
964+
break;
965+
case KickTypes.ELIMINATED:
966+
if (room instanceof EliminationRoom) {
967+
room.rewards.push({
968+
text: room.blobs.length + (room.blobs.length === 1
969+
? "st" : (room.blobs.length === 2
970+
? "nd" : (room.blobs.length === 3 ? "rd" : "th"))) + " place",
971+
gain: CoinChangeTable[room.blobs.length] || 0,
972+
gainCurrency: Currency.COINS,
973+
pos: 0
974+
});
975+
room.rewards.push({
976+
text: room.blobs.length + (room.blobs.length === 1
977+
? "st" : (room.blobs.length === 2
978+
? "nd" : (room.blobs.length === 3 ? "rd" : "th"))) + " place",
979+
gain: eventData.result,
980+
gainCurrency: Currency.BR,
981+
pos: 0
982+
});
983+
room.rewards.push({
984+
text: eventData.noms + " noms",
985+
gain: 5 * eventData.noms,
986+
gainCurrency: Currency.COINS,
987+
pos: 0
988+
});
989+
room.state = EliminationRoomState.ENDED;
990+
room.won = false;
991+
}
992+
showAlert = false;
993+
break;
994+
case KickTypes.MOD_KICK:
995+
kickReason += "\nThis is a mod-kick, which means that a moderator has noticed that you have violated the rules and taken action by kicking you from this room.\n";
996+
break;
997+
case KickTypes.WIN:
998+
console.log(eventData);
999+
if (room instanceof EliminationRoom) {
1000+
room.rewards.push({
1001+
text: "1st place",
1002+
gain: CoinChangeTable[room.blobs.length] || 0,
1003+
gainCurrency: Currency.COINS,
1004+
pos: 0
1005+
});
1006+
room.rewards.push({
1007+
text: "1st place",
1008+
gain: eventData.result,
1009+
gainCurrency: Currency.BR,
1010+
pos: 0
1011+
});
1012+
room.rewards.push({
1013+
text: eventData.noms + " noms",
1014+
gain: 5 * eventData.noms,
1015+
gainCurrency: Currency.COINS,
1016+
pos: 0
1017+
});
1018+
room.state = EliminationRoomState.ENDED;
1019+
room.won = true;
1020+
}
1021+
showAlert = false;
1022+
break;
1023+
}
1024+
1025+
if (showAlert) alert(kickReason)
1026+
showWSCloseNotification = false;
1027+
ownBlob.ready = false;
1028+
room.blobs.splice(room.blobs.findIndex(b => b.username === ownBlob.username), 1);
10301029
}
10311030
});
10321031
ws.onclose = () => {

0 commit comments

Comments
 (0)