NRG stuff

This commit is contained in:
sladecraven 2022-09-18 17:30:15 +02:00
parent 9a20a96cec
commit 343ac6ab9d
6 changed files with 57 additions and 12 deletions

View File

@ -23,6 +23,7 @@ const __statBuild = [
const __isVehicleUnique = { vehiclehull:1, powercoremodule:1, mobilitymodule: 1, propulsionmodule: 1, combatmodule: 1} const __isVehicleUnique = { vehiclehull:1, powercoremodule:1, mobilitymodule: 1, propulsionmodule: 1, combatmodule: 1}
const __speed2Num = { fullstop: 0, crawling: 1, slow: 2, average: 3, fast: 4, extfast: 5 } const __speed2Num = { fullstop: 0, crawling: 1, slow: 2, average: 3, fast: 4, extfast: 5 }
const __num2speed = ["fullstop", "crawling", "slow", "average", "fast", "extfast"] const __num2speed = ["fullstop", "crawling", "slow", "average", "fast", "extfast"]
const __isVehicle = { vehiclehull: 1, powercoremodule: 1, mobilitymodule: 1, combatmodule: 1, propulsionmodule: 1, vehiclemodule: 1, vehicleweaponmodule: 1, effect: 1}
/* -------------------------------------------- */ /* -------------------------------------------- */
/** /**
@ -628,6 +629,10 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async preprocessItem(event, item, onDrop = false) { async preprocessItem(event, item, onDrop = false) {
if ( item.type != "effect" && __isVehicle[item.type]) {
ui.notifications.warn("You can't drop Vehicles item over a character sheet.")
return
}
// Pre-filter effects // Pre-filter effects
if (item.type == 'effect') { if (item.type == 'effect') {
@ -649,6 +654,7 @@ export class PegasusActor extends Actor {
} }
} }
if (item.type == 'race') { if (item.type == 'race') {
this.applyRace(item.system) this.applyRace(item.system)
} else if (item.type == 'role') { } else if (item.type == 'role') {
@ -1868,11 +1874,29 @@ export class PegasusActor extends Actor {
} }
// Manage top speed }
/* -------------------------------------------- */
getTotalCost( ) {
let sumCost = 0
for( let item of this.items) {
if ( __isVehicle[item.type]) {
if (item.system.cost) {
sumCost += Number(item.system.cost)
}
}
}
return sumCost
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async preprocessItemVehicle(event, item, onDrop = false) { async preprocessItemVehicle(event, item, onDrop = false) {
if ( item.type != "effect" && !__isVehicle[item.type]) {
ui.notifications.warn("You can't drop Character items over a vehicle sheet.")
return
}
//console.log(">>>>> item", item.type, __isVehicleUnique[item.type]) //console.log(">>>>> item", item.type, __isVehicleUnique[item.type])
if ( __isVehicleUnique[item.type] ) { if ( __isVehicleUnique[item.type] ) {
let toDelList = [] let toDelList = []
@ -1886,7 +1910,13 @@ export class PegasusActor extends Actor {
await this.deleteEmbeddedDocuments('Item', toDelList) await this.deleteEmbeddedDocuments('Item', toDelList)
} }
} }
// Check size
if (item.type == "vehiclemodule" || item.type == "vehicleweaponmodule") {
if ( this.system.modules.usedvms + Number(item.system.space) > this.system.modules.totalvms ) {
ChatMessage.create( { content: `No more room available to host module ${item.name}. Module is not added to the vehicle.`})
return false
}
}
return true return true
} }

View File

@ -40,6 +40,8 @@ export class PegasusVehicleSheet extends ActorSheet {
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)), effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
limited: this.object.limited, limited: this.object.limited,
optionsDiceList: PegasusUtility.getOptionsDiceList(), optionsDiceList: PegasusUtility.getOptionsDiceList(),
vmsAvailable: objectData.system.modules.totalvms - objectData.system.modules.vmsused,
totalCost: this.actor.getTotalCost(),
optionsLevel: PegasusUtility.getOptionsLevel(), optionsLevel: PegasusUtility.getOptionsLevel(),
subActors: duplicate(this.actor.getSubActors()), subActors: duplicate(this.actor.getSubActors()),
effects: duplicate(this.actor.getEffects()), effects: duplicate(this.actor.getEffects()),

View File

@ -254,6 +254,6 @@
], ],
"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": "10.0.8", "version": "10.0.9",
"background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp" "background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp"
} }

View File

@ -233,6 +233,7 @@
"currentlevel": 0, "currentlevel": 0,
"avgnrg": 0, "avgnrg": 0,
"curnrg": 0, "curnrg": 0,
"maxnrg": 0,
"col": 2 "col": 2
}, },
"mr": { "mr": {

View File

@ -45,14 +45,16 @@
{{#if (eq key "pc")}} {{#if (eq key "pc")}}
<div class="flexrow stat-text-white"> <div class="flexrow stat-text-white">
<span class="stat-label stat-margin" name="{{key}}">Av NRG</span>
<input type="text" class="input-numeric-short" name="system.statistics.{{key}}.avgnrg" value="{{stat.avgnrg}}" data-dtype="Number" />
<span class="stat-label stat-margin" name="{{key}}">Cur NRG</span> <span class="stat-label stat-margin" name="{{key}}">Cur NRG</span>
<input type="text" class="input-numeric-short" name="system.statistics.{{key}}.curnrg" value="{{stat.curnrg}}" data-dtype="Number" /> <input type="text" class="input-numeric-short" name="system.statistics.{{key}}.curnrg" value="{{stat.curnrg}}" data-dtype="Number" />
<span class="padd-right status-small-label no-grow"> <span class="padd-right status-small-label no-grow">
<a class="vehicle-current-nrg-plus plus-minus-button">+</a> <a class="vehicle-current-nrg-plus plus-minus-button">+</a>
<a class="vehicle-current-nrg-minus plus-minus-button">&nbsp;-</a> <a class="vehicle-current-nrg-minus plus-minus-button">&nbsp;-</a>
</span> </span>
<span class="stat-label stat-margin" name="{{key}}">Av NRG</span>
<input type="text" class="input-numeric-short" name="system.statistics.{{key}}.avgnrg" value="{{stat.avgnrg}}" data-dtype="Number" />
<span class="stat-label stat-margin" name="{{key}}">Max NRG</span>
<input type="text" class="input-numeric-short" name="system.statistics.{{key}}.maxnrg" value="{{stat.maxnrg}}" data-dtype="Number" />
</div> </div>
{{/if}} {{/if}}

View File

@ -253,16 +253,26 @@
<div class="tab items" data-group="primary" data-tab="modules"> <div class="tab items" data-group="primary" data-tab="modules">
<div class="stat-item"> <div class="stat-item">
<span class="flexrow">
<h3>VMS</h3>
</span>
<ul class="stat-list alternate-list"> <ul class="stat-list alternate-list">
<li class="item stat flexrow list-item"> <li class="item stat flexrow list-item">
<span class="generic-label small-label "><strong>VDP</strong></span>
<input type="text" class="input-numeric-short padd-right" name="system.modules.vdp" value="{{data.modules.vdp}}"
data-dtype="Number" />
<span class="generic-label small-label"><strong>Vehicle Value</strong></span>
<input type="text" class="input-numeric-short" name="system.modules.vehiculevalue" value="{{data.modules.vehiculevalue}}"
data-dtype="Number" />
<span class="generic-label small-label"><strong>Total cost</strong></span>
<input type="text" class="" value="{{totalCost}}"
data-dtype="Number" disabled />
<span class="generic-label small-label "><strong>VMS</strong></span>
<span class="generic-label small-label">Total</span> <span class="generic-label small-label">Total</span>
<input type="text" class="" name="system.modules.totalvms" value="{{data.modules.totalvms}}" <input type="text" class="input-numeric-short" name="system.modules.totalvms" value="{{data.modules.totalvms}}"
data-dtype="Number" disabled /> data-dtype="Number" disabled />
<span class="generic-label small-label">Available</span>
<input type="text" class="input-numeric-short" name="system.modules.vmsavailable" value="{{data.modules.vmsAvailable}}"
data-dtype="Number" disabled />
<span class="generic-label small-label">Used</span> <span class="generic-label small-label">Used</span>
<input type="text" class="" name="system.modules.vmsused" value="{{data.modules.vmsused}}" <input type="text" class="input-numeric-short" name="system.modules.vmsused" value="{{data.modules.vmsused}}"
data-dtype="Number" disabled /> data-dtype="Number" disabled />
</li> </li>
</ul> </ul>