Skip to content

Commit

Permalink
ダイスまわりの処理を本家に追従、記載の統一
Browse files Browse the repository at this point in the history
取り込んだ本家CommitのHash
- c32d6be
- 9982a76
- 706ac9b
- febf933
  • Loading branch information
h-mikisato committed Nov 6, 2022
1 parent 5da8974 commit 10f41f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/app/class/bcdice/bcdice-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand Down
18 changes: 9 additions & 9 deletions src/app/class/dice-bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
Expand Down Expand Up @@ -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);
}
});
}

Expand Down Expand Up @@ -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);
Expand All @@ -215,7 +215,7 @@ export class DiceBot extends GameObject {
const chatMessage = ObjectStore.instance.get<ChatMessage>(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() ;
Expand All @@ -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 };
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"importHelpers": true,
"target": "es2017",
"module": "es2020",
Expand Down

0 comments on commit 10f41f6

Please sign in to comment.