From c4610894fbbe86006a65df9032b39a8170cf9596 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 12 Aug 2018 23:25:47 +0900 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E5=BD=93=E3=81=A6=E3=82=B2=E3=83=BC?= =?UTF-8?q?=E3=83=A0=E3=81=AF=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=A7=E3=81=AE=E3=81=BF=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/guessing-game/index.ts | 39 ++++++++++++++++++------------ src/serifs.ts | 5 ++++ 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/modules/guessing-game/index.ts b/src/modules/guessing-game/index.ts index 5d96c72..a1cc139 100644 --- a/src/modules/guessing-game/index.ts +++ b/src/modules/guessing-game/index.ts @@ -30,24 +30,31 @@ export default class GuessingGameModule implements IModule { isEnded: false }); - if (exist != null) { - msg.reply(serifs.GUESSINGGAME_ARLEADY_STARTED); - } else { - const secret = Math.floor(Math.random() * 100); + if (!msg.isMessage) { + if (exist != null) { + msg.reply(serifs.GUESSINGGAME_ARLEADY_STARTED); + } else { + msg.reply(serifs.GUESSINGGAME_PLZ_DM); + } - guesses.insertOne({ - userId: msg.userId, - secret: secret, - tries: [], - isEnded: false, - startedAt: Date.now(), - endedAt: null - }); - - msg.reply(serifs.GUESSINGGAME_STARTED).then(reply => { - this.ai.subscribeReply(this, msg.userId, msg.isMessage, msg.isMessage ? msg.userId : reply.id); - }); + return true; } + + const secret = Math.floor(Math.random() * 100); + + guesses.insertOne({ + userId: msg.userId, + secret: secret, + tries: [], + isEnded: false, + startedAt: Date.now(), + endedAt: null + }); + + msg.reply(serifs.GUESSINGGAME_STARTED).then(reply => { + this.ai.subscribeReply(this, msg.userId, msg.isMessage, msg.isMessage ? msg.userId : reply.id); + }); + return true; } else { return false; diff --git a/src/serifs.ts b/src/serifs.ts index fb88097..f115d94 100644 --- a/src/serifs.ts +++ b/src/serifs.ts @@ -42,6 +42,11 @@ export default { */ GUESSINGGAME_ARLEADY_STARTED: 'え、ゲームは既に始まってますよ!', + /** + * タイムライン上で数当てゲームに誘われたとき + */ + GUESSINGGAME_PLZ_DM: 'メッセージでやりましょう!', + /** * 数当てゲーム開始 */