Fix #31 - Global perl select

This commit is contained in:
2022-11-26 16:03:11 +01:00
parent cc0dc9e43c
commit dad117fc17
4 changed files with 145 additions and 97 deletions

View File

@@ -194,12 +194,12 @@ export class PegasusActor extends Actor {
let comp = this.items.filter(item => item.type == 'vehiclemodule');
return comp;
}
getVehicleWeaponModules( activated = false ) {
getVehicleWeaponModules(activated = false) {
let comp = []
if (activated ) {
if (activated) {
comp = this.items.filter(item => item.type == 'vehicleweaponmodule' && item.system.activated)
} else {
comp = this.items.filter(item => item.type == 'vehicleweaponmodule' )
comp = this.items.filter(item => item.type == 'vehicleweaponmodule')
}
return comp;
}
@@ -280,6 +280,26 @@ export class PegasusActor extends Actor {
ChatMessage.create({ content: `Tactician Bonus Dice has been removed to ${this.name}`, whisper: ChatMessage.getWhisperRecipients('GM') })
}
}
/* -------------------------------------------- */
getStatus(statusKey) {
if ( statusKey == "nrg") {
return duplicate(this.system.nrg)
}
return duplicate(this.system.secondary[statusKey])
}
/* -------------------------------------------- */
async addStatusBonus(statusKey, value) {
let status = this.getStatus(statusKey)
let effect = duplicate(__bonusEffect)
effect.name = `${status.label} Creation Bonus`
effect.system.affectstatus = true
effect.system.affectedstatus = statusKey
effect.system.effectlevel = value
effect.system.bonusdice = false
effect.system.locked = true
await this.createEmbeddedDocuments('Item', [effect])
}
/* -------------------------------------------- */
isEnhancer() {
@@ -755,13 +775,13 @@ export class PegasusActor extends Actor {
ui.notifications.warn("Container is already full !")
return
} else {
this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'system.containerid':containerId }])
this.updateEmbeddedDocuments("Item", [{ _id: object.id, 'system.containerid': containerId }])
}
} else if (object && object.system.containerid) { // remove from container
this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'system.containerid':"" }])
this.updateEmbeddedDocuments("Item", [{ _id: object.id, 'system.containerid': "" }])
}
}
/* -------------------------------------------- */
checkVirtue(virtue) {
let vices = this.getVices()
@@ -794,7 +814,7 @@ export class PegasusActor extends Actor {
console.log("Pre-process", item)
if (!item) {
return
return
}
if (item.type != "effect" && __isVehicle[item.type]) {
ui.notifications.warn("You can't drop Vehicles item over a character sheet.")
@@ -1478,7 +1498,7 @@ export class PegasusActor extends Actor {
}
if (bonus != stat.bonuseffect) {
stat.bonuseffect = bonus
if ( stat.bonuseffect + stat.value < 1) {
if (stat.bonuseffect + stat.value < 1) {
stat.value = 1
stat.bonuseffect = 0
}
@@ -1536,6 +1556,19 @@ export class PegasusActor extends Actor {
await this.update({ [`data.statistics.${key}`]: stat })
}
/* -------------------------------------------- */
async modStatus(key, inc = 1) {
if ( key == "nrg") {
let nrg = duplicate(this.system.nrg)
nrg.mod += parseInt(inc)
await this.update({ [`data.nrg`]: nrg })
} else {
let status = duplicate(this.system.secondary[key])
status.bonus += parseInt(inc)
await this.update({ [`data.secondary.${key}`]: status })
}
}
/* -------------------------------------------- */
async addIncSpec(spec, inc = 1) {
console.log("Using spec : ", spec, inc)
@@ -1853,10 +1886,10 @@ export class PegasusActor extends Actor {
ChatMessage.create({ content: `${vehicle.name} is moving at Slow speed : add a D4 to your Attack Dice Pool against this Vehicle` })
}
}
if (this.type == "vehicle" && rollData.statKey == "man" && this.system.statistics.ad.currentspeed == "fast") {
if (this.type == "vehicle" && rollData.statKey == "man" && this.system.statistics.ad.currentspeed == "fast") {
ChatMessage.create({ content: `${this.name} is moving at Fast speed : anyone using the vehicles MAN Dice Pool suffers a D8 Hindrance which is added to the Difficulty Dice Pool against this Vehicle` })
}
if (this.type == "vehicle" && rollData.statKey == "man" && this.system.statistics.ad.currentspeed == "extfast") {
if (this.type == "vehicle" && rollData.statKey == "man" && this.system.statistics.ad.currentspeed == "extfast") {
ChatMessage.create({ content: `${this.name} is moving at Extremely Fast speed : anyone using the vehicles MAN Dice Pool suffers a D12 Hindrance which is added to the Difficulty Dice Pool against this Vehicle` })
}
if (rollData.subKey == "defence" && rollData.vehicle && rollData.vehicle.system.statistics.ad.currentspeed == "crawling") {
@@ -1865,7 +1898,7 @@ export class PegasusActor extends Actor {
if (rollData.subKey == "defence" && rollData.vehicle && rollData.vehicle.system.statistics.ad.currentspeed == "slow") {
ChatMessage.create({ content: `${this.name} is moving at Slow speed : add a D4 to your Attack Dice Pool against this Vehicle` })
}
}
}
}
/* -------------------------------------------- */
@@ -2257,15 +2290,15 @@ export class PegasusActor extends Actor {
}
if (bonus != stat.bonuseffect) {
stat.bonuseffect = bonus
if ( stat.bonuseffect + stat.level < 1) {
if (stat.bonuseffect + stat.level < 1) {
stat.level = 1
stat.bonuseffect = 0
}
if (stat.currentlevel > stat.bonuseffect+stat.level) {
stat.currentlevel = stat.bonuseffect+stat.level
if (stat.currentlevel > stat.bonuseffect + stat.level) {
stat.currentlevel = stat.bonuseffect + stat.level
}
this.update({ [`system.statistics.${statKey}`]: stat })
}
}
}
}
@@ -2409,12 +2442,12 @@ export class PegasusActor extends Actor {
}
}
// NRG max management
if (item.type == "powercoremodule" ) {
if (this.system.statistics.pc.maxnrg != item.system.nrg ) {
this.update( {'system.statistics.pc.maxnrg': item.system.nrg })
if (item.type == "powercoremodule") {
if (this.system.statistics.pc.maxnrg != item.system.nrg) {
this.update({ 'system.statistics.pc.maxnrg': item.system.nrg })
}
}
// Cargo management
if (__isVehicleCargo[item.type]) {
let capacity = this.getCurrentCargoCapacity()
@@ -2545,7 +2578,7 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
async addVehicleModuleEffects( mod) {
async addVehicleModuleEffects(mod) {
let effects = []
for (let effect of mod.system.effects) {
if (!effect.system) {
@@ -2559,7 +2592,7 @@ export class PegasusActor extends Actor {
}
}
/* -------------------------------------------- */
async removeVehicleModuleEffects( mod) {
async removeVehicleModuleEffects(mod) {
let toRem = []
for (let item of this.items) {
if (item.type == 'effect' && item.system.effectId == mod.id) {
@@ -2597,7 +2630,7 @@ export class PegasusActor extends Actor {
this.removeVehicleModuleEffects(mod)
}
} else {
if ( mod.system.activated) {
if (mod.system.activated) {
this.removeVehicleModuleEffects(mod)
} else {
this.addVehicleModuleEffects(mod)
@@ -2627,7 +2660,7 @@ export class PegasusActor extends Actor {
let lvChanged = level - arc.maxshieldlevel
arc.maxshieldlevel = level
arc.shieldlevel += lvChanged
if ( arc.shieldlevel <= 0 || arc.shieldlevel > level) {
if (arc.shieldlevel <= 0 || arc.shieldlevel > level) {
arc.shieldlevel = level
}
setTimeout(shift, this.update({ [`system.arcs.${arcKey}`]: arc }))
@@ -2650,7 +2683,7 @@ export class PegasusActor extends Actor {
let lvChanged = level - arc.maxarmourlevel
arc.maxarmourlevel = level
arc.armourlevel += lvChanged
if ( arc.armourlevel <= 0 || arc.armourlevel > arc.maxarmourlevel) {
if (arc.armourlevel <= 0 || arc.armourlevel > arc.maxarmourlevel) {
arc.armourlevel = level
}
setTimeout(500, this.update({ [`system.arcs.${arcKey}`]: arc }))
@@ -2659,7 +2692,7 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
updateMaxNrg(currentLevel) {
this.update({ 'system.statistics.pc.maxnrg': Number( PegasusUtility.getDiceValue(currentLevel) ) })
this.update({ 'system.statistics.pc.maxnrg': Number(PegasusUtility.getDiceValue(currentLevel)) })
}
/* -------------------------------------------- */
setTurningArc(currentLevel) {