Skip to content

Commit

Permalink
CoCのダイス装飾。
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanasu committed Feb 25, 2024
1 parent 4bd64fe commit 0f9b780
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/class/cut-in-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class CutInList extends ObjectNode implements InnerXml {
let isMatch = false;
for (const postfix of cutIn.postfixes) {
if (StringUtil.toHalfWidth(text).toUpperCase().trimRight().endsWith(StringUtil.toHalfWidth(postfix).toUpperCase().trimRight())
|| StringUtil.toHalfWidth(text.replace(/\s>\s/g, ' → ')).toUpperCase().trimRight().endsWith(StringUtil.toHalfWidth(postfix).toUpperCase().trimRight())) {
|| StringUtil.toHalfWidth(text.replace(/(\s|^)>\s/g, '$1→ ')).toUpperCase().trimRight().endsWith(StringUtil.toHalfWidth(postfix).toUpperCase().trimRight())) {
isMatch = true;
if ((postfix.slice(0, 1) == '@' || postfix.slice(0, 1) == '@') && textTagMatch.length < postfix.length) textTagMatch = postfix;
}
Expand Down
10 changes: 8 additions & 2 deletions src/app/class/dice-bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,15 @@ export class DiceBot extends GameObject {
let barabaraDiceInfos = [];
let rerollDiceInfos = [];
let upperDiceInfos = [];
return resultLine.split(' > ').map((resultFragment, i, a) => {
if (id === 'Cthulhu7th' && /^\d+(:?回目|次|번째): >/.test(resultLine)) resultLine = '🎲' + resultLine;
return resultLine.split(/\s>\s/).map((resultFragment, i, a) => {
if (a.length === 1) return resultFragment;
if (i == 0) {
if ((id === 'Cthulhu' && /\d\) (?:故障ナンバー|故障率|고장넘버)\[\-?\d+\]/.test(resultFragment))
|| (id === 'Cthulhu7th' && /\d\) (?:ボーナス・ペナルティダイス|獎勵、懲罰骰値|보너스, 패널티 주사위)\[\-?\d+\]/.test(resultFragment))
) {
return '🎲' + resultFragment;
}
const regExp1 = (DiceBot.apiUrl && DiceBot.apiVersion == 1) ? /^(?:\: )\(([A-Z\d\+\-\*\/=\(\),\[\]\<\>@#\$]+)\)$/i : /^\(([A-Z\d\+\-\*\/=\(\),\[\]\<\>@#\$]+)\)$/i;
const regExp2 = (DiceBot.apiUrl && DiceBot.apiVersion == 1) ? /^(?:\: )\((CHOICE(?:\d+)?[\[\( ].+)\)$/i : /^\((CHOICE(?:\d+)?[\[\( ].+)\)$/i;
const parentheses = resultFragment.match(regExp1) || resultFragment.match(regExp2);
Expand Down Expand Up @@ -805,7 +811,7 @@ export class DiceBot extends GameObject {
}
}
return resultFragment;
}).join(' → ');
}).join(' > ').replace(/(\s|^)>\s/g, '$1→ ');
}).join("\n");
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/class/stand-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class StandList extends DataElement {
for (let postfix of postfixes.split(/[\r\n]+/g)) {
if (postfix == null || postfix.trim().length == 0) continue;
if (StringUtil.toHalfWidth(text).toUpperCase().trimRight().endsWith(StringUtil.toHalfWidth(postfix).trimRight().toUpperCase())
|| StringUtil.toHalfWidth(text.replace(/\s>\s/g, ' → ')).toUpperCase().trimRight().endsWith(StringUtil.toHalfWidth(postfix).trimRight().toUpperCase())) {
|| StringUtil.toHalfWidth(text.replace(/(\s|^)>\s/g, '$1→ ')).toUpperCase().trimRight().endsWith(StringUtil.toHalfWidth(postfix).trimRight().toUpperCase())) {
if ((postfix.slice(0, 1) == '@' || postfix.slice(0, 1) == '@') && textTagMatch.length < postfix.length) textTagMatch = postfix;
conditionPostfix = true;
}
Expand Down

0 comments on commit 0f9b780

Please sign in to comment.