Various fixes

This commit is contained in:
sladecraven 2022-02-16 14:13:16 +01:00
parent 8dd7217e69
commit 7da8f7d9f1
2 changed files with 53 additions and 51 deletions

View File

@ -478,6 +478,7 @@ export class PegasusActor extends Actor {
}
}
if (effects.length > 0) {
console.log("DELET!!!!", effects, this)
await this.deleteEmbeddedDocuments('Item', effects)
}
}
@ -487,22 +488,16 @@ export class PegasusActor extends Actor {
let item = this.items.get(itemId)
if (item && index) {
let key = "data.used" + index
await this.updateEmbeddedDocuments('Item', [{ _id: itemId, [`${key}`]: checked }] )
await this.updateEmbeddedDocuments('Item', [{ _id: itemId, [`${key}`]: checked }])
item = this.items.get(itemId) // Refresh
if (item.data.data.nbuse == "next1action" && item.data.data.used1) {
this.cleanPerkEffects(itemId)
await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
{ _id: itemId, 'data.used2': false}, { _id: itemId,'data.used3': false } ] ) // Reset on Ready
}
if (item.data.data.nbuse == "next2action" && item.data.data.used1 && item.data.data.used2) {
this.cleanPerkEffects(itemId)
await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
{ _id: itemId, 'data.used2': false}, { _id: itemId,'data.used3': false } ] ) // Reset on Ready
}
if (item.data.data.nbuse == "next3action" && item.data.data.used1 && item.data.data.used2 && item.data.data.used3) {
this.cleanPerkEffects(itemId)
await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
{ _id: itemId, 'data.used2': false}, { _id: itemId,'data.used3': false } ] ) // Reset on Ready
}
}
}
@ -525,10 +520,8 @@ export class PegasusActor extends Actor {
let updateOK = true
if (status == "ready") {
console.log("Cleaning effects")
this.cleanPerkEffects(itemId)
await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
{ _id: itemId, 'data.used2': false}, { _id: itemId,'data.used3': false } ] ) // Reset on Ready
await this.cleanPerkEffects(itemId)
await this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.used1': false, 'data.used2': false, 'data.used3': false }])
if (item.data.data.features.nrgcost.flag) {
let nrg = duplicate(this.data.data.nrg)
nrg.activated -= item.data.data.features.nrgcost.value
@ -539,19 +532,19 @@ export class PegasusActor extends Actor {
let health = duplicate(this.data.data.secondary.health)
health.value -= Number(item.data.data.features.bonushealth.value) || 0
health.max -= Number(item.data.data.features.bonushealth.value) || 0
this.update({ 'data.secondary.health': health })
await this.update({ 'data.secondary.health': health })
}
if (item.data.data.features.bonusdelirium.flag) {
let delirium = duplicate(this.data.data.secondary.delirium)
delirium.value -= Number(item.data.data.features.bonusdelirium.value) || 0
delirium.max -= Number(item.data.data.features.bonusdelirium.value) || 0
this.update({ 'data.secondary.delirium': delirium })
await this.update({ 'data.secondary.delirium': delirium })
}
if (item.data.data.features.bonusnrg.flag) {
let nrg = duplicate(this.data.data.nrg)
nrg.value -= Number(item.data.data.features.bonusnrg.value) || 0
nrg.max -= Number(item.data.data.features.bonusnrg.value) || 0
this.update({ 'data.nrg': nrg })
await this.update({ 'data.nrg': nrg })
}
this.disableWeaverPerk(item)
}
@ -568,12 +561,12 @@ export class PegasusActor extends Actor {
}
// Manage additional flags
if (item.data.data.features.nrgcost.flag) {
if ( (this.data.data.nrg.value >= item.data.data.features.nrgcost.value) && (this.data.data.nrg.max >= item.data.data.features.nrgcost.value)) {
if ((this.data.data.nrg.value >= item.data.data.features.nrgcost.value) && (this.data.data.nrg.max >= item.data.data.features.nrgcost.value)) {
let nrg = duplicate(this.data.data.nrg)
nrg.activated += item.data.data.features.nrgcost.value
nrg.value -= item.data.data.features.nrgcost.value
nrg.max -= item.data.data.features.nrgcost.value
this.update({ 'data.nrg': nrg })
await this.update({ 'data.nrg': nrg })
} else {
updateOK = false
ui.notifications.warn("Not enough NRG to activate the Perk " + item.name)
@ -583,24 +576,24 @@ export class PegasusActor extends Actor {
let health = duplicate(this.data.data.secondary.health)
health.value += Number(item.data.data.features.bonushealth.value) || 0
health.max += Number(item.data.data.features.bonushealth.value) || 0
this.update({ 'data.secondary.health': health })
await this.update({ 'data.secondary.health': health })
}
if (item.data.data.features.bonusdelirium.flag) {
let delirium = duplicate(this.data.data.secondary.delirium)
delirium.value += Number(item.data.data.features.bonusdelirium.value) || 0
delirium.max += Number(item.data.data.features.bonusdelirium.value) || 0
this.update({ 'data.secondary.delirium': delirium })
await this.update({ 'data.secondary.delirium': delirium })
}
if (item.data.data.features.bonusnrg.flag) {
let nrg = duplicate(this.data.data.nrg)
nrg.value += Number(item.data.data.features.bonusnrg.value) || 0
nrg.max += Number(item.data.data.features.bonusnrg.value) || 0
this.update({ 'data.nrg': nrg })
await this.update({ 'data.nrg': nrg })
}
this.enableWeaverPerk(item)
}
if (updateOK) {
this.updateEmbeddedDocuments('Item', [{ _id: item.id, 'data.status': status }])
await this.updateEmbeddedDocuments('Item', [{ _id: item.id, 'data.status': status }])
}
}
}
@ -620,48 +613,49 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
async computeNRGHealth( ) {
if (this.isToken) return
async computeNRGHealth() {
//if (this.isToken) return
if (this.isOwner || game.user.isGM) {
let updates = {}
let phyDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value) + this.data.data.secondary.health.bonus + this.data.data.statistics.phy.mod;
if (phyDiceValue != this.data.data.secondary.health.max) {
updates['data.secondary.health.max'] = phyDiceValue
if (this.computeValue) {
updates['data.secondary.health.value'] = phyDiceValue
}
}
if (this.computeValue) {
updates['data.secondary.health.value'] = phyDiceValue
}
let mndDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.mnd.value) + this.data.data.secondary.delirium.bonus + this.data.data.statistics.mnd.mod;
if (mndDiceValue != this.data.data.secondary.delirium.max) {
updates['data.secondary.delirium.max'] = mndDiceValue
if (this.computeValue) {
updates['data.secondary.delirium.value'] = mndDiceValue
}
}
if (this.computeValue) {
updates['data.secondary.delirium.value'] = mndDiceValue
}
let stlDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.stl.value) + this.data.data.secondary.stealthhealth.bonus + this.data.data.statistics.stl.mod;
if (stlDiceValue != this.data.data.secondary.stealthhealth.max) {
updates['data.secondary.stealthhealth.max'] = stlDiceValue
if (this.computeValue) {
updates['data.secondary.stealthhealth.value'] = stlDiceValue
}
}
if (this.computeValue) {
updates['data.secondary.stealthhealth.value'] = stlDiceValue
}
let socDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.soc.value) + this.data.data.secondary.socialhealth.bonus + this.data.data.statistics.soc.mod;
if (socDiceValue != this.data.data.secondary.socialhealth.max) {
updates['data.secondary.socialhealth.max'] = socDiceValue
if (this.computeValue) {
updates['data.secondary.socialhealth.value'] = socDiceValue
}
}
if (this.computeValue) {
updates['data.secondary.socialhealth.value'] = socDiceValue
}
let nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.nrg.mod + this.data.data.statistics.foc.mod;
if (nrgValue != this.data.data.nrg.absolutemax) {
updates['data.nrg.absolutemax'] = nrgValue
if (this.computeValue) {
updates['data.nrg.max'] = nrgValue
updates['data.nrg.value'] = nrgValue
}
}
if (this.computeValue) {
updates['data.nrg.max'] = nrgValue
updates['data.nrg.value'] = nrgValue
}
nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.statistics.foc.mod;
if (nrgValue != this.data.data.combat.stunthreshold) {
updates['data.combat.stunthreshold'] = nrgValue
@ -691,15 +685,17 @@ export class PegasusActor extends Actor {
await this.update(updates)
}
// Update current hindrance level
let hindrance = this.data.data.combat.hindrancedice
if (this.data.data.secondary.health.value < 0) {
hindrance += Math.abs(this.data.data.secondary.health.value)
if (this.isOwner || game.user.isGM) {
// Update current hindrance level
let hindrance = this.data.data.combat.hindrancedice
if (this.data.data.secondary.health.value < 0) {
hindrance += Math.abs(this.data.data.secondary.health.value)
}
if (this.data.data.secondary.delirium.value < 0) {
hindrance += Math.abs(this.data.data.secondary.delirium.value)
}
this.data.data.combat.hindrancedice = hindrance
}
if (this.data.data.secondary.delirium.value < 0) {
hindrance += Math.abs(this.data.data.secondary.delirium.value)
}
this.data.data.combat.hindrancedice = hindrance
}
/* -------------------------------------------- */
@ -876,12 +872,17 @@ export class PegasusActor extends Actor {
for (let effect of effects) {
effect = duplicate(effect)
if (!effect.data.hindrance
&& effect.data.stataffected != "notapplicable"
&& (effect.data.stataffected != "notapplicable" || effect.data.specaffected.length > 0)
&& effect.data.stataffected != "special") {
if ( effect.data.effectstatlevel && effect.data.effectstat == rollData.statKey) {
if (effect.data.effectstatlevel) {
if ( effect.data.effectstat == rollData.statKey ) {
effect.data.effectlevel = rollData.statDicesLevel
}
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel })
if ( effect.data.stataffected == "all") { // Real nightmare
effect.data.effectlevel = this.data.data.statistics[effect.data.effectstat].value
}
}
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel })
}
}
}
@ -953,7 +954,7 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
async startRoll(rollData) {
this.syncRoll(rollData);
console.log("ROLL DATA", rollData)
//console.log("ROLL DATA", rollData)
let rollDialog = await PegasusRollDialog.create(this, rollData);
console.log(rollDialog);
rollDialog.render(true);
@ -966,6 +967,7 @@ export class PegasusActor extends Actor {
if (stat) {
let rollData = this.getCommonRollData(statKey, useShield)
rollData.mode = "stat"
rollData.title = `Roll : ${stat.label} `
this.startRoll(rollData)
} else {

View File

@ -183,6 +183,6 @@
"templateVersion": 78,
"title": "Pegasus RPG",
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
"version": "0.4.13",
"version": "0.4.14",
"background" : "./images/ui/pegasus_welcome_page.webp"
}