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 __speed2Num = { fullstop: 0, crawling: 1, slow: 2, average: 3, fast: 4, extfast: 5 }
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) {
if ( item.type != "effect" && __isVehicle[item.type]) {
ui.notifications.warn("You can't drop Vehicles item over a character sheet.")
return
}
// Pre-filter effects
if (item.type == 'effect') {
@ -649,6 +654,7 @@ export class PegasusActor extends Actor {
}
}
if (item.type == 'race') {
this.applyRace(item.system)
} else if (item.type == 'role') {
@ -1851,7 +1857,7 @@ export class PegasusActor extends Actor {
modules.totalvms = Number(hull.system.vms)
} else {
modules.totalvms = 0
}
}
let spaceList = this.items.filter(item => item.type == "vehiclemodule") || []
spaceList = spaceList.concat(this.items.filter(item => item.type == "vehicleweaponmodule") || [])
let space = 0
@ -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) {
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])
if ( __isVehicleUnique[item.type] ) {
let toDelList = []
@ -1886,7 +1910,13 @@ export class PegasusActor extends Actor {
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
}

View File

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

View File

@ -254,6 +254,6 @@
],
"title": "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"
}

View File

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

View File

@ -45,14 +45,16 @@
{{#if (eq key "pc")}}
<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>
<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">
<a class="vehicle-current-nrg-plus plus-minus-button">+</a>
<a class="vehicle-current-nrg-minus plus-minus-button">&nbsp;-</a>
</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>
{{/if}}

View File

@ -253,16 +253,26 @@
<div class="tab items" data-group="primary" data-tab="modules">
<div class="stat-item">
<span class="flexrow">
<h3>VMS</h3>
</span>
<ul class="stat-list alternate-list">
<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>
<input type="text" class="" name="system.modules.totalvms" value="{{data.modules.totalvms}}"
data-dtype="Number" disabled />
<input type="text" class="input-numeric-short" name="system.modules.totalvms" value="{{data.modules.totalvms}}"
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>
<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 />
</li>
</ul>