diff --git a/modules/pegasus-actor-sheet.js b/modules/pegasus-actor-sheet.js index bf67a83..2c9e865 100644 --- a/modules/pegasus-actor-sheet.js +++ b/modules/pegasus-actor-sheet.js @@ -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) } } diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 87e207a..f66f51d 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -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) diff --git a/modules/pegasus-roll-dialog.js b/modules/pegasus-roll-dialog.js index 49486e8..b5ecb7b 100644 --- a/modules/pegasus-roll-dialog.js +++ b/modules/pegasus-roll-dialog.js @@ -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) => { - 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) this.refreshDialog() }); diff --git a/modules/pegasus-utility.js b/modules/pegasus-utility.js index 3a500fa..9517395 100644 --- a/modules/pegasus-utility.js +++ b/modules/pegasus-utility.js @@ -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) { diff --git a/system.json b/system.json index 8dac708..1dd0bc4 100644 --- a/system.json +++ b/system.json @@ -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" }