Managedeletion

This commit is contained in:
2022-07-28 18:45:04 +02:00
parent fb3bde9bc7
commit a4abedd4b3
5 changed files with 51 additions and 30 deletions

View File

@ -43,8 +43,6 @@ export class PegasusActor extends Actor {
}
if (data.type == 'character') {
const skills = await PegasusUtility.loadCompendium("fvtt-weapons-of-the-gods.skills");
data.items = skills.map(i => i.toObject());
}
if (data.type == 'npc') {
}
@ -809,19 +807,19 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
async cleanupPerksIfTrauma() {
if ( this.getTraumaState() == "severetrauma") {
if (this.getTraumaState() == "severetrauma") {
for (let perk of this.data.items) {
if (perk.type == "perk") {
this.cleanPerkEffects(perk.id)
this.updateEmbeddedDocuments('Item', [{ _id: perk.id, 'data.status': "ready", 'data.used1': false, 'data.used2': false, 'data.used3': false }])
ChatMessage.create({ content: `Perk ${perk.name} has been deactivated due to Severe Trauma state !` } )
ChatMessage.create({ content: `Perk ${perk.name} has been deactivated due to Severe Trauma state !` })
}
}
}
}
/* -------------------------------------------- */
incDecNRG( value) {
incDecNRG(value) {
let nrg = duplicate(this.data.data.nrg)
nrg.value += value
if (nrg.value >= 0 && nrg.value <= nrg.max) {
@ -1010,7 +1008,7 @@ export class PegasusActor extends Actor {
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
@ -1037,14 +1035,14 @@ export class PegasusActor extends Actor {
updates['data.mr.value'] = mrLevel
}
let moralitythreshold = - (Number(PegasusUtility.getDiceValue(this.data.data.statistics.foc.value)) + Number(this.data.data.statistics.foc.mod) )
let moralitythreshold = - (Number(PegasusUtility.getDiceValue(this.data.data.statistics.foc.value)) + Number(this.data.data.statistics.foc.mod))
if (moralitythreshold != this.data.data.biodata.moralitythreshold) {
updates['data.biodata.moralitythreshold'] = moralitythreshold
}
if (!this.warnMorality && this.data.data.biodata.morality <= moralitythreshold-2) {
ChatMessage.create( {content: "WARNING: Your character is dangerously close to becoming corrupted and defeated. Start on a path of redemption!"} )
this.warnMorality = true
if (!this.warnMorality && this.data.data.biodata.morality < 0) {
ChatMessage.create({ content: "WARNING: Your character is dangerously close to becoming corrupted and defeated. Start on a path of redemption!" })
this.warnMorality = true
}
let race = this.getRace()
@ -1055,16 +1053,18 @@ export class PegasusActor extends Actor {
if (role && role.name && (role.name != this.data.data.biodata.rolename)) {
updates['data.biodata.rolename'] = role.name
}
//console.log("UPD", updates, this.data.data.biodata)
await this.update(updates)
this.computeThreatLevel()
if (Object.entries(updates).length > 0) {
await this.update(updates)
this.computeThreatLevel()
}
}
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) {
if (this.data.data.secondary.health.value < -Math.floor((this.data.data.secondary.health.max + 1) / 2) ) { // Severe wounded
if (this.data.data.secondary.health.value < -Math.floor((this.data.data.secondary.health.max + 1) / 2)) { // Severe wounded
hindrance += 3
} else {
hindrance += 1
@ -1243,7 +1243,7 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
addHindrancesList(effectsList) {
if (this.data.data.combat.stunlevel > 0) {
effectsList.push({ label: "Stun Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: this.data.data.combat.stunlevel })
effectsList.push({ label: "Stun Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: this.data.data.combat.stunlevel })
}
if (this.data.data.combat.hindrancedice > 0) {
effectsList.push({ label: "Wounds Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: this.data.data.combat.hindrancedice })
@ -1253,7 +1253,7 @@ export class PegasusActor extends Actor {
effectsList.push({ label: "Encumbrance Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: overCapacity })
}
if (this.data.data.biodata.morality <= 0) {
effectsList.push({ label: "Morality Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: 3 })
effectsList.push({ label: "Morality Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: 3 })
}
let effects = this.data.items.filter(item => item.type == 'effect')
for (let effect of effects) {
@ -1354,10 +1354,17 @@ export class PegasusActor extends Actor {
rollData.img = `systems/fvtt-pegasus-rpg/images/icons/${rollData.stat.abbrev}.webp`
}
let diceKey = PegasusUtility.getDiceFromLevel(rollData.stat.value)
rollData.dicePool.push({
name: "stat", key: diceKey, level: rollData.stat.value, mod: rollData.stat.mod,
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp`
})
let diceList = diceKey.split(" ")
let mod = rollData.stat.mod
for (let myDice of diceList) {
myDice = myDice.trim()
let newDice = {
name: "stat", key: myDice, level: PegasusUtility.getLevelFromDice(myDice), mod: mod,
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
}
rollData.dicePool.push(newDice)
mod = 0 // Only first dice has modifier
}
}
this.addEffects(rollData, isInit)