Managedeletion

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

View File

@ -383,6 +383,6 @@ export class PegasusActorSheet extends ActorSheet {
/** @override */ /** @override */
_updateObject(event, formData) { _updateObject(event, formData) {
// Update the Actor // Update the Actor
return this.object.update(formData); return this.object.update(formData)
} }
} }

View File

@ -43,8 +43,6 @@ export class PegasusActor extends Actor {
} }
if (data.type == 'character') { 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') { if (data.type == 'npc') {
} }
@ -809,19 +807,19 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async cleanupPerksIfTrauma() { async cleanupPerksIfTrauma() {
if ( this.getTraumaState() == "severetrauma") { if (this.getTraumaState() == "severetrauma") {
for (let perk of this.data.items) { for (let perk of this.data.items) {
if (perk.type == "perk") { if (perk.type == "perk") {
this.cleanPerkEffects(perk.id) this.cleanPerkEffects(perk.id)
this.updateEmbeddedDocuments('Item', [{ _id: perk.id, 'data.status': "ready", 'data.used1': false, 'data.used2': false, 'data.used3': false }]) 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) let nrg = duplicate(this.data.data.nrg)
nrg.value += value nrg.value += value
if (nrg.value >= 0 && nrg.value <= nrg.max) { if (nrg.value >= 0 && nrg.value <= nrg.max) {
@ -1038,13 +1036,13 @@ export class PegasusActor extends Actor {
} }
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) { if (moralitythreshold != this.data.data.biodata.moralitythreshold) {
updates['data.biodata.moralitythreshold'] = moralitythreshold updates['data.biodata.moralitythreshold'] = moralitythreshold
} }
if (!this.warnMorality && this.data.data.biodata.morality <= moralitythreshold-2) { 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!"} ) ChatMessage.create({ content: "WARNING: Your character is dangerously close to becoming corrupted and defeated. Start on a path of redemption!" })
this.warnMorality = true this.warnMorality = true
} }
let race = this.getRace() let race = this.getRace()
@ -1055,16 +1053,18 @@ export class PegasusActor extends Actor {
if (role && role.name && (role.name != this.data.data.biodata.rolename)) { if (role && role.name && (role.name != this.data.data.biodata.rolename)) {
updates['data.biodata.rolename'] = role.name updates['data.biodata.rolename'] = role.name
} }
//console.log("UPD", updates, this.data.data.biodata) if (Object.entries(updates).length > 0) {
await this.update(updates) await this.update(updates)
this.computeThreatLevel() this.computeThreatLevel()
}
} }
if (this.isOwner || game.user.isGM) { if (this.isOwner || game.user.isGM) {
// Update current hindrance level // Update current hindrance level
let hindrance = this.data.data.combat.hindrancedice let hindrance = this.data.data.combat.hindrancedice
if (this.data.data.secondary.health.value < 0) { 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 hindrance += 3
} else { } else {
hindrance += 1 hindrance += 1
@ -1243,7 +1243,7 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
addHindrancesList(effectsList) { addHindrancesList(effectsList) {
if (this.data.data.combat.stunlevel > 0) { 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) { 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 }) 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 }) effectsList.push({ label: "Encumbrance Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: overCapacity })
} }
if (this.data.data.biodata.morality <= 0) { 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') let effects = this.data.items.filter(item => item.type == 'effect')
for (let effect of effects) { 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` rollData.img = `systems/fvtt-pegasus-rpg/images/icons/${rollData.stat.abbrev}.webp`
} }
let diceKey = PegasusUtility.getDiceFromLevel(rollData.stat.value) let diceKey = PegasusUtility.getDiceFromLevel(rollData.stat.value)
rollData.dicePool.push({ let diceList = diceKey.split(" ")
name: "stat", key: diceKey, level: rollData.stat.value, mod: rollData.stat.mod, let mod = rollData.stat.mod
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp` 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) this.addEffects(rollData, isInit)

View File

@ -85,7 +85,7 @@ export class PegasusRollDialog extends Dialog {
} }
//console.log("Effect", effect, toggled) //console.log("Effect", effect, toggled)
this.rollData.statDicesLevel = Number($('#statDicesLevel').val()) this.rollData.statDicesLevel = Number($('#statDicesLevel').val())
PegasusUtility.updateStatDicePool(this.rollData) //PegasusUtility.updateStatDicePool(this.rollData)
PegasusUtility.updateSpecDicePool(this.rollData) PegasusUtility.updateSpecDicePool(this.rollData)
PegasusUtility.updateDamageDicePool(this.rollData) PegasusUtility.updateDamageDicePool(this.rollData)
PegasusUtility.updateEffectsBonusDice(this.rollData) PegasusUtility.updateEffectsBonusDice(this.rollData)
@ -174,6 +174,7 @@ export class PegasusRollDialog extends Dialog {
$('#specDicesLevel').val(this.rollData.specDicesLevel) $('#specDicesLevel').val(this.rollData.specDicesLevel)
} else { } else {
this.rollData.specName = undefined this.rollData.specName = undefined
this.rollData.specDicesLevel = 0
$('#specDicesLevel').val(0) $('#specDicesLevel').val(0)
} }
PegasusUtility.updateSpecDicePool(this.rollData) PegasusUtility.updateSpecDicePool(this.rollData)
@ -183,7 +184,11 @@ export class PegasusRollDialog extends Dialog {
this.rollData.statDicesLevel = Number(event.currentTarget.value) 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) if (event.currentTarget.value == "none") {
this.rollData.specDicesLevel = 0
} else {
this.rollData.specDicesLevel = Number(event.currentTarget.value)
}
PegasusUtility.updateSpecDicePool(this.rollData) PegasusUtility.updateSpecDicePool(this.rollData)
this.refreshDialog() this.refreshDialog()
}); });

View File

@ -4,8 +4,9 @@ import { PegasusCommands } from "./pegasus-commands.js";
import { PegasusActorCreate } from "./pegasus-create-char.js"; import { PegasusActorCreate } from "./pegasus-create-char.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
const __level2Dice = ["d0", "d4", "d6", "d8", "d10", "d12"]; const __level2Dice = ["d0", "d4", "d6", "d8", "d10", "d12"]
const __name2DiceValue = { "0": 0, "d0": 0, "d4": 4, "d6": 6, "d8": 8, "d10": 10, "d12": 12 } const __name2DiceValue = { "0": 0, "d0": 0, "d4": 4, "d6": 6, "d8": 8, "d10": 10, "d12": 12 }
const __dice2Level = {"d0": 0, "d4": 1, "d6": 2, "d8": 3, "d10": 4, "d12": 5}
/* -------------------------------------------- */ /* -------------------------------------------- */
export class PegasusUtility { export class PegasusUtility {
@ -142,14 +143,17 @@ export class PegasusUtility {
static updateStatDicePool( rollData) { static updateStatDicePool( rollData) {
let newDicePool = rollData.dicePool.filter(dice => dice.name != "stat") let newDicePool = rollData.dicePool.filter(dice => dice.name != "stat")
let statDice = rollData.dicePool.find(dice => dice.name == "stat") let statDice = rollData.dicePool.find(dice => dice.name == "stat")
if (rollData.statDicesLevel > 0) { if (statDice.level > 0) {
let diceKey = PegasusUtility.getDiceFromLevel(rollData.statDicesLevel) let diceKey = PegasusUtility.getDiceFromLevel(rollData.statDicesLevel)
let diceList = diceKey.split(" ") let diceList = diceKey.split(" ")
let mod = statDice.mod
for (let myDice of diceList) { for (let myDice of diceList) {
myDice = myDice.trim()
let newDice = { let newDice = {
name: "stat", key: myDice, level: rollData.statDicesLevel, mod: statDice.mod, name: "stat", key: myDice, level: PegasusUtility.getLevelFromDice(myDice), mod: mod,
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp` img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
} }
mod = 0 // Only first dice has modifier
newDicePool.push(newDice) newDicePool.push(newDice)
} }
} }
@ -163,8 +167,9 @@ export class PegasusUtility {
let diceKey = PegasusUtility.getDiceFromLevel(rollData.specDicesLevel) let diceKey = PegasusUtility.getDiceFromLevel(rollData.specDicesLevel)
let diceList = diceKey.split(" ") let diceList = diceKey.split(" ")
for (let myDice of diceList) { for (let myDice of diceList) {
myDice = myDice.trim()
let newDice = { let newDice = {
name: "spec", key: myDice, level: rollData.specDicesLevel, name: "spec", key: myDice, level: PegasusUtility.getLevelFromDice(myDice),
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp` img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
} }
newDicePool.push(newDice) newDicePool.push(newDice)
@ -467,6 +472,10 @@ export class PegasusUtility {
} }
return diceValue return diceValue
} }
/* -------------------------------------------- */
static getLevelFromDice(dice) {
return __dice2Level[dice]
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static getDiceFromLevel(level = 0) { static getDiceFromLevel(level = 0) {

View File

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