mirror of
https://github.com/syuilo/ai.git
synced 2024-11-22 05:08:00 +00:00
Improve readability
This commit is contained in:
parent
87b6ba55c5
commit
c95c2c76ef
|
@ -7,6 +7,7 @@ import getCollection from '../../utils/get-collection';
|
|||
|
||||
export default class GuessingGameModule extends Module {
|
||||
public readonly name = 'guessingGame';
|
||||
|
||||
private guesses: loki.Collection<{
|
||||
userId: string;
|
||||
secret: number;
|
||||
|
@ -32,7 +33,8 @@ export default class GuessingGameModule extends Module {
|
|||
|
||||
@autobind
|
||||
private mentionHook(msg: MessageLike) {
|
||||
if (msg.includes(['数当て', '数あて'])) {
|
||||
if (!msg.includes(['数当て', '数あて'])) return false;
|
||||
|
||||
const exist = this.guesses.findOne({
|
||||
userId: msg.userId,
|
||||
isEnded: false
|
||||
|
@ -64,9 +66,6 @@ export default class GuessingGameModule extends Module {
|
|||
});
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
|
@ -93,11 +92,12 @@ export default class GuessingGameModule extends Module {
|
|||
msg.reply(serifs.guessingGame.nan).then(reply => {
|
||||
this.subscribeReply(msg.userId, msg.isMessage, reply.id);
|
||||
});
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (guess.length > 3) return;
|
||||
|
||||
const g = parseInt(guess[0], 10);
|
||||
|
||||
const firsttime = exist.tries.indexOf(g) === -1;
|
||||
|
||||
exist.tries.push(g);
|
||||
|
@ -132,5 +132,4 @@ export default class GuessingGameModule extends Module {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue