v0.5 fixes

This commit is contained in:
2022-07-19 00:18:46 +02:00
parent bf52b61a0d
commit 2ab1cbe24c
12 changed files with 255 additions and 52 deletions

View File

@ -48,7 +48,7 @@ export class PegasusRollDialog extends Dialog {
if (effect) {
effect.applied = toggled
let level, genre, idVal
let level, genre, idVal, key
if (effect.type == 'hindrance') {
level = effect.value
genre = 'positive'
@ -61,30 +61,36 @@ export class PegasusRollDialog extends Dialog {
effectData.data.isUsed = toggled
if (effectData.data.reducedicevalue || effectData.data.statdice) {
idVal = "#statDicesLevel"
key = "statLevelBonus"
}
if (effectData.data.otherdice) {
idVal = "#damageDiceLevel"
key = "damageLevelBonus"
}
if (effectData.data.hindrance) {
idVal = "#hindranceDicesLevel"
genre = 'positive' // Dynamic fix
key = "hindranceLevelBonus"
}
}
// Now process the dice level update
if (idVal) {
let newLevel = Number($(idVal).val())
if (toggled) {
let newLevel = Number($(idVal).val())
console.log("Ongoing", newLevel, toggled, idVal)
if (genre == 'positive') {
if (genre == 'positive') {
newLevel += Number(level)
this.rollData[key] += Number(level)
} else {
newLevel -= Number(level)
this.rollData[key] -= Number(level)
}
} else {
if (genre == 'positive') {
newLevel -= Number(level)
this.rollData[key] -= Number(level)
} else {
newLevel += Number(level)
this.rollData[key] += Number(level)
}
}
newLevel = (newLevel < 0) ? 0 : newLevel
@ -210,7 +216,7 @@ export class PegasusRollDialog extends Dialog {
html.find('#statDicesLevel').change((event) => {
this.rollData.statDicesLevel = Number(event.currentTarget.value)
});
html.find('#specDicesLevel').change( async (event) => {
html.find('#specDicesLevel').change(async (event) => {
this.rollData.specDicesLevel = Number(event.currentTarget.value)
PegasusUtility.updateSpecDicePool(this.rollData)
this.refreshDialog()
@ -244,15 +250,16 @@ export class PegasusRollDialog extends Dialog {
html.find('.pool-add-dice').click(async (event) => {
let diceKey = $(event.currentTarget).data("dice-key")
PegasusUtility.addDicePool( this.rollData, diceKey)
let diceLevel = $(event.currentTarget).data("dice-level")
PegasusUtility.addDicePool(this.rollData, diceKey, diceLevel)
this.refreshDialog()
})
html.find('.pool-remove-dice').click(async (event) => {
let idx = $(event.currentTarget).data("dice-idx")
PegasusUtility.removeFromDicePool( this.rollData, idx)
PegasusUtility.removeFromDicePool(this.rollData, idx)
this.refreshDialog()
})
}
}