mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
Redoing Dice Reroll functionality
Attempting something new
This commit is contained in:
parent
65e010caf8
commit
29d7a3e597
2 changed files with 43 additions and 61 deletions
|
|
@ -303,61 +303,41 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
|
|
||||||
//Reroll Functionality
|
//Reroll Functionality
|
||||||
rerollEvent = async(event,message)=> {
|
rerollEvent = async(event,message)=> {
|
||||||
let originalMessage = message;
|
let DieTerm=foundry.dice.terms.Die;
|
||||||
let dicetype = "str";
|
let dicetype = event.target.value;
|
||||||
let originalobject=originalMessage.rolls.map(roll => JSON.parse(roll));
|
let originalRoll=message.rolls.map(roll => JSON.parse(roll))[0];
|
||||||
let fear,hope;
|
let diceIndex;
|
||||||
|
console.log("Dice to reroll is:",dicetype,", and the message id is:",message._id)
|
||||||
if (originalMessage.rolls.length) {
|
console.log("Original Roll Terms:",originalRoll.terms);
|
||||||
console.log("Reroll button clicked for message:", originalMessage._id,originalMessage,originalobject);
|
|
||||||
if (originalobject[0].class==='DualityRoll') {
|
|
||||||
new foundry.applications.api.DialogV2({
|
|
||||||
window: { title: 'Reroll' },
|
|
||||||
content: '<p>Select which die/dice to reroll:</p><label><input type="radio" name="choice" value="fear" checked> Fear</label><label><input type="radio" name="choice" value="hope"> Hope</label><label><input type="radio" name="choice" value="both"> Both</label><p>Confirm option?</p>',
|
|
||||||
buttons:[{
|
|
||||||
action: "choice",
|
|
||||||
label: "Confirm Choice",
|
|
||||||
default: true,
|
|
||||||
callback: (event, button, dialog) => button.form.elements.choice.value
|
|
||||||
},
|
|
||||||
{
|
|
||||||
action: "cancel",
|
|
||||||
label:"Discard Reroll"
|
|
||||||
}],
|
|
||||||
submit: result =>{
|
|
||||||
if (result==="cancel") return;
|
|
||||||
else dicetype = result;
|
|
||||||
},
|
|
||||||
}).render({ force: true });
|
|
||||||
console.log('User picked:',dicetype);
|
|
||||||
switch(dicetype){
|
switch(dicetype){
|
||||||
case "fear":
|
case "hope": {
|
||||||
console.log('Rerolling fear for user.');
|
diceIndex=0; //Hope Die
|
||||||
fear=new Roll("1d12");
|
break;
|
||||||
await fear.evaluate();
|
};
|
||||||
console.log('Dice rerolled to',fear.result);
|
case "fear" :{
|
||||||
case "hope":
|
diceIndex=2 //Fear Die
|
||||||
console.log('Rerolling hope for user.');
|
break;
|
||||||
hope=new Roll("1d12");
|
};
|
||||||
await hope.evaluate();
|
default:
|
||||||
console.log('Dice rerolled to',hope.result);
|
ui.notifications.warn("Invalid Dice type selected.");
|
||||||
case "both":
|
break;
|
||||||
console.log('Rerolling both fear and hope for user.');
|
|
||||||
await hope.evaluate();
|
|
||||||
await fear.evaluate();
|
|
||||||
console.log('Dice rerolled to',hope.result,' in hope and ',fear.result,' in fear');
|
|
||||||
}
|
}
|
||||||
|
let rollClone=originalRoll;
|
||||||
/* const confirm = await foundry.applications.api.DialogV2.confirm({
|
let rerolledTerm=rollClone.terms[diceIndex];
|
||||||
|
if (!(rerolledTerm instanceof DieTerm)) {
|
||||||
|
ui.notifications.error("Selected term is not a die.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
await rerolledTerm.reroll();
|
||||||
|
await rollClone.evaluate();
|
||||||
|
const confirm = await foundry.applications.api.DialogV2.confirm({
|
||||||
window: { title: 'Confirm Reroll' },
|
window: { title: 'Confirm Reroll' },
|
||||||
content: `<p>You have rerolled your ${dicetype} to ${r.result}</p><p>Apply 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>`
|
||||||
});
|
});
|
||||||
if (!confirm) return;
|
if (!confirm) return;
|
||||||
else{
|
rollClone.toMessage({flavor: 'Selective reroll applied for ${dicetype}.'});
|
||||||
originalobject[0].;
|
console.log("Updated Roll",rollClone);
|
||||||
} */
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,12 @@
|
||||||
<div class="dice-container">
|
<div class="dice-container">
|
||||||
<div class="dice-title">{{localize "DAGGERHEART.GENERAL.hope"}}</div>
|
<div class="dice-title">{{localize "DAGGERHEART.GENERAL.hope"}}</div>
|
||||||
<div class="dice-inner-container hope" title="{{localize "DAGGERHEART.GENERAL.hope"}}">
|
<div class="dice-inner-container hope" title="{{localize "DAGGERHEART.GENERAL.hope"}}">
|
||||||
|
<button type="checkbox" class="reroll-button" id="reroll-dice" value="hope">
|
||||||
<div class="dice-wrapper">
|
<div class="dice-wrapper">
|
||||||
<img class="dice" src="../icons/svg/d12-grey.svg"/>
|
<img class="dice" src="../icons/svg/d12-grey.svg"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="dice-value">{{roll.hope.value}}</div>
|
<div class="dice-value">{{roll.hope.value}}</div>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
@ -152,6 +154,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="reroll-div">
|
<!-- <div class="reroll-div">
|
||||||
<button class="reroll-button"><i class="fas fa-dice"></i><span>Reroll</span></button>
|
<button class="reroll-button"><i class="fas fa-dice"></i><span>Reroll</span></button>
|
||||||
</div>
|
</div> -->
|
||||||
Loading…
Add table
Add a link
Reference in a new issue