Fix #51
This commit is contained in:
parent
9fac687030
commit
c0c6231b4c
@ -14,18 +14,21 @@ const __statBuild = [
|
|||||||
{ modules: ["vehiclehull", "vehiclemodule"], field: "hr", itemfield: "size", subfield: "size" },
|
{ modules: ["vehiclehull", "vehiclemodule"], field: "hr", itemfield: "size", subfield: "size" },
|
||||||
//{ modules: ["vehiclehull"], field: "pc", itemfield: "vms", subfield: "avgnrg" },
|
//{ modules: ["vehiclehull"], field: "pc", itemfield: "vms", subfield: "avgnrg" },
|
||||||
//{ modules: ["powercoremodule"], field: "pc", itemfield: "nrg", subfield: "avgnrg" },
|
//{ modules: ["powercoremodule"], field: "pc", itemfield: "nrg", subfield: "avgnrg" },
|
||||||
{ modules: ["vehiclehull", "mobilitymodule"], itemfield: "man", field: "man", additionnal1: "turningarc45"},
|
{ modules: ["vehiclehull", "mobilitymodule"], itemfield: "man", field: "man", additionnal1: "turningarc45" },
|
||||||
{ modules: ["powercoremodule"], field: "pc", itemfield: "pc", additionnal1: "curnrg", additionnal2: "maxnrg" },
|
{ modules: ["powercoremodule"], field: "pc", itemfield: "pc", additionnal1: "curnrg", additionnal2: "maxnrg" },
|
||||||
{ modules: ["mobilitymodule"], field: "mr", itemfield: "mr" },
|
{ modules: ["mobilitymodule"], field: "mr", itemfield: "mr" },
|
||||||
{ modules: ["propulsionmodule"], field: "ad", itemfield: "ad" },
|
{ modules: ["propulsionmodule"], field: "ad", itemfield: "ad" },
|
||||||
{ modules: ["combatmodule"], field: "fc", itemfield: "fc" },
|
{ modules: ["combatmodule"], field: "fc", itemfield: "fc" },
|
||||||
]
|
]
|
||||||
|
const __LocationsArmour = ["front", "rear", "bottom", "left", "right", "bottom"]
|
||||||
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,
|
const __isVehicle = {
|
||||||
propulsionmodule: 1, vehiclemodule: 1, vehicleweaponmodule: 1, effect: 1, cargo: 1 }
|
vehiclehull: 1, powercoremodule: 1, mobilitymodule: 1, combatmodule: 1,
|
||||||
const __isVehicleCargo = {cargo: 1}
|
propulsionmodule: 1, vehiclemodule: 1, vehicleweaponmodule: 1, effect: 1, cargo: 1
|
||||||
|
}
|
||||||
|
const __isVehicleCargo = { cargo: 1 }
|
||||||
const __bonusEffect = {
|
const __bonusEffect = {
|
||||||
name: "Crawling MAN Bonus", type: "effect", img: "systems/fvtt-pegasus-rpg/images/icons/icon_effect.webp",
|
name: "Crawling MAN Bonus", type: "effect", img: "systems/fvtt-pegasus-rpg/images/icons/icon_effect.webp",
|
||||||
system: {
|
system: {
|
||||||
@ -2006,9 +2009,10 @@ export class PegasusActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Destroyed
|
// Destroyed
|
||||||
if ( this.system.statistics.hr.currentlevel == 0) {
|
if (this.system.statistics.hr.currentlevel == 0) {
|
||||||
ChatMessage.create({ content: `The vehicle ${this.name} has been destroyed !`} )
|
ChatMessage.create({ content: `The vehicle ${this.name} has been destroyed !` })
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2054,20 +2058,42 @@ export class PegasusActor extends Actor {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( __isVehicleCargo[item.type]) {
|
// Cargo management
|
||||||
|
if (__isVehicleCargo[item.type]) {
|
||||||
let capacity = this.getCurrentCargoCapacity()
|
let capacity = this.getCurrentCargoCapacity()
|
||||||
if ( item.type == "cargo") {
|
if (item.type == "cargo") {
|
||||||
capacity += Number(item.system.capacity)
|
capacity += Number(item.system.capacity)
|
||||||
} else {
|
} else {
|
||||||
let q = item.system.quantity || 1
|
let q = item.system.quantity || 1
|
||||||
capacity += Number(q) * Number(item.system.weight)
|
capacity += Number(q) * Number(item.system.weight)
|
||||||
}
|
}
|
||||||
console.log("capa", capacity, this.system.cargo.cargocapacity)
|
console.log("capa", capacity, this.system.cargo.cargocapacity)
|
||||||
if ( capacity > this.system.cargo.cargocapacity) {
|
if (capacity > this.system.cargo.cargocapacity) {
|
||||||
ui.notifications.warn("Your cargo capacity is already full, unable to add this content : " + item.name)
|
ui.notifications.warn("Your cargo capacity is already full, unable to add this content : " + item.name)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Armour management
|
||||||
|
if (item.type == "vehiclemodule" && item.system.category == "armor") {
|
||||||
|
let armorsList = this.items.filter(item => item.type == "vehiclemodule" && item.system.category == "armor") || []
|
||||||
|
armorsList.push(item)
|
||||||
|
let arcKey = item.system.location + "arc"
|
||||||
|
let arc = duplicate(this.system.arcs[arcKey])
|
||||||
|
let level = 0
|
||||||
|
for (let armour of armorsList) {
|
||||||
|
if (armour.system.armourdicevalue > 0) {
|
||||||
|
level += Number(armour.system.armourdicevalue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log(">>>> AMROR, ", level, arc.armourlevel)
|
||||||
|
if (level != Number(arc.armourlevel)) {
|
||||||
|
arc.armourlevel = level
|
||||||
|
setTimeout(500, this.update({ [`system.arcs.${arcKey}`]: arc }))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2163,7 +2189,7 @@ export class PegasusActor extends Actor {
|
|||||||
|
|
||||||
this.addVehicleShields(rollData)
|
this.addVehicleShields(rollData)
|
||||||
this.startRoll(rollData)
|
this.startRoll(rollData)
|
||||||
this.modifyVehicleStun( 1 )
|
this.modifyVehicleStun(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2171,22 +2197,22 @@ export class PegasusActor extends Actor {
|
|||||||
activateVehicleModule(itemId) {
|
activateVehicleModule(itemId) {
|
||||||
let mod = this.items.get(itemId)
|
let mod = this.items.get(itemId)
|
||||||
if (mod) {
|
if (mod) {
|
||||||
if ( mod.system.nrg && mod.system.nrg > 0) {
|
if (mod.system.nrg && mod.system.nrg > 0) {
|
||||||
let pc = duplicate( this.system.statistics.pc)
|
let pc = duplicate(this.system.statistics.pc)
|
||||||
if ( !mod.system.activated ) { // Previous state was non activated -> activated now
|
if (!mod.system.activated) { // Previous state was non activated -> activated now
|
||||||
if ( mod.system.nrg > pc.curnrg) {
|
if (mod.system.nrg > pc.curnrg) {
|
||||||
ChatMessage.create( { content: `The Vehicle ${this.name} does not have enough Energy to Activate this module at this time.`})
|
ChatMessage.create({ content: `The Vehicle ${this.name} does not have enough Energy to Activate this module at this time.` })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
||||||
pc.actnrg += Number(mod.system.nrg)
|
pc.actnrg += Number(mod.system.nrg)
|
||||||
pc.maxnrg -= Number(mod.system.nrg)
|
pc.maxnrg -= Number(mod.system.nrg)
|
||||||
pc.curnrg -= Number(mod.system.nrg)
|
pc.curnrg -= Number(mod.system.nrg)
|
||||||
this.update({'system.statistics.pc': pc})
|
this.update({ 'system.statistics.pc': pc })
|
||||||
} else { // Now deactivated
|
} else { // Now deactivated
|
||||||
pc.actnrg -= Number(mod.system.nrg)
|
pc.actnrg -= Number(mod.system.nrg)
|
||||||
pc.maxnrg += Number(mod.system.nrg)
|
pc.maxnrg += Number(mod.system.nrg)
|
||||||
this.update({'system.statistics.pc': pc})
|
this.update({ 'system.statistics.pc': pc })
|
||||||
this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
this.updateEmbeddedDocuments('Item', [{ _id: mod.id, 'system.activated': !mod.system.activated }])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2196,23 +2222,23 @@ export class PegasusActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
setTurningArc( currentLevel) {
|
setTurningArc(currentLevel) {
|
||||||
this.update( { 'system.statistics.man.turningarc45': currentLevel })
|
this.update({ 'system.statistics.man.turningarc45': currentLevel })
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getCurrentCargoCapacity( ) {
|
getCurrentCargoCapacity() {
|
||||||
let capacity = 0
|
let capacity = 0
|
||||||
for (let cargo of this.items) {
|
for (let cargo of this.items) {
|
||||||
if (cargo.type == "equipment" || cargo.type == "weapon" || cargo.type == "armor" || cargo.type == "money" || cargo.type == "shield" ) {
|
if (cargo.type == "equipment" || cargo.type == "weapon" || cargo.type == "armor" || cargo.type == "money" || cargo.type == "shield") {
|
||||||
let q = cargo.system.quantity || 1
|
let q = cargo.system.quantity || 1
|
||||||
capacity += Number(q) * Number(cargo.system.weight)
|
capacity += Number(q) * Number(cargo.system.weight)
|
||||||
}
|
}
|
||||||
if (cargo.type == "cargo" ) {
|
if (cargo.type == "cargo") {
|
||||||
capacity += Number(cargo.system.capacity)
|
capacity += Number(cargo.system.capacity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return capacity
|
return capacity
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -995,7 +995,7 @@ export class PegasusUtility {
|
|||||||
icon: '<i class="fas fa-check"></i>',
|
icon: '<i class="fas fa-check"></i>',
|
||||||
label: "Yes, remove it",
|
label: "Yes, remove it",
|
||||||
callback: () => {
|
callback: () => {
|
||||||
actorSheet.actor.deleteEmbeddedDocuments("Item", [itemId]);
|
actorSheet.actor.deleteEmbeddedDocuments("Item", [itemId])
|
||||||
li.slideUp(200, () => actorSheet.render(false));
|
li.slideUp(200, () => actorSheet.render(false));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user