Improve readability

This commit is contained in:
syuilo 2019-01-15 12:03:31 +09:00
parent 87b6ba55c5
commit c95c2c76ef
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69

View file

@ -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 {
}
});
}
}
}