The rise of NaNs

Resolved Dice Parsing Errors, now dealing with parsing errors from system values.
This commit is contained in:
Nikhil Nagarajan 2025-07-21 15:48:37 -04:00
parent 29d7a3e597
commit 9c273d8a40

View file

@ -305,9 +305,10 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
rerollEvent = async(event,message)=> { rerollEvent = async(event,message)=> {
let DieTerm=foundry.dice.terms.Die; let DieTerm=foundry.dice.terms.Die;
let dicetype = event.target.value; let dicetype = event.target.value;
let originalRoll=message.rolls.map(roll => JSON.parse(roll))[0]; let originalRoll_parsed=message.rolls.map(roll => JSON.parse(roll))[0];
let originalRoll=Roll.fromData(originalRoll_parsed);
let diceIndex; let diceIndex;
console.log("Dice to reroll is:",dicetype,", and the message id is:",message._id) console.log("Dice to reroll is:",dicetype,", and the message id is:",message._id,originalRoll_parsed);
console.log("Original Roll Terms:",originalRoll.terms); console.log("Original Roll Terms:",originalRoll.terms);
switch(dicetype){ switch(dicetype){
case "hope": { case "hope": {
@ -315,22 +316,25 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
break; break;
}; };
case "fear" :{ case "fear" :{
diceIndex=2 //Fear Die diceIndex=2; //Fear Die
break; break;
}; };
default: default:
ui.notifications.warn("Invalid Dice type selected."); ui.notifications.warn("Invalid Dice type selected.");
break; break;
} }
let rollClone=originalRoll;
let rollClone=originalRoll.clone();
let rerolledTerm=rollClone.terms[diceIndex]; let rerolledTerm=rollClone.terms[diceIndex];
console.log("originalRoll:",originalRoll,"rollClone:",rollClone,"rerolledTerm",rerolledTerm);
if (!(rerolledTerm instanceof DieTerm)) { if (!(rerolledTerm instanceof DieTerm)) {
ui.notifications.error("Selected term is not a die."); ui.notifications.error("Selected term is not a die.");
return; return;
} }
/* await rollClone.reroll()[diceIndex];
await rerolledTerm.reroll();
await rollClone.evaluate(); await rollClone.evaluate();
console.log(rollClone.result);
const confirm = await foundry.applications.api.DialogV2.confirm({ const confirm = await foundry.applications.api.DialogV2.confirm({
window: { title: 'Confirm Reroll' }, window: { title: 'Confirm Reroll' },
content: `<p>You have rerolled your <strong>${dicetype}</strong> die to <strong>${rerolledTerm.results[0].result}</strong>.</p><p>Apply this new roll?</p>` content: `<p>You have rerolled your <strong>${dicetype}</strong> die to <strong>${rerolledTerm.results[0].result}</strong>.</p><p>Apply this new roll?</p>`
@ -338,6 +342,5 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
if (!confirm) return; if (!confirm) return;
rollClone.toMessage({flavor: 'Selective reroll applied for ${dicetype}.'}); rollClone.toMessage({flavor: 'Selective reroll applied for ${dicetype}.'});
console.log("Updated Roll",rollClone); console.log("Updated Roll",rollClone);
*/
} }
} }