Better roll with advantage

This commit is contained in:
sladecraven 2022-08-10 14:41:40 +02:00
parent 99c0b26f78
commit ab755aac22
4 changed files with 62 additions and 20 deletions

View File

@ -67,12 +67,9 @@ export class CrucibleRollDialog extends Dialog {
html.find('#rollAdvantage').change((event) => {
this.rollData.rollAdvantage = event.currentTarget.value
})
/*html.find('#featDieName').change((event) => {
this.rollData.featDieName = event.currentTarget.value
html.find('#useshield').change((event) => {
this.rollData.useShield = event.currentTarget.checked
})
html.find('#featDieSL').change((event) => {
this.rollData.featDieSL = event.currentTarget.value
})*/
}
}

View File

@ -244,6 +244,19 @@ export class CrucibleUtility {
}
}
/* -------------------------------------------- */
getSuccessResult(sum){
ui.notifications.warn("Not implemented up to now !")
}
/* -------------------------------------------- */
static async processAttackDefense( rollData) {
if ( rollData.attackRollData) {
let sumSuccess = rollData.attackRollData.nbSuccess - rollData.nbSuccess
this.getSuccessResult(sumSuccess)
}
}
/* -------------------------------------------- */
static async onSocketMesssage(msg) {
console.log("SOCKET MESSAGE", msg.name)
@ -328,9 +341,6 @@ export class CrucibleUtility {
if (rollData.save) {
startFormula = String(rollData.save.value) + "d6cs>=5"
}
if (rollData.shield) {
startFormula = "1" + String(rollData.shield.data.shielddie) + "cs>=5"
}
diceFormula = startFormula
// skill => 2
@ -401,6 +411,13 @@ export class CrucibleUtility {
diceFormula += `- 0d8cs>=5`
}
// shield => 14
if (rollData.useShield && rollData.shield) {
diceFormula += "+ 1" + String(rollData.shield.data.shielddie) + "cs>=5"
} else {
diceFormula += " + 0d6cs>=5"
}
// Performs roll
console.log("Roll formula", diceFormula)
let myRoll = rollData.roll
@ -408,13 +425,27 @@ export class CrucibleUtility {
myRoll = new Roll(diceFormula).roll({ async: false })
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
}
rollData.rollOrder = 0
rollData.roll = myRoll
rollData.nbSuccess = myRoll.total
if (rollData.rollAdvantage != "none") {
rollData.rollOrder = 1
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-crucible-rpg/templates/chat-generic-result.html`, rollData)
})
rollData.rollOrder = 2
let myRoll2 = new Roll(diceFormula).roll({ async: false })
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
await this.showDiceSoNice(myRoll2, game.settings.get("core", "rollMode"))
rollData.roll = myRoll2 // Tmp switch to display the proper results
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-crucible-rpg/templates/chat-generic-result.html`, rollData)
})
rollData.roll = myRoll // Revert the tmp switch
if (rollData.rollAdvantage == "roll-advantage") {
if (myRoll2.total > rollData.nbSuccess) {
hasChanged = true
rollData.roll = myRoll2
rollData.nbSuccess = myRoll2.total
}
@ -424,7 +455,10 @@ export class CrucibleUtility {
rollData.nbSuccess = myRoll2.total
}
}
rollData.rollOrder = 3
}
rollData.isFirstRollAdvantage = false
// Manage exp
if (rollData.skill && rollData.skill.data.level > 0) {
let nbSkillSuccess = rollData.roll.terms[2].total
@ -444,7 +478,8 @@ export class CrucibleUtility {
// Message response
this.displayDefenseMessage(rollData)
// And save the roll
// Manage defense result
this.processAttackDefense(rollData)
}
/* -------------------------------------------- */

View File

@ -221,8 +221,8 @@
"templateVersion": 14,
"title": "Crucible RPG",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/raw/master/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v0.1.25.zip",
"download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v0.1.26.zip",
"url": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg",
"version": "0.1.25",
"version": "0.1.26",
"background" : "./images/ui/crucible_welcome_page.webp"
}

View File

@ -18,16 +18,18 @@
<div>
<ul>
{{#if save}}
<li>Save : {{save.label}} - {{save.value}}d6
({{#each roll.terms.0.results as |die idx|}}
{{die.result}}&nbsp;
{{/each}})
</li>
{{#if (eq rollOrder 1)}}
<li><strong>Roll with advantage - Roll 1</strong></li>
{{/if}}
{{#if (eq rollOrder 2)}}
<li><strong>Roll with advantage - Roll 2</strong></li>
{{/if}}
{{#if (eq rollOrder 3)}}
<li><strong>Roll with advantage - Final result !</strong></li>
{{/if}}
{{#if shield}}
<li>Shield : {{shield.name}} - {{shield.data.shieldie}}
{{#if save}}
<li>Save : {{save.label}} - {{save.value}}d6
({{#each roll.terms.0.results as |die idx|}}
{{die.result}}&nbsp;
{{/each}})
@ -116,6 +118,14 @@
</li>
{{/if}}
{{#if useShield}}
<li>Shield : {{shield.name}} - {{shield.data.shielddie}}
({{#each roll.terms.14.results as |die idx|}}
{{die.result}}&nbsp;
{{/each}})
</li>
{{/if}}
<li><strong>Number of successes</strong> {{nbSuccess}} </li>
<!-- <button class="chat-card-button reroll-level-remaining" data-roll-id="{{rollId}}">Reroll</button> -->