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 */
_updateObject(event, formData) {
// 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') {
const skills = await PegasusUtility.loadCompendium("fvtt-weapons-of-the-gods.skills");
data.items = skills.map(i => i.toObject());
}
if (data.type == 'npc') {
}
@ -1042,7 +1040,7 @@ export class PegasusActor extends Actor {
if (moralitythreshold != this.data.data.biodata.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!" })
this.warnMorality = true
}
@ -1055,11 +1053,13 @@ 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)
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
@ -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)

View File

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

View File

@ -4,8 +4,9 @@ import { PegasusCommands } from "./pegasus-commands.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 __dice2Level = {"d0": 0, "d4": 1, "d6": 2, "d8": 3, "d10": 4, "d12": 5}
/* -------------------------------------------- */
export class PegasusUtility {
@ -142,14 +143,17 @@ export class PegasusUtility {
static updateStatDicePool( rollData) {
let newDicePool = rollData.dicePool.filter(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 diceList = diceKey.split(" ")
let mod = statDice.mod
for (let myDice of diceList) {
myDice = myDice.trim()
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`
}
mod = 0 // Only first dice has modifier
newDicePool.push(newDice)
}
}
@ -163,8 +167,9 @@ export class PegasusUtility {
let diceKey = PegasusUtility.getDiceFromLevel(rollData.specDicesLevel)
let diceList = diceKey.split(" ")
for (let myDice of diceList) {
myDice = myDice.trim()
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`
}
newDicePool.push(newDice)
@ -467,6 +472,10 @@ export class PegasusUtility {
}
return diceValue
}
/* -------------------------------------------- */
static getLevelFromDice(dice) {
return __dice2Level[dice]
}
/* -------------------------------------------- */
static getDiceFromLevel(level = 0) {

View File

@ -183,6 +183,6 @@
"templateVersion": 96,
"title": "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"
}