feedback4: a bond card's layer-scaled chance (不屈, 迅捷, 奇迹) stops at 100 % like the sim's (GitHub #108: 124 % at 266 layers)
This commit is contained in:
1 parent
723755e3a5
commit
305b524df2
2 files changed
+9
-1
No files matched your search
@@ -175,7 +175,10 @@ export function formatBondEffect(bond, layers = 0) {
|
|||||||
if (!p || !Number.isInteger(p.index)) continue;
|
if (!p || !Number.isInteger(p.index)) continue;
|
||||||
const base = Number(bb[p.base]) || 0;
|
const base = Number(bb[p.base]) || 0;
|
||||||
const per = Number(bb[p.perStack]) || 0;
|
const per = Number(bb[p.perStack]) || 0;
|
||||||
values[p.index] = base + per * L;
|
// a layer-scaled chance (迅捷 / 不屈 base_prob + prob_per_stack, 奇迹 baseprob + prob) stops at 100 % like the sim's
|
||||||
|
// min(1, …) (bonds/addon procChance, meta.js 奇迹) — the card read 124 % at 266 layers (GitHub #108)
|
||||||
|
const chance = /prob/i.test(`${p.base}|${p.perStack}`);
|
||||||
|
values[p.index] = chance ? Math.max(0, Math.min(1, base + per * L)) : base + per * L;
|
||||||
formats[p.index] = p.format || '0';
|
formats[p.index] = p.format || '0';
|
||||||
}
|
}
|
||||||
return fillPlaceholders(src, values, formats);
|
return fillPlaceholders(src, values, formats);
|
||||||
|
|||||||
@@ -89,6 +89,11 @@ describe('placeholders', () => {
|
|||||||
const out = richTextPlain(formatBondEffect(b, 25));
|
const out = richTextPlain(formatBondEffect(b, 25));
|
||||||
assert.ok(!/\{\d+(:[^}]*)?\}/.test(out), `${b.bondId} leaves a placeholder: ${out}`);
|
assert.ok(!/\{\d+(:[^}]*)?\}/.test(out), `${b.bondId} leaves a placeholder: ${out}`);
|
||||||
}
|
}
|
||||||
|
// a chance stops at 100 % (GitHub #108: 不屈 read 124 % at 266 layers; the sim caps it with min(1, …))
|
||||||
|
for (const id of ['indomShip', 'swiftShip', 'miraShip']) {
|
||||||
|
const pct = richTextPlain(formatBondEffect(bonds[id], 500)).match(/(\d+)%/);
|
||||||
|
assert.ok(pct && Number(pct[1]) === 100, `${id} at 500 layers: ${pct && pct[0]}`);
|
||||||
|
}
|
||||||
assert.equal(formatBondEffect(null, 3), '');
|
assert.equal(formatBondEffect(null, 3), '');
|
||||||
assert.equal(formatBondEffect({ effectDesc: 'x{0:0}', effectDescParams: [{ index: 0, format: '0', base: 'a', perStack: 'b' }], bb: { a: 1, b: 2 } }, 'bad'), 'x1');
|
assert.equal(formatBondEffect({ effectDesc: 'x{0:0}', effectDescParams: [{ index: 0, format: '0', base: 'a', perStack: 'b' }], bb: { a: 1, b: 2 } }, 'bad'), 'x1');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user