Better roll with advantage
This commit is contained in:
parent
99c0b26f78
commit
ab755aac22
@ -67,12 +67,9 @@ export class CrucibleRollDialog extends Dialog {
|
|||||||
html.find('#rollAdvantage').change((event) => {
|
html.find('#rollAdvantage').change((event) => {
|
||||||
this.rollData.rollAdvantage = event.currentTarget.value
|
this.rollData.rollAdvantage = event.currentTarget.value
|
||||||
})
|
})
|
||||||
/*html.find('#featDieName').change((event) => {
|
html.find('#useshield').change((event) => {
|
||||||
this.rollData.featDieName = event.currentTarget.value
|
this.rollData.useShield = event.currentTarget.checked
|
||||||
})
|
})
|
||||||
html.find('#featDieSL').change((event) => {
|
|
||||||
this.rollData.featDieSL = event.currentTarget.value
|
|
||||||
})*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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) {
|
static async onSocketMesssage(msg) {
|
||||||
console.log("SOCKET MESSAGE", msg.name)
|
console.log("SOCKET MESSAGE", msg.name)
|
||||||
@ -328,9 +341,6 @@ export class CrucibleUtility {
|
|||||||
if (rollData.save) {
|
if (rollData.save) {
|
||||||
startFormula = String(rollData.save.value) + "d6cs>=5"
|
startFormula = String(rollData.save.value) + "d6cs>=5"
|
||||||
}
|
}
|
||||||
if (rollData.shield) {
|
|
||||||
startFormula = "1" + String(rollData.shield.data.shielddie) + "cs>=5"
|
|
||||||
}
|
|
||||||
diceFormula = startFormula
|
diceFormula = startFormula
|
||||||
|
|
||||||
// skill => 2
|
// skill => 2
|
||||||
@ -401,6 +411,13 @@ export class CrucibleUtility {
|
|||||||
diceFormula += `- 0d8cs>=5`
|
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
|
// Performs roll
|
||||||
console.log("Roll formula", diceFormula)
|
console.log("Roll formula", diceFormula)
|
||||||
let myRoll = rollData.roll
|
let myRoll = rollData.roll
|
||||||
@ -408,13 +425,27 @@ export class CrucibleUtility {
|
|||||||
myRoll = new Roll(diceFormula).roll({ async: false })
|
myRoll = new Roll(diceFormula).roll({ async: false })
|
||||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||||
}
|
}
|
||||||
|
rollData.rollOrder = 0
|
||||||
rollData.roll = myRoll
|
rollData.roll = myRoll
|
||||||
rollData.nbSuccess = myRoll.total
|
rollData.nbSuccess = myRoll.total
|
||||||
if (rollData.rollAdvantage != "none") {
|
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 })
|
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 (rollData.rollAdvantage == "roll-advantage") {
|
||||||
if (myRoll2.total > rollData.nbSuccess) {
|
if (myRoll2.total > rollData.nbSuccess) {
|
||||||
|
hasChanged = true
|
||||||
rollData.roll = myRoll2
|
rollData.roll = myRoll2
|
||||||
rollData.nbSuccess = myRoll2.total
|
rollData.nbSuccess = myRoll2.total
|
||||||
}
|
}
|
||||||
@ -424,7 +455,10 @@ export class CrucibleUtility {
|
|||||||
rollData.nbSuccess = myRoll2.total
|
rollData.nbSuccess = myRoll2.total
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rollData.rollOrder = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rollData.isFirstRollAdvantage = false
|
||||||
// Manage exp
|
// Manage exp
|
||||||
if (rollData.skill && rollData.skill.data.level > 0) {
|
if (rollData.skill && rollData.skill.data.level > 0) {
|
||||||
let nbSkillSuccess = rollData.roll.terms[2].total
|
let nbSkillSuccess = rollData.roll.terms[2].total
|
||||||
@ -444,7 +478,8 @@ export class CrucibleUtility {
|
|||||||
// Message response
|
// Message response
|
||||||
this.displayDefenseMessage(rollData)
|
this.displayDefenseMessage(rollData)
|
||||||
|
|
||||||
// And save the roll
|
// Manage defense result
|
||||||
|
this.processAttackDefense(rollData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -221,8 +221,8 @@
|
|||||||
"templateVersion": 14,
|
"templateVersion": 14,
|
||||||
"title": "Crucible RPG",
|
"title": "Crucible RPG",
|
||||||
"manifest": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/raw/master/system.json",
|
"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",
|
"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"
|
"background" : "./images/ui/crucible_welcome_page.webp"
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,18 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<ul>
|
<ul>
|
||||||
{{#if save}}
|
{{#if (eq rollOrder 1)}}
|
||||||
<li>Save : {{save.label}} - {{save.value}}d6
|
<li><strong>Roll with advantage - Roll 1</strong></li>
|
||||||
({{#each roll.terms.0.results as |die idx|}}
|
{{/if}}
|
||||||
{{die.result}}
|
{{#if (eq rollOrder 2)}}
|
||||||
{{/each}})
|
<li><strong>Roll with advantage - Roll 2</strong></li>
|
||||||
</li>
|
{{/if}}
|
||||||
|
{{#if (eq rollOrder 3)}}
|
||||||
|
<li><strong>Roll with advantage - Final result !</strong></li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if shield}}
|
{{#if save}}
|
||||||
<li>Shield : {{shield.name}} - {{shield.data.shieldie}}
|
<li>Save : {{save.label}} - {{save.value}}d6
|
||||||
({{#each roll.terms.0.results as |die idx|}}
|
({{#each roll.terms.0.results as |die idx|}}
|
||||||
{{die.result}}
|
{{die.result}}
|
||||||
{{/each}})
|
{{/each}})
|
||||||
@ -116,6 +118,14 @@
|
|||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if useShield}}
|
||||||
|
<li>Shield : {{shield.name}} - {{shield.data.shielddie}}
|
||||||
|
({{#each roll.terms.14.results as |die idx|}}
|
||||||
|
{{die.result}}
|
||||||
|
{{/each}})
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<li><strong>Number of successes</strong> {{nbSuccess}} </li>
|
<li><strong>Number of successes</strong> {{nbSuccess}} </li>
|
||||||
|
|
||||||
<!-- <button class="chat-card-button reroll-level-remaining" data-roll-id="{{rollId}}">Reroll</button> -->
|
<!-- <button class="chat-card-button reroll-level-remaining" data-roll-id="{{rollId}}">Reroll</button> -->
|
||||||
|
Loading…
Reference in New Issue
Block a user