Update with minor fixes/updates
This commit is contained in:
@ -66,36 +66,75 @@ export class PegasusUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static updateEffectsBonusDice( rollData) {
|
||||
static updateEffectsBonusDice(rollData) {
|
||||
let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-bonus-dice")
|
||||
for (let effect of rollData.effectsList) {
|
||||
if (effect && effect.applied && effect.effect.data.bonusdice) {
|
||||
if (effect && effect.applied && effect.type == "effect" && effect.effect.data.bonusdice) {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(effect.effect.data.effectlevel)
|
||||
let newDice = {
|
||||
name: "effect-bonus-dice", key: diceKey, level: effect.effect.data.effectlevel, effect: effect.effect.name,
|
||||
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp`
|
||||
}
|
||||
newDicePool.push(newDice)
|
||||
newDicePool.push(newDice)
|
||||
}
|
||||
}
|
||||
rollData.dicePool = newDicePool
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static updateDamageDicePool(rollData) {
|
||||
if (rollData.isDamage) {
|
||||
let newDicePool = rollData.dicePool.filter(dice => dice.name != "damage")
|
||||
if (rollData.damageDiceLevel > 0) {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(rollData.damageDiceLevel)
|
||||
static updateHindranceBonusDice(rollData) {
|
||||
let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-hindrance")
|
||||
for (let hindrance of rollData.effectsList) {
|
||||
if (hindrance && hindrance.applied && hindrance.type == "hindrance") {
|
||||
console.log("Manage Hindrance", hindrance)
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(hindrance.value)
|
||||
let newDice = {
|
||||
name: "effect-hindrance", key: diceKey, level: hindrance.value, effect: hindrance.name,
|
||||
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp`
|
||||
}
|
||||
newDicePool.push(newDice)
|
||||
}
|
||||
}
|
||||
rollData.dicePool = newDicePool
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static updateArmorDicePool(rollData) {
|
||||
let newDicePool = rollData.dicePool.filter(dice => dice.name != "armor-shield" )
|
||||
for (let armor of rollData.armorsList) {
|
||||
if (armor.applied ) {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(armor.value)
|
||||
let diceList = diceKey.split(" ")
|
||||
for(let myDice of diceList) {
|
||||
for (let myDice of diceList) {
|
||||
let newDice = {
|
||||
name: "damage", key: myDice, level: rollData.damageDiceLevel,
|
||||
name: "armor-shield", key: myDice, level: armor.value,
|
||||
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
|
||||
}
|
||||
newDicePool.push(newDice)
|
||||
}
|
||||
}
|
||||
}
|
||||
rollData.dicePool = newDicePool
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static updateDamageDicePool(rollData) {
|
||||
if (rollData.isDamage) {
|
||||
let newDicePool = rollData.dicePool.filter(dice => dice.name != "damage")
|
||||
for (let weapon of rollData.weaponsList) {
|
||||
if (weapon.applied && weapon.type == "damage") {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(weapon.value)
|
||||
let diceList = diceKey.split(" ")
|
||||
for (let myDice of diceList) {
|
||||
let newDice = {
|
||||
name: "damage", key: myDice, level: weapon.value,
|
||||
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
|
||||
}
|
||||
newDicePool.push(newDice)
|
||||
}
|
||||
}
|
||||
}
|
||||
rollData.dicePool = newDicePool
|
||||
}
|
||||
}
|
||||
@ -106,7 +145,7 @@ export class PegasusUtility {
|
||||
if (rollData.specDicesLevel > 0) {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(rollData.specDicesLevel)
|
||||
let diceList = diceKey.split(" ")
|
||||
for(let myDice of diceList) {
|
||||
for (let myDice of diceList) {
|
||||
let newDice = {
|
||||
name: "spec", key: myDice, level: rollData.specDicesLevel,
|
||||
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
|
||||
@ -125,21 +164,21 @@ export class PegasusUtility {
|
||||
}
|
||||
rollData.dicePool.push(newDice)
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------- */
|
||||
static removeFromDicePool( rollData, diceIdx ) {
|
||||
static removeFromDicePool(rollData, diceIdx) {
|
||||
let toRemove = rollData.dicePool[diceIdx]
|
||||
if (toRemove && toRemove.name != "spec" && toRemove.name != "stat" && toRemove.name != "damage") {
|
||||
let newDicePool = []
|
||||
for (let i=0; i<rollData.dicePool.length; i++) {
|
||||
if ( i!=diceIdx) {
|
||||
newDicePool.push( rollData.dicePool[i])
|
||||
for (let i = 0; i < rollData.dicePool.length; i++) {
|
||||
if (i != diceIdx) {
|
||||
newDicePool.push(rollData.dicePool[i])
|
||||
}
|
||||
}
|
||||
rollData.dicePool = newDicePool
|
||||
if (toRemove.name == "effect-bonus-dice") {
|
||||
for (let effect of rollData.effectsList) {
|
||||
if ( effect.effect.name == toRemove.effect && effect.applied) {
|
||||
if (effect.effect.name == toRemove.effect && effect.applied) {
|
||||
effect.applied = false //Remove the effect
|
||||
}
|
||||
}
|
||||
@ -287,10 +326,10 @@ export class PegasusUtility {
|
||||
html.on("click", '.reroll-level-remaining', event => {
|
||||
let rollId = $(event.currentTarget).data("roll-id")
|
||||
let rollData = this.getRollData(rollId)
|
||||
rollData.reroll = true
|
||||
this.rollPegasus( rollData)
|
||||
rollData.reroll = true
|
||||
this.rollPegasus(rollData)
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -461,7 +500,7 @@ export class PegasusUtility {
|
||||
game.socket.emit("system.pegasus-rpg", {
|
||||
name: "msg_update_roll", data: rollData
|
||||
}); // Notify all other clients of the roll
|
||||
this.updateRollData(rollData)
|
||||
this.updateRollData(rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -568,9 +607,9 @@ export class PegasusUtility {
|
||||
// De-actived used effects from perks
|
||||
let toRem = []
|
||||
for (let effect of rollData.effectsList) {
|
||||
if (effect.effect.data.isUsed && effect.effect.data.oneuse) {
|
||||
if (effect.effect && effect.effect.data.isUsed && effect.effect.data.oneuse) {
|
||||
toRem.push(effect.effect._id)
|
||||
ChatMessage.create({content: `One used effect ${effect.effect.name} has been auto-deleted.`})
|
||||
ChatMessage.create({ content: `One used effect ${effect.effect.name} has been auto-deleted.` })
|
||||
}
|
||||
}
|
||||
if (toRem.length > 0) {
|
||||
@ -594,25 +633,25 @@ export class PegasusUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async showMomentumDialog( actorId) {
|
||||
static async showMomentumDialog(actorId) {
|
||||
let d = new Dialog({
|
||||
title: "Momentum reroll",
|
||||
content: "<p>Do you want to re-roll your last roll ?</p>",
|
||||
buttons: {
|
||||
one: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Cancel",
|
||||
callback: () => this.close()
|
||||
},
|
||||
two: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: "Reroll",
|
||||
callback: () => PegasusUtility.momentumReroll(actorId)
|
||||
}
|
||||
one: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Cancel",
|
||||
callback: () => this.close()
|
||||
},
|
||||
two: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: "Reroll",
|
||||
callback: () => PegasusUtility.momentumReroll(actorId)
|
||||
}
|
||||
},
|
||||
default: "Reroll",
|
||||
})
|
||||
d.render(true)
|
||||
})
|
||||
d.render(true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -663,10 +702,10 @@ export class PegasusUtility {
|
||||
let diceFormulaTab = []
|
||||
for (let dice of rollData.dicePool) {
|
||||
let level = dice.level
|
||||
if (dice.name == "stat" ) {
|
||||
if (dice.name == "stat") {
|
||||
level += rollData.statLevelBonus
|
||||
}
|
||||
diceFormulaTab.push( this.getFoundryDiceFromLevel(level) )
|
||||
diceFormulaTab.push(this.getFoundryDiceFromLevel(level))
|
||||
}
|
||||
let diceFormula = '{' + diceFormulaTab.join(', ') + '}kh + ' + (rollData.stat?.mod || 0)
|
||||
|
||||
@ -702,7 +741,7 @@ export class PegasusUtility {
|
||||
|
||||
// Stun specific -> Suffere a stun level when dmg-res
|
||||
if (rollData.subKey && rollData.subKey == "dmg-res") {
|
||||
actor.modifyStun(-1)
|
||||
actor.modifyStun(+1)
|
||||
}
|
||||
|
||||
//this.removeUsedPerkEffects( rollData) // Unused for now
|
||||
|
Reference in New Issue
Block a user