@bot-shiki/koishi-plugin-werewolf
Version:
Touhou werewolf game
79 lines (78 loc) • 3.56 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require(".");
const utils_1 = require("../utils");
class ExileAction extends _1.VoteAction {
async action() {
let speakers = await this.game.sage.order();
speakers = speakers.filter(c => !c.isDead);
speakers = await this.round(1, speakers);
if (speakers.length > 1) {
if (this.game.weather !== 'nagi') {
speakers = await this.round(2, speakers);
if (speakers.length > 1)
speakers = [];
}
else {
speakers = [];
await this.game.room.broadcast((0, utils_1.t)('weather.nagi.hint'));
}
}
const [char] = speakers;
if (char) {
char.killer = 'vote';
if (char.identity === 'parsee') {
char.isWellKnown = true;
const chars = this.game.seats.filter(c => c.target === char);
const players = chars.map(c => c.player.name).join(', ');
chars.forEach(c => c.killer = 'parsee');
await this.game.room.broadcast((0, utils_1.t)('exile.parsee', [char.player.name, players]));
}
else if (char.identity === 'utsuho') {
char.isWellKnown = true;
char.isOut = true;
await this.game.room.broadcast((0, utils_1.t)('exile.utsuho', [char.player.name]));
await this.game.death.lastWords([char]);
}
else if (this.game.weather === 'hanagumori') {
char.isWellKnown = true;
await this.game.room.broadcast((0, utils_1.t)('exile.hanagumori', [char.player.name, char.identity]));
}
else {
await this.game.room.broadcast((0, utils_1.t)('exile.death', [char.player.name]));
}
}
else {
await this.game.room.broadcast((0, utils_1.t)('exile.nobody', [this.game.dayCount]));
}
}
async round(round, speakers) {
const others = this.game.room.filter(p => !speakers.includes(this.game.chars.get(p)));
if (this.game.weather === 'donten') {
speakers.forEach(c => c.player.allowSpeech = true);
await Promise.all([
others.broadcast((0, utils_1.t)('exile.douten', [round])),
...speakers.map(async (char) => {
await char.player.send((0, utils_1.t)('exile.douten-hint'));
await char.player.select(['.', '。'], 60000);
}),
]);
speakers.forEach(c => c.player.allowSpeech = false);
}
else {
await this.game.room.broadcast((0, utils_1.t)('exile.speech', [round]));
for (const char of speakers) {
const others = this.game.room.filter(p => p !== char.player);
await others.broadcast((0, utils_1.t)('general.speech-action', [char.player.name]));
char.player.allowSpeech = true;
await char.player.send((0, utils_1.t)('exile.speech-hint'));
await char.player.select(['.', '。'], 60000);
char.player.allowSpeech = false;
}
}
await this.game.room.broadcast((0, utils_1.t)('exile.vote', [round]));
const voters = this.game.seats.filter(c => !c.isDead);
return this.vote(round, voters, speakers, (0, utils_1.t)('exile.vote-hint'));
}
}
exports.default = ExileAction;