mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-21 17:25:10 -05:00
parent
2a88d42831
commit
719bc1a87f
|
|
@ -176,13 +176,10 @@ export class UNO extends Rooms.RoomGame<UNOPlayer> {
|
|||
}
|
||||
|
||||
override leaveGame(user: User) {
|
||||
if (!(user.id in this.playerTable)) return false;
|
||||
const player = this.playerTable[user.id];
|
||||
if ((this.state === 'signups' && this.removePlayer(player)) || this.eliminate(user.id)) {
|
||||
this.sendToRoom(`${user.name} has left the game of UNO.`);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (!player) return false;
|
||||
this.sendToRoom(`${user.name} has left the game of UNO.`);
|
||||
return this.state === 'signups' ? this.removePlayer(player) : this.eliminate(player);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -202,17 +199,14 @@ export class UNO extends Rooms.RoomGame<UNOPlayer> {
|
|||
this.renamePlayer(user, oldUserid);
|
||||
}
|
||||
|
||||
eliminate(userid: ID | undefined) {
|
||||
if (!userid) return null;
|
||||
const player = this.playerTable[userid];
|
||||
eliminate(player: UNOPlayer | null) {
|
||||
if (!player) return false;
|
||||
|
||||
const name = player.name;
|
||||
|
||||
if (this.playerCount === 2) {
|
||||
this.removePlayer(player);
|
||||
this.onWin(this.players[0]);
|
||||
return name;
|
||||
return true;
|
||||
}
|
||||
|
||||
// handle current player...
|
||||
|
|
@ -243,7 +237,7 @@ export class UNO extends Rooms.RoomGame<UNOPlayer> {
|
|||
if (removingCurrentPlayer) {
|
||||
this.nextTurn(true);
|
||||
}
|
||||
return name;
|
||||
return true;
|
||||
}
|
||||
|
||||
sendToRoom(msg: string, overrideSuppress = false) {
|
||||
|
|
@ -310,7 +304,7 @@ export class UNO extends Rooms.RoomGame<UNOPlayer> {
|
|||
|
||||
this.timer = setTimeout(() => {
|
||||
this.sendToRoom(`|c:|${Math.floor(Date.now() / 1000)}|~|${player.name} has been automatically disqualified.`);
|
||||
this.eliminate(player.id);
|
||||
this.eliminate(player);
|
||||
}, this.maxTime * 1000);
|
||||
});
|
||||
}
|
||||
|
|
@ -425,7 +419,7 @@ export class UNO extends Rooms.RoomGame<UNOPlayer> {
|
|||
this.isPlusFour = true;
|
||||
this.timer = setTimeout(() => {
|
||||
this.sendToRoom(`|c:|${Math.floor(Date.now() / 1000)}|~|${this.currentPlayer!.name} has been automatically disqualified.`);
|
||||
this.eliminate(this.currentPlayer!.id);
|
||||
this.eliminate(this.currentPlayer);
|
||||
}, this.maxTime * 1000);
|
||||
break;
|
||||
case 'Wild':
|
||||
|
|
@ -433,7 +427,7 @@ export class UNO extends Rooms.RoomGame<UNOPlayer> {
|
|||
this.state = 'color';
|
||||
this.timer = setTimeout(() => {
|
||||
this.sendToRoom(`|c:|${Math.floor(Date.now() / 1000)}|~|${this.currentPlayer!.name} has been automatically disqualified.`);
|
||||
this.eliminate(this.currentPlayer!.id);
|
||||
this.eliminate(this.currentPlayer);
|
||||
}, this.maxTime * 1000);
|
||||
break;
|
||||
}
|
||||
|
|
@ -709,7 +703,7 @@ export const commands: Chat.ChatCommands = {
|
|||
game.maxTime = amount;
|
||||
if (game.timer) clearTimeout(game.timer);
|
||||
game.timer = setTimeout(() => {
|
||||
game.eliminate(game.currentPlayer?.id);
|
||||
game.eliminate(game.currentPlayer);
|
||||
}, amount * 1000);
|
||||
this.addModAction(`${user.name} has set the UNO automatic disqualification timer to ${amount} seconds.`);
|
||||
this.modlog('UNO TIMER', null, `${amount} seconds`);
|
||||
|
|
@ -743,11 +737,12 @@ export const commands: Chat.ChatCommands = {
|
|||
this.checkCan('minigame', null, room);
|
||||
const game = this.requireGame(UNO);
|
||||
|
||||
const disqualified = game.eliminate(toID(target));
|
||||
if (disqualified === false) throw new Chat.ErrorMessage(`Unable to disqualify ${target}.`);
|
||||
this.privateModAction(`${user.name} has disqualified ${disqualified} from the UNO game.`);
|
||||
const player = game.playerTable[toID(target)];
|
||||
if (!player) throw new Chat.ErrorMessage(`Player "${target}" not found.`);
|
||||
game.eliminate(player);
|
||||
this.privateModAction(`${user.name} has disqualified ${player.name} from the UNO game.`);
|
||||
this.modlog('UNO DQ', toID(target));
|
||||
room.add(`${disqualified} has been disqualified from the UNO game.`).update();
|
||||
room.add(`${player.name} has been disqualified from the UNO game.`).update();
|
||||
},
|
||||
|
||||
// player/user commands
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user