Sync effetcts + initiative
This commit is contained in:
@@ -60,7 +60,7 @@ export class PegasusRollDialog extends Dialog {
|
||||
if (effectData.data.bonusdice) {
|
||||
idVal = "#bonusDicesLevel"
|
||||
}
|
||||
if (effectData.data.reducedicevalue) {
|
||||
if (effectData.data.reducedicevalue || effectData.data.statdice) {
|
||||
idVal = "#statDicesLevel"
|
||||
}
|
||||
if (effectData.data.otherdice) {
|
||||
@@ -116,6 +116,56 @@ export class PegasusRollDialog extends Dialog {
|
||||
console.log("Armor", armorIdx, toggled)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
manageWeapons( weaponIdx, toggled) {
|
||||
let weapon = this.rollData.weaponsList[weaponIdx]
|
||||
if (weapon) {
|
||||
weapon.applied = toggled
|
||||
if (weapon.type == 'damage' ) {
|
||||
if (toggled) {
|
||||
this.rollData.otherDicesLevel += Number(weapon.value)
|
||||
} else {
|
||||
this.rollData.otherDicesLevel -= Number(weapon.value)
|
||||
this.rollData.otherDicesLevel = (this.rollData.otherDicesLevel<0) ? 0 : this.rollData.otherDicesLevel
|
||||
}
|
||||
$("#otherDicesLevel").val(this.rollData.otherDicesLevel)
|
||||
}
|
||||
}
|
||||
console.log("Weapon", weaponIdx, toggled, this.rollData.otherDicesLevel, weapon)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
manageEquip( equipIdx, toggled) {
|
||||
let equip = this.rollData.equipmentsList[equipIdx]
|
||||
if (equip) {
|
||||
equip.applied = toggled
|
||||
let idVal = "#otherDicesLevel" // Default
|
||||
if (equip.equip.data.bonusdice) {
|
||||
idVal = "#bonusDicesLevel"
|
||||
}
|
||||
if (equip.equip.data.statdice) {
|
||||
idVal = "#statDicesLevel"
|
||||
}
|
||||
if (equip.equip.data.otherdice) {
|
||||
idVal = "#otherDicesLevel"
|
||||
}
|
||||
let newLevel = Number($(idVal).val())
|
||||
if (toggled) {
|
||||
newLevel += Number(equip.value)
|
||||
} else {
|
||||
newLevel -= Number(equip.value)
|
||||
}
|
||||
newLevel = (newLevel <0) ? 0 : newLevel
|
||||
$(idVal).val(newLevel)
|
||||
// Then refresh
|
||||
this.rollData.statDicesLevel = $('#statDicesLevel').val()
|
||||
this.rollData.specDicesLevel = $('#specDicesLevel').val()
|
||||
this.rollData.bonusDicesLevel = $('#bonusDicesLevel').val()
|
||||
this.rollData.hindranceDicesLevel = $('#hindranceDicesLevel').val()
|
||||
this.rollData.otherDicesLevel = $('#otherDicesLevel').val()
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
@@ -160,6 +210,16 @@ export class PegasusRollDialog extends Dialog {
|
||||
let armorIdx = $(event.currentTarget).data("armor-idx")
|
||||
this.manageArmors( armorIdx, toggled)
|
||||
});
|
||||
html.find('.weapon-clicked').change((event) => {
|
||||
let toggled = event.currentTarget.checked
|
||||
let weaponIdx = $(event.currentTarget).data("weapon-idx")
|
||||
this.manageWeapons( weaponIdx, toggled)
|
||||
});
|
||||
html.find('.equip-clicked').change((event) => {
|
||||
let toggled = event.currentTarget.checked
|
||||
let equipIdx = $(event.currentTarget).data("equip-idx")
|
||||
this.manageEquip( equipIdx, toggled)
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user