fix addition
This commit is contained in:
@@ -328,11 +328,26 @@ function renderHistory() {
|
||||
// Create a mapping of which dice contributes which parts
|
||||
let dicePartMapping = [];
|
||||
entry.dices.forEach(dice => {
|
||||
// Map the actual dice rolls (count number of rolls per dice)
|
||||
for (let i = 0; i < dice.count; i++) {
|
||||
if (partIndex < formulaParts.length && !isNaN(parseInt(formulaParts[partIndex]))) {
|
||||
dicePartMapping.push({
|
||||
partIndex: partIndex,
|
||||
dice: dice
|
||||
dice: dice,
|
||||
isDiceRoll: true
|
||||
});
|
||||
partIndex++;
|
||||
}
|
||||
}
|
||||
// Skip the dice addition - it should remain uncolored
|
||||
if (dice.addition && partIndex < formulaParts.length) {
|
||||
// Check if this part matches the dice addition
|
||||
const currentPart = formulaParts[partIndex];
|
||||
if (!isNaN(parseInt(currentPart)) && parseInt(currentPart) === Math.abs(dice.addition)) {
|
||||
dicePartMapping.push({
|
||||
partIndex: partIndex,
|
||||
dice: dice,
|
||||
isDiceRoll: false // This is a modifier, not a dice roll
|
||||
});
|
||||
partIndex++;
|
||||
}
|
||||
@@ -342,8 +357,8 @@ function renderHistory() {
|
||||
formulaParts.forEach((part, index) => {
|
||||
const mapping = dicePartMapping.find(m => m.partIndex === index);
|
||||
|
||||
if (mapping) {
|
||||
// This part comes from a dice roll
|
||||
if (mapping && mapping.isDiceRoll) {
|
||||
// This part comes from a dice roll - color it
|
||||
const partSpan = document.createElement("span");
|
||||
partSpan.innerText = part;
|
||||
partSpan.style.color = mapping.dice.color;
|
||||
@@ -357,7 +372,7 @@ function renderHistory() {
|
||||
}
|
||||
diceFormula.appendChild(partSpan);
|
||||
} else {
|
||||
// This is an addition value (modifier)
|
||||
// This is a modifier or unrelated value - no color
|
||||
const partSpan = document.createElement("span");
|
||||
partSpan.innerText = part;
|
||||
diceFormula.appendChild(partSpan);
|
||||
|
||||
Reference in New Issue
Block a user