Commit d78ea237 authored by nanahira's avatar nanahira

search with room name

parent 3ce3db89
......@@ -235,22 +235,13 @@ export class YGOTournamentPlugin {
return { tournament, matches };
}
const roomlist = await this.fetchSRVProRoomlist();
const zombieMatches = matches.filter((m) => {
const player1 = tournament.getParticipantFromParticipantId(
m.match.player1_id,
);
const player2 = tournament.getParticipantFromParticipantId(
m.match.player2_id,
);
const player1Name = player1.getNameMatching().userName;
const player2Name = player2.getNameMatching().userName;
const roomsWithPlayer1 = roomlist.searchForUser(player1Name);
const roomsWithPlayer2 = roomlist.searchForUser(player2Name);
return (
roomsWithPlayer1.every((r) => r.istart === 'wait') &&
roomsWithPlayer2.every((r) => r.istart === 'wait')
);
});
const zombieMatches = matches.filter(
(m) =>
!roomlist.rooms.some(
(r) =>
r.roomname.endsWith(m.match.id.toString()) && r.istart !== 'wait',
),
);
return { tournament, matches: zombieMatches };
}
......@@ -426,7 +417,10 @@ export class YGOTournamentPlugin {
if (reply !== 'yes') {
return '清理被取消。';
}
const logger = this.ctx.logger('challonge');
logger.info(`Cleaning ${matches.length} zombie matches.`);
await Promise.all(matches.map((m) => this.cleanZombieMatch(m)));
logger.info(`Cleaned ${matches.length} zombie matches.`);
return `清理成功,清理了 ${matches.length} 个僵尸对局。`;
} catch (e) {
this.ctx
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment