This commit is contained in:
sladecraven 2022-09-27 20:31:01 +02:00
parent 85585325e3
commit ffaa9e4c19
8 changed files with 45 additions and 13 deletions

View File

@ -47,7 +47,7 @@ export class PegasusActorSheet extends ActorSheet {
armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())),
shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields()) ),
equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ),
perks: duplicate(this.actor.getPerks()),
perks: this.actor.getPerks(),
abilities: duplicate(this.actor.getAbilities()),
activePerks: duplicate(this.actor.getActivePerks()),
powers: duplicate(this.actor.getPowers()),

View File

@ -120,6 +120,7 @@ export class PegasusActor extends Actor {
this.computeNRGHealth();
this.system.encCapacity = this.getEncumbranceCapacity()
this.buildContainerTree()
this.updatePPP()
}
if (this.type == 'vehicle') {
this.computeVehicleStats();
@ -149,8 +150,13 @@ export class PegasusActor extends Actor {
return ab;
}
/* -------------------------------------------- */
getPerks() {
let comp = this.items.filter(item => item.type == 'perk');
getPerks() {
let comp = duplicate(this.items.filter(item => item.type == 'perk') || [])
for (let perk of comp) {
if (perk.system.features.range.flag) {
perk.rangeText = PegasusUtility.getRangeText( perk.system.features.range.value)
}
}
return comp;
}
/* -------------------------------------------- */
@ -356,6 +362,21 @@ export class PegasusActor extends Actor {
await this.updateEmbeddedDocuments('Item', [update]) // Updates one EmbeddedEntity
}
}
/* -------------------------------------------- */
updatePPP() {
let ppp = 0
for(let power of this.items) {
if (power.type == "power") {
ppp += Number(power.system.powerlevelcost)
}
}
console.log("PPP update", ppp)
if ( ppp != this.system.ppp.spentPPP) {
console.log("PPP update2", ppp)
this.update( { 'system.ppp.spentPPP': ppp} )
}
}
/* -------------------------------------------- */
async activatePower(itemId) {

View File

@ -62,14 +62,19 @@ export class PegasusItemSheet extends ItemSheet {
optionsDiceList: PegasusUtility.getOptionsDiceList(),
optionsStatusList: PegasusUtility.getOptionsStatusList(),
data: itemData.system,
description: await TextEditor.enrichHTML(this.object.system.description, {async: true}),
limited: this.object.limited,
options: this.options,
owner: this.document.isOwner,
mr: (this.object.type == 'specialisation'),
isGM: game.user.isGM
}
if (this.object.type == "power") {
formData.effects = await TextEditor.enrichHTML(this.object.system.effects, {async: true})
formData.purchasedeffects = await TextEditor.enrichHTML(this.object.system.purchasedeffects, {async: true})
}
this.options.editable = true //!(this.object.isEmbedded)
this.options.editable = true
console.log("ITEM DATA", formData, this);
return formData;
}
@ -425,7 +430,6 @@ export class PegasusItemSheet extends ItemSheet {
let data = event.dataTransfer.getData('text/plain')
let dataItem = JSON.parse( data)
console.log("DROP", event, dataItem )
let item = fromUuidSync(dataItem.uuid)
if (item.pack) {
item = await PegasusUtility.searchItem(item)
@ -434,7 +438,6 @@ export class PegasusItemSheet extends ItemSheet {
ui.notifications.warn("Unable to find relevant item - Aborting drag&drop " + data.uuid)
return
}
console.log("DROP REULT", this.object.type, item.type)
if (this.object.type == 'virtue' ) {
if (item.type == 'effect') {

View File

@ -8,6 +8,9 @@ import { PegasusRollDialog } from "./pegasus-roll-dialog.js";
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 }
const __rangeKeyToText = { notapplicable: "N/A", touch: "Self Only", touchself: "Touch/Self", tz: "Threat Zone", close: "Close", medium: "Medium",
long: "Long", extreme: "Extreme", sight: "Lineof Sight", tz_close: "TZ/Close", close_medium: "Close/Medium", medium_long: "Medium/Long",
long_extreme: "Long/Extreme"}
/* -------------------------------------------- */
export class PegasusUtility {
@ -98,6 +101,11 @@ export class PegasusUtility {
options.push({ name: "Apply -10", condition: true, icon: '<i class="fas fa-plus"></i>', callback: target => { PegasusCombat.decInitBy10(target.data('combatant-id'), -10); } })
}
/* -------------------------------------------- */
static getRangeText( rangeKey) {
return __rangeKeyToText[rangeKey] || "N/A"
}
/* -------------------------------------------- */
static getDiceList() {
return [{ key: "d4", level: 1, img: "systems/fvtt-pegasus-rpg/images/dice/d4.webp" }, { key: "d6", level: 2, img: "systems/fvtt-pegasus-rpg/images/dice/d6.webp" },

View File

@ -208,7 +208,7 @@
<span class="item-field-label-short">{{perk.system.level}}</span>
{{#if perk.system.features.range.flag}}
<span class="item-field-label-medium">{{perk.system.features.range.value}}</span>
<span class="item-field-label-medium">{{perk.rangeText}}</span>
{{else}}
<span class="item-field-label-medium">&nbsp;-&nbsp;</span>
@ -402,8 +402,7 @@
data-dtype="Number" />
&nbsp;&nbsp;
<span class="small-label padd-right packed-left">Spent PPP</span><input type="text"
class="padd-right input-numeric-short" name="system.ppp.spent" value="{{data.ppp.spent}}"
data-dtype="Number" />
class="padd-right input-numeric-short" name="system.ppp.spentPPP" value="{{data.ppp.spentPPP}}" disabled data-dtype="Number" />
</li>
</ul>

View File

@ -9,6 +9,7 @@
{{!-- Sheet Body --}}
<section class="sheet-body">
{{> systems/fvtt-pegasus-rpg/templates/partial-item-description.html}}
<div class="tab details" data-group="primary" data-tab="details">

View File

@ -14,15 +14,15 @@
<div class="tab description" data-group="primary" data-tab="description">
<div class="medium-editor item-text-long-line">
<label class="generic-label">Description</label>
{{editor data.description target="system.description" button=true owner=owner editable=editable}}
{{editor description target="system.description" button=true owner=owner editable=editable}}
</div>
<div class="medium-editor item-text-long-line">
<label class="generic-label">Available Effects</label>
{{editor data.effects target="system.effects" button=true owner=owner editable=editable}}
{{editor effects target="system.effects" button=true owner=owner editable=editable}}
</div>
<div class="medium-editor item-text-long-line">
<label class="generic-label">Purchased Effects</label>
{{editor data.purchasedeffects target="system.purchasedeffects" button=true owner=owner
{{editor purchasedeffects target="system.purchasedeffects" button=true owner=owner
editable=editable}}
</div>
</div>

View File

@ -2,7 +2,7 @@
<div>
<label class="generic-label">Description</label>
<div class="medium-editor item-text-long-line">
{{editor data.description target="system.description" button=true owner=owner editable=editable}}
{{editor description target="system.description" button=true owner=owner editable=editable}}
</div>
</div>
</div>