diff --git a/modules/pegasus-actor-sheet.js b/modules/pegasus-actor-sheet.js index 8636835..b572623 100644 --- a/modules/pegasus-actor-sheet.js +++ b/modules/pegasus-actor-sheet.js @@ -62,6 +62,8 @@ export class PegasusActorSheet extends ActorSheet { levelRemainingList: this.actor.getLevelRemainingList(), maxLevelRemainingList: this.actor.getMaxLevelRemainingList(), disabledBonus: (this.actor.system.biodata.noautobonus) ? "" : "disabled", + mt: this.actor.getMT(), + kbv: this.actor.getKBV(), containersTree: this.actor.containersTree, encCurrent: this.actor.encCurrent, encHindrance: this.actor.encHindrance, diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 9860247..57d96a4 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -134,7 +134,14 @@ export class PegasusActor extends Actor { super._preUpdate(changed, options, user); } - + /* -------------------------------------------- */ + getMT() { + return PegasusUtility.getDiceValue(this.system.statistics.mnd.value) + this.system.statistics.mnd.mod + PegasusUtility.getDiceValue(this.system.statistics.mnd.bonuseffect) + } + /* -------------------------------------------- */ + getKBV() { + return this.system.statistics.phy.value + this.system.statistics.phy.mod + this.system.statistics.phy.bonuseffect + } /* -------------------------------------------- */ getEncumbranceCapacity() { return this.system.statistics.str.value * 25 @@ -489,7 +496,10 @@ export class PegasusActor extends Actor { increaseRoleAbility() { } - + /* -------------------------------------------- */ + setBonusInformation( info) { + this.update( {'system.biodata.bonusselection': info}) + } /* -------------------------------------------- */ addCDP( value) { let cdp = this.system.biodata.cdp @@ -500,7 +510,8 @@ export class PegasusActor extends Actor { /* -------------------------------------------- */ addPPP(value) { let ppp = duplicate(this.system.ppp) - ppp.availablePPP += value + console.log("PPP", ppp) + ppp.availablePPP += Number(value) this.update({ 'system.ppp': ppp }) } @@ -1457,9 +1468,11 @@ export class PegasusActor extends Actor { } if (!this.isToken) { if (this.warnMorality != this.system.biodata.morality && this.system.biodata.morality < 0) { - console.log("CHAR", this) ChatMessage.create({ content: "WARNING: Your character is dangerously close to becoming corrupted and defeated. Start on a path of redemption!" }) } + if (this.warnMorality != this.system.biodata.morality && this.system.biodata.morality == 0) { + ChatMessage.create({ content: "This character can no longer spend CDP until their Morality has reached 1 or higher" }) + } if (this.warnMorality != this.system.biodata.morality) { this.warnMorality = this.system.biodata.morality } @@ -1645,6 +1658,9 @@ export class PegasusActor extends Actor { /* -------------------------------------------- */ async applyAbility(ability, updates = [], directUpdate = false) { // manage stat bonus + if (!ability.system) { + ability.system = ability.data + } if (ability.system.affectedstat != "notapplicable") { let stat = duplicate(this.system.statistics[ability.system.affectedstat]) stat.mod += Number(ability.system.statmodifier) @@ -1775,9 +1791,9 @@ export class PegasusActor extends Actor { if (overCapacity > 0) { effectsList.push({ label: "Encumbrance Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: overCapacity }) } - if (this.system.biodata.morality <= 0) { + /* Remove as per ticket #159if (this.system.biodata.morality <= 0) { effectsList.push({ label: "Morality Hindrance", type: "hindrance", foreign: true, actorId: this.id, applied: false, value: 3 }) - } + }*/ let effects = this.items.filter(item => item.type == 'effect') for (let effect of effects) { effect = duplicate(effect) @@ -1842,7 +1858,23 @@ export class PegasusActor extends Actor { if (isPowerDmg && effect.system.stataffected == "powerdmgroll") { this.pushEffect(rollData, effect) } + } + } + /* -------------------------------------------- */ + addRoleBonus(rollData, statKey, subKey) { + let role = this.getRole() + if (role.name.toLowerCase() == "ranged" && subKey == "ranged-dmg") { + rollData.effectsList.push({ label: "Ranged Role Bonus", type: "effect", applied: true, isdynamic: true, value: this.getRoleLevel() }) + rollData.dicePool = rollData.dicePool.concat(PegasusUtility.buildDicePool("effect-bonus-dice", this.getRoleLevel(), 0, "Ranged Role Bonus")) + } + if (role.name.toLowerCase() == "defender" && subKey == "defence") { + rollData.effectsList.push({ label: "Defender Role Bonus", type: "effect", applied: true, isdynamic: true, value: this.getRoleLevel() }) + rollData.dicePool = rollData.dicePool.concat(PegasusUtility.buildDicePool("effect-bonus-dice", this.getRoleLevel(), 0,"Defender Role Bonus")) + } + if (role.name.toLowerCase() == "scrapper" && statKey == "com") { + rollData.effectsList.push({ label: "Scrapper Role Bonus", type: "effect", applied: true, isdynamic: true, value: this.getRoleLevel() }) + rollData.dicePool = rollData.dicePool.concat(PegasusUtility.buildDicePool("effect-bonus-dice", this.getRoleLevel(), 0,"Scrapper Role Bonus")) } } @@ -2026,6 +2058,7 @@ export class PegasusActor extends Actor { this.addArmorsShields(rollData, statKey, useShield, subKey) this.addWeapons(rollData, statKey, useShield) this.addEquipments(rollData, statKey) + this.addRoleBonus(rollData, statKey, subKey) this.processVehicleTargetMessage(rollData) console.log("ROLLDATA", rollData) diff --git a/modules/pegasus-create-char.js b/modules/pegasus-create-char.js index 1d37a47..cfda9d3 100644 --- a/modules/pegasus-create-char.js +++ b/modules/pegasus-create-char.js @@ -75,7 +75,7 @@ export class PegasusActorCreate { if (step == "select-race") { let race = this.races.find(item => item._id == itemId); this.currentRace = race; - this.actor.applyRace(race); + await this.actor.applyRace(race); PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); if (race.system.nboptionnal > 0 && race.system.optionnalabilities.length > 0) { this.manageOptionnalAbilities(race); @@ -93,7 +93,7 @@ export class PegasusActorCreate { if (step == 'select-race-optionnal') { let ability = this.raceOptionnalAbilities.optionnalabilities.find(item => item._id == itemId); let update = [] - this.actor.applyAbility(ability, update); + await this.actor.applyAbility(ability, update); this.actor.update(update) this.actor.createEmbeddedDocuments('Item', [ability]); PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); @@ -104,7 +104,7 @@ export class PegasusActorCreate { if (step == 'select-race-stats') { let statKey = $(event.currentTarget).data("stat-key"); - this.actor.modStat(statKey, 1); + await this.actor.modStat(statKey, 1); this.raceSelectableStats.stats[statKey].used = true; this.raceSelectableStats.numberstats -= 1; PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); @@ -114,7 +114,7 @@ export class PegasusActorCreate { if (step == 'select-race-perks') { PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); let perk = this.racePerks.find(item => item._id == itemId); - this.actor.createEmbeddedDocuments('Item', [perk]); + await this.actor.createEmbeddedDocuments('Item', [perk]); this.racePerks = this.racePerks.filter(item => item._id != itemId); this.nbRacePerks -= 1; if (this.nbRacePerks == 0 || this.racePerks.length == 0) { @@ -127,7 +127,7 @@ export class PegasusActorCreate { if (step == 'select-role') { let role = this.roles.find(item => item._id == itemId); PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); - this.actor.applyRole(role); + await this.actor.applyRole(role); this.currentRole = role; this.nbRoleStat = 2; this.roleStats = duplicate(role.system.statincreasechoice) @@ -137,7 +137,7 @@ export class PegasusActorCreate { if (step == 'select-role-start-spec') { PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); let spec = this.roleSpecStart.find(item => item._id == itemId); - this.actor.addIncSpec(spec, 1); + await this.actor.addIncSpec(spec, 1); this.nbRoleSpecStart--; this.roleSpecStart = this.roleSpecStart.filter(item => item._id != itemId);//Remove selected spec if (this.nbRoleSpecStart == 0) { @@ -150,7 +150,7 @@ export class PegasusActorCreate { if (step == 'select-role-stat') { PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); let statKey = $(event.currentTarget).data("stat-key"); - this.actor.valueStat(statKey, 1); + await this.actor.valueStat(statKey, 1); for (let stat of this.roleStats) { if (stat.name.toLowerCase() == statKey.toLowerCase()) { @@ -172,15 +172,15 @@ export class PegasusActorCreate { PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); let spec = this.roleSpec.find(item => item._id == itemId); if (this.nbDT2 > 0) { - this.actor.addIncSpec(spec, 2) + await this.actor.addIncSpec(spec, 2) this.nbDT2--; } else { - this.actor.addIncSpec(spec, 1) + await this.actor.addIncSpec(spec, 1) this.nbDT1--; } this.roleSpec = this.roleSpec.filter(item => item._id != itemId);//Remove selected spec if (this.nbDT1 == 0 || this.roleSpec.length == 0) { - this.rolePerks = this.getPerksFromRole(this.currentRole) // duplicate(this.currentRole.data.perks) + this.rolePerks = this.getPerksFromRole(this.currentRole) this.nbPerks = 2; this.showRolePerks() } else { @@ -191,7 +191,7 @@ export class PegasusActorCreate { if (step == 'select-role-perk') { PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); let perk = this.rolePerks.find(item => item._id == itemId); - this.actor.addIncPerk(perk, 1) + await this.actor.addIncPerk(perk, 1) let excludedPerks = this.actor.items.filter(it => it.type == "perk" && !it.system.upgradable) this.rolePerks = [] for (let perk of this.rolePerks) { @@ -216,7 +216,7 @@ export class PegasusActorCreate { if (step == 'select-global-spec') { PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); let spec = this.specs.find(item => item._id == itemId); - this.actor.addIncSpec(spec, 1) + await this.actor.addIncSpec(spec, 1) this.nbGlobalSpec--; if (this.nbGlobalSpec == 0) { this.nbGlobalStat = 5 @@ -233,7 +233,7 @@ export class PegasusActorCreate { if (step == 'select-global-stat') { PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)) let statKey = $(event.currentTarget).data("stat-key") - this.actor.valueStat(statKey, 1) + await this.actor.valueStat(statKey, 1) this.nbGlobalStat-- if (this.nbGlobalStat == 0) { this.nbGlobalPerk = 1 @@ -250,13 +250,14 @@ export class PegasusActorCreate { if (step == 'select-global-perk') { PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)) let perk = this.perks.find(item => item._id == itemId); - this.actor.addIncPerk(perk, 1) + await this.actor.addIncPerk(perk, 1) this.nbGlobalPerk--; if (this.nbGlobalPerk == 0) { this.nbGlobalStatus = 1 if (this.forceVirtue) { this.showVirtue() } else { + this.statusCount = {} this.showGlobalStatus() } } else { @@ -267,7 +268,8 @@ export class PegasusActorCreate { if (step == 'select-global-status') { PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)) let statusKey = $(event.currentTarget).data("status-key") - this.actor.addStatusBonus(statusKey, 1) + await this.actor.addStatusBonus(statusKey, 1) + this.statusCount[statusKey] = (this.statusCount[statusKey]) ? this.statusCount[statusKey]+1 : 1; this.nbGlobalStatus--; if (this.nbGlobalStatus == 0) { this.nbBonusSelection = 1 @@ -286,48 +288,63 @@ export class PegasusActorCreate { let nextStep = $(event.currentTarget).data("bonus-key") this.forceVirtue = true if (nextStep == "bonus-statistic") { + this.actor.setBonusInformation("Stats Increased") this.nbGlobalStat = 2 this.showGlobalStat() } if (nextStep == "bonus-specialisation") { + this.actor.setBonusInformation("Specialisations Increased") this.nbGlobalSpec = 4 this.showGlobalSpec() } if (nextStep == "bonus-perk") { + this.actor.setBonusInformation("Perks - Check Effects & Perk Details.") this.nbGlobalPerk = 2 this.showGlobalPerk() } if (nextStep == "bonus-status") { + this.actor.setBonusInformation("Status Modifiers") this.nbGlobalStatus = 5 + this.statusCount = {} this.showGlobalStatus() } if (nextStep == "bonus-roleability") { + this.actor.setBonusInformation("Role Ability Level Increased") this.actor.increaseRoleAbility() + this.showVirtue() } if (nextStep == "bonus-ppp5") { + this.actor.setBonusInformation("Power Purchase Points") this.actor.addPPP(5) + this.showVirtue() } if (nextStep == "bonus-wealthy") { + this.actor.setBonusInformation("x2 Starting Funds") ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with x2 Starting Funds" }) this.showVirtue() } if (nextStep == "bonus-heirloom") { + this.actor.setBonusInformation("Family Heirloom (Level 1 Bonus Dice Item)") ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with an item of choice (GM Must approve). This item provides a Level 1 Bonus Dice to a Stat of choice" }) this.showVirtue() } if (nextStep == "bonus-vehicle") { + this.actor.setBonusInformation("Vehicle") ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with a Vehicle of Choice (GM Must approve)." }) this.showVirtue() } if (nextStep == "bonus-mount") { + this.actor.setBonusInformation("Mount") ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with a Mount of Choice (GM Must approve)." }) this.showVirtue() } if (nextStep == "bonus-sidekick") { + this.actor.setBonusInformation("Sidekick") ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with a Sidekick of Choice (GM Must approve)." }) this.showVirtue() } if (nextStep == "bonus-ambidextrious") { + this.actor.setBonusInformation("Ambidextrious") this.actor.setHandInformation("Ambidextrious") this.showVirtue() } @@ -411,9 +428,9 @@ export class PegasusActorCreate { manageSelectableStats(race) { this.raceSelectableStats = { "race": race, - "statsonlyonce": race.data.statsonlyonce, - "numberstats": race.data.numberstats, - "stats": duplicate(this.actor.data.data.statistics) + "statsonlyonce": race.system.statsonlyonce, + "numberstats": race.system.numberstats, + "stats": duplicate(this.actor.system.statistics) } this.processSelectableStats() } @@ -433,17 +450,17 @@ export class PegasusActorCreate { /* --------------- -------------------- --------- */ manageRacePerks(race) { - if (!this.currentRace.data.perksgained) { + if (!this.currentRace.system.perksgained) { this.showRoles() return; } if (!this.racePerks) { // First init - if (this.currentRace.data.perksall) { + if (this.currentRace.system.perksall) { this.racePerks = duplicate(this.perks) } else { - this.racePerks = duplicate(this.currentRace.data.perks) + this.racePerks = duplicate(this.currentRace.system.perks) } - this.nbRacePerks = this.currentRace.data.perksnumber; + this.nbRacePerks = this.currentRace.system.perksnumber; } let formData = this.createFormData("select-race-perks") formData.raceperks = this.racePerks; @@ -474,8 +491,8 @@ export class PegasusActorCreate { /* --------------- ----------------------------- */ manageOptionnalAbilities(race) { this.raceOptionnalAbilities = { - "nboptionnal": race.data.nboptionnal, - "optionnalabilities": duplicate(race.data.optionnalabilities), + "nboptionnal": race.system.nboptionnal, + "optionnalabilities": duplicate(race.system.optionnalabilities), } this.processOptionnalAbilitiesStep() } @@ -513,8 +530,6 @@ export class PegasusActorCreate { async showRoleStartSpec() { if (!this.roleSpecStart) { this.roleSpecStart = this.specs.filter(spec => spec.system.statistic.toUpperCase() == this.currentRole.system.statincrease1.toUpperCase() || spec.system.statistic.toUpperCase() == this.currentRole.system.statincrease2.toUpperCase()) - //console.log("SPEC FOUND", this.roleSpecStart) - //this.roleSpecStart = duplicate(this.currentRole.data.specialisationsplus1) this.nbRoleSpecStart = 2; } let formData = this.createFormData("select-role-start-spec") @@ -589,7 +604,7 @@ export class PegasusActorCreate { formData.stats = {} for (let key in this.actor.system.statistics) { let stat = this.actor.system.statistics[key] - if (stat.level < 5) { + if (stat.value < 5) { formData.stats[key] = duplicate(stat) } } @@ -620,8 +635,18 @@ export class PegasusActorCreate { /* -------------------------------------------- */ async showGlobalStatus() { let formData = this.createFormData("select-global-status") - formData.status = duplicate(this.actor.system.secondary) - formData.status["nrg"] = duplicate(this.actor.system.nrg) + formData.status = {} + for(let statusKey in this.actor.system.secondary) { + if ( this.statusCount[statusKey] == undefined) { + this.statusCount[statusKey] = 0 + } + if ( this.statusCount[statusKey] < 3) { + formData.status[statusKey] = duplicate(this.actor.system.secondary[statusKey]) + } + } + if ( this.statusCount["nrg"] < 3) { + formData.status["nrg"] = duplicate(this.actor.system.nrg) + } this.renderChatMessage(formData) } diff --git a/system.json b/system.json index c99f92e..a16be62 100644 --- a/system.json +++ b/system.json @@ -253,7 +253,7 @@ ], "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "10.2.0", - "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v10.2.0.zip", + "version": "10.2.1", + "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v10.2.1.zip", "background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp" } \ No newline at end of file diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index c657ada..67629f6 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -168,6 +168,22 @@ +