Better roll with advantage
This commit is contained in:
@@ -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
|
||||
})*/
|
||||
|
||||
}
|
||||
}
|
@@ -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)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user