mirror of
https://github.com/syuilo/ai.git
synced 2024-11-22 13:17:59 +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 {
|
export default class GuessingGameModule extends Module {
|
||||||
public readonly name = 'guessingGame';
|
public readonly name = 'guessingGame';
|
||||||
|
|
||||||
private guesses: loki.Collection<{
|
private guesses: loki.Collection<{
|
||||||
userId: string;
|
userId: string;
|
||||||
secret: number;
|
secret: number;
|
||||||
|
@ -32,7 +33,8 @@ export default class GuessingGameModule extends Module {
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
private mentionHook(msg: MessageLike) {
|
private mentionHook(msg: MessageLike) {
|
||||||
if (msg.includes(['数当て', '数あて'])) {
|
if (!msg.includes(['数当て', '数あて'])) return false;
|
||||||
|
|
||||||
const exist = this.guesses.findOne({
|
const exist = this.guesses.findOne({
|
||||||
userId: msg.userId,
|
userId: msg.userId,
|
||||||
isEnded: false
|
isEnded: false
|
||||||
|
@ -64,9 +66,6 @@ export default class GuessingGameModule extends Module {
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
|
@ -93,11 +92,12 @@ export default class GuessingGameModule extends Module {
|
||||||
msg.reply(serifs.guessingGame.nan).then(reply => {
|
msg.reply(serifs.guessingGame.nan).then(reply => {
|
||||||
this.subscribeReply(msg.userId, msg.isMessage, reply.id);
|
this.subscribeReply(msg.userId, msg.isMessage, reply.id);
|
||||||
});
|
});
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (guess.length > 3) return;
|
if (guess.length > 3) return;
|
||||||
|
|
||||||
const g = parseInt(guess[0], 10);
|
const g = parseInt(guess[0], 10);
|
||||||
|
|
||||||
const firsttime = exist.tries.indexOf(g) === -1;
|
const firsttime = exist.tries.indexOf(g) === -1;
|
||||||
|
|
||||||
exist.tries.push(g);
|
exist.tries.push(g);
|
||||||
|
@ -133,4 +133,3 @@ export default class GuessingGameModule extends Module {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue