From 988cf87aeebdfdb9f24ba31147abeae8279ed883 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 1 Sep 2018 19:36:58 +0900 Subject: [PATCH] Improve AI --- src/friend.ts | 19 +++++++++++++++++++ src/modules/core/index.ts | 30 ++++++++++++++++++++++-------- src/serifs.ts | 14 ++++++++++++-- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/src/friend.ts b/src/friend.ts index 6677ebf..6b76073 100644 --- a/src/friend.ts +++ b/src/friend.ts @@ -92,11 +92,30 @@ export default class Friend { if (this.doc.love == null) this.doc.love = 0; this.doc.love++; + + // 最大 100 + if (this.doc.love > 100) this.doc.love = 100; + this.doc.lastLoveIncrementedAt = today; this.doc.todayLoveIncrements = (this.doc.todayLoveIncrements || 0) + 1; this.save(); } + public decLove = () => { + if (this.doc.love == null) this.doc.love = 0; + this.doc.love--; + + // 最低 -30 + if (this.doc.love < -30) this.doc.love = -30; + + // 親愛度マイナスなら名前を忘れる + if (this.doc.love < 0) { + this.doc.name = null; + } + + this.save(); + } + public updateName = (name: string) => { this.doc.name = name; this.save(); diff --git a/src/modules/core/index.ts b/src/modules/core/index.ts index d5f9d2a..2b70934 100644 --- a/src/modules/core/index.ts +++ b/src/modules/core/index.ts @@ -147,6 +147,11 @@ export default class CoreModule implements IModule { return true; } + if (includes(msg.text, ['ぽんこつ'])) { + msg.friend.decLove(); + return true; + } + return false; } @@ -156,22 +161,28 @@ export default class CoreModule implements IModule { // メッセージのみ if (!msg.isMessage) return true; - //#region 1日に1回だけ親愛度を上げる - const today = getDate(); + //#region 1日に1回だけ親愛度を上げる(嫌われてない場合のみ) + if (msg.friend.love >= 0) { + const today = getDate(); - const data = msg.friend.getPerModulesData(this); + const data = msg.friend.getPerModulesData(this); - if (data.lastNadenadeAt != today) { - data.lastNadenadeAt = today; - msg.friend.setPerModulesData(this, data); + if (data.lastNadenadeAt != today) { + data.lastNadenadeAt = today; + msg.friend.setPerModulesData(this, data); - msg.friend.incLove(); + msg.friend.incLove(); + } } //#endregion msg.reply( msg.friend.love >= 10 ? serifs.core.nadenade3 : msg.friend.love >= 5 ? serifs.core.nadenade2 : + msg.friend.love <= -15 ? serifs.core.nadenadeIya4 : + msg.friend.love <= -10 ? serifs.core.nadenadeIya3 : + msg.friend.love <= -5 ? serifs.core.nadenadeIya2 : + msg.friend.love <= -1 ? serifs.core.nadenadeIya1 : serifs.core.nadenade1 ); @@ -181,7 +192,10 @@ export default class CoreModule implements IModule { private kawaii = (msg: MessageLike): boolean => { if (!includes(msg.text, ['かわいい', '可愛い'])) return false; - msg.reply(msg.friend.love >= 5 ? serifs.core.kawaii2 : serifs.core.kawaii1); + msg.reply( + msg.friend.love >= 5 ? serifs.core.kawaii2 : + msg.friend.love <= -3 ? serifs.core.kawaiiIya1 : + serifs.core.kawaii1); return true; } diff --git a/src/serifs.ts b/src/serifs.ts index f54fc61..c004ef8 100644 --- a/src/serifs.ts +++ b/src/serifs.ts @@ -22,15 +22,25 @@ export default { happyBirthday: name => name ? `お誕生日おめでとうございます、${name}🎉` : 'お誕生日おめでとうございます🎉', - nadenade1: '…っ! びっくりしました', + nadenade1: '…! びっくりしました', nadenade2: 'わわっ… 恥ずかしいです', nadenade3: 'ん… ありがとうございます♪', + nadenadeIya1: '…っ! やめてほしいです...', + + nadenadeIya2: '触らないでください', + + nadenadeIya3: '近寄らないでください', + + nadenadeIya4: 'やめてください。刺しますよ?', + kawaii1: 'ありがとうございます♪', - kawaii2: '嬉しいです♪' + kawaii2: '嬉しいです♪', + + kawaiiIya1: '...ありがとうございます', }, keyword: {