From 10f41f66790eb2cdcc259f96269bb5686866f513 Mon Sep 17 00:00:00 2001 From: Hideyo Mikisato Date: Mon, 7 Nov 2022 00:45:00 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=80=E3=82=A4=E3=82=B9=E3=81=BE=E3=82=8F?= =?UTF-8?q?=E3=82=8A=E3=81=AE=E5=87=A6=E7=90=86=E3=82=92=E6=9C=AC=E5=AE=B6?= =?UTF-8?q?=E3=81=AB=E8=BF=BD=E5=BE=93=E3=80=81=E8=A8=98=E8=BC=89=E3=81=AE?= =?UTF-8?q?=E7=B5=B1=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 取り込んだ本家CommitのHash - c32d6be - 9982a76 - 706ac9b - febf933 --- src/app/class/bcdice/bcdice-loader.ts | 4 ++-- src/app/class/dice-bot.ts | 18 +++++++++--------- tsconfig.json | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/app/class/bcdice/bcdice-loader.ts b/src/app/class/bcdice/bcdice-loader.ts index a1c570824..092d0ab0f 100644 --- a/src/app/class/bcdice/bcdice-loader.ts +++ b/src/app/class/bcdice/bcdice-loader.ts @@ -6,8 +6,8 @@ export default class BCDiceLoader extends Loader { return (await import( /* webpackChunkName: "lib/bcdice/i18n/[request]" */ /* webpackInclude: /\.json$/ */ - `bcdice/lib/bcdice/i18n/${baseClassName}.${locale}.json` - )).default as I18nJsonObject; + /* webpackExclude: /i18n.json$/ */ + `bcdice/lib/bcdice/i18n/${baseClassName}.${locale}.json`)).default as I18nJsonObject; } async dynamicImport(className: string): Promise { diff --git a/src/app/class/dice-bot.ts b/src/app/class/dice-bot.ts index fd7a557b5..f83568f45 100644 --- a/src/app/class/dice-bot.ts +++ b/src/app/class/dice-bot.ts @@ -82,7 +82,7 @@ export class DiceBot extends GameObject { console.log('isSecret!!!', result.secret); return { id: gameSystem.ID, - result: `${gameSystem.ID} : ${result.text}`, + result: `${gameSystem.ID} : ${result.text}`.replace(/\n?(#\d+)\n/ig, '$1 '), // 繰り返しダイスロールは改行表示を短縮する isSecret: result.secret, }; } @@ -118,10 +118,12 @@ export class DiceBot extends GameObject { if ( system ) { return system; } - const id = this.diceBotInfos.some((info) => info.id === gameType) - ? gameType - : 'DiceBot'; - return DiceBot.loader.dynamicLoad(id); + const id = this.diceBotInfos.some((info) => info.id === gameType) ? gameType : 'DiceBot'; + try { + return DiceBot.loader.getGameSystemClass(id); + } catch { + return DiceBot.loader.dynamicLoad(id); + } }); } @@ -201,8 +203,6 @@ export class DiceBot extends GameObject { const rollResult = await DiceBot.diceRollAsync(rollText, gameSystem); if (!rollResult.result) { return; } - rollResult.result = rollResult.result.replace(/\n?(#\d+)\n/ig, '$1 '); // 繰り返しロールを詰める - this.sendResultMessage(rollResult, chatMessage); } catch (e) { console.error(e); @@ -215,7 +215,7 @@ export class DiceBot extends GameObject { const chatMessage = ObjectStore.instance.get(event.data.messageIdentifier); if (!chatMessage || !chatMessage.isSendFromSelf || chatMessage.isSystem) { return; } - const text: string = StringUtil.toHalfWidth(chatMessage.text); + const text: string = StringUtil.toHalfWidth(chatMessage.text).trim(); const splitText = text.split(/\s/); const diceTable = this.getDiceTables() ; @@ -234,7 +234,7 @@ export class DiceBot extends GameObject { if ( !rollTable ) { return; } try { - const regArray = /^((\d+)?\s+)?([^\s]*)?/ig.exec(rollTable.dice); + const regArray = /^((\d+)?\s+)?(.*)?/ig.exec(rollTable.dice); const repeat: number = (regArray[2] != null) ? Number(regArray[2]) : 1; const rollText: string = (regArray[3] != null) ? regArray[3] : text; const finalResult: DiceRollResult = { result: '', isSecret: false }; diff --git a/tsconfig.json b/tsconfig.json index 5c2bd36fb..adec639ae 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "downlevelIteration": true, "experimentalDecorators": true, "moduleResolution": "node", + "resolveJsonModule": true, "importHelpers": true, "target": "es2017", "module": "es2020",