@bot-shiki/koishi-plugin-werewolf
Version:
Touhou werewolf game
74 lines (73 loc) • 3 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require(".");
const utils_1 = require("../utils");
class YukariAction extends _1.ExpertAction {
identity = 'yukari';
saveUsed;
killUsed;
async save() {
const output = [];
const taiji = this.game.ningen.target;
if (this.saveUsed) {
utils_1.logger.debug('yukari save exhausted');
return this.player.pause(60000, (0, utils_1.t)('character.yukari.save.exhausted'));
}
else if (!taiji) {
return this.player.pause(60000, (0, utils_1.t)('character.yukari.save.nobody'));
}
else if (taiji === this.character) {
if (this.game.weather === 'baiu') {
output.push((0, utils_1.t)('character.yukari.save.baiu'));
}
else {
return this.player.pause(60000, (0, utils_1.t)('character.yukari.save.self'));
}
}
else {
if (this.game.weather === 'kaisei') {
return this.player.pause(60000, (0, utils_1.t)('character.yukari.save.kaisei'));
}
else {
output.push((0, utils_1.t)('character.yukari.save.normal', [taiji.player.name]));
}
}
const result = await this.player.confirm(60000, output);
if (!result) {
utils_1.logger.debug('yukari save unused');
return this.player.send((0, utils_1.t)('character.yukari.save.cancel'));
}
if (this.retsujitsu())
return this.player.send((0, utils_1.t)('weather.retsujitsu.hint'));
this.game.ningen.target = null;
taiji.killer = null;
this.saveUsed = true;
utils_1.logger.debug('yukari save used');
await this.player.send((0, utils_1.t)('character.yukari.save.success', [taiji.player.name]));
}
async kill() {
if (this.killUsed) {
utils_1.logger.debug('yukari kill exhausted');
return this.player.pause(60000, (0, utils_1.t)('character.yukari.kill.exhausted'));
}
await this.player.send((0, utils_1.t)('character.yukari.kill.normal'));
const target = await this.character.select(c => ({
disabled: c.isDead,
}), 60000, true);
utils_1.logger.debug('yukari target: %s', target);
if (!target)
return this.player.send((0, utils_1.t)('character.yukari.kill.cancel'));
if (this.retsujitsu())
return this.player.send((0, utils_1.t)('weather.retsujitsu.hint'));
this.killUsed = true;
target.killer = 'yukari';
utils_1.logger.debug('yukari kill used');
await this.player.send((0, utils_1.t)('character.yukari.kill.success', [target.player.name]));
}
async callback() {
await this.player.send((0, utils_1.t)('character.yukari.action'));
await this.save();
await this.kill();
}
}
exports.default = YukariAction;