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