Fix #11 Speed management

This commit is contained in:
sladecraven 2022-09-25 15:13:59 +02:00
parent 241c7fa1ae
commit 52b7279cb8
2 changed files with 40 additions and 44 deletions

View File

@ -756,7 +756,7 @@ export class PegasusActor extends Actor {
subActors.push(subActorId);
await this.update({ 'system.subactors': subActors });
}
/* -------------------------------------------- */
async delSubActor(subActorId) {
let newArray = [];
@ -1394,31 +1394,31 @@ export class PegasusActor extends Actor {
let newItems = []
if (ability.system.effectsgained) {
for (let effect of ability.system.effectsgained) {
if (!effect.system) effect.system = effect.data
if (!effect.system) effect.system = effect.data
newItems.push(effect);
}
}
if (ability.system.powersgained) {
for (let power of ability.system.powersgained) {
if (!power.system) power.system = power.data
if (!power.system) power.system = power.data
newItems.push(power);
}
}
if (ability.system.specialisations) {
for (let spec of ability.system.specialisations) {
if (!spec.system) spec.system = spec.data
if (!spec.system) spec.system = spec.data
newItems.push(spec);
}
}
if (ability.system.attackgained) {
for (let weapon of ability.system.attackgained) {
if (!weapon.system) weapon.system = weapon.data
if (!weapon.system) weapon.system = weapon.data
newItems.push(weapon);
}
}
if (ability.system.armorgained) {
for (let armor of ability.system.armorgained) {
if (!armor.system) armor.system = armor.data
if (!armor.system) armor.system = armor.data
newItems.push(armor);
}
}
@ -1432,16 +1432,16 @@ export class PegasusActor extends Actor {
let newItems = []
await this.deleteAllItemsByType('race')
newItems.push(race);
console.log("DROPPED RACE", race)
for (let ability of race.system.abilities) {
if (!ability.system) ability.system = ability.data
if (!ability.system) ability.system = ability.data
newItems.push(ability)
this.applyAbility(ability, updates)
}
if (race.system.perksgained) {
for (let power of race.system.perks) {
if (!power.system) power.system = power.data
if (!power.system) power.system = power.data
newItems.push(power);
}
}
@ -1656,7 +1656,7 @@ export class PegasusActor extends Actor {
if (subKey == "ranged-dmg") {
this.addVehicleWeapons(rollData, vehicle)
}
if (subKey == "defense") {
if (subKey == "defence") {
if (vehicle.isVehicleFullStop()) {
ui.notifications.warn("MAN not added to Defense due to Full Stop.")
} else {
@ -1858,24 +1858,35 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
/* VEHICLE STUFF */
manageCurrentSpeed(speed) {
async manageCurrentSpeed(speed) {
// Delete any previous effect
let effect = this.items.find(effect => effect.system.isspeed != undefined)
if (effect) {
await this.deleteEmbeddedDocuments("Item", [effect.id])
}
if (speed == "fullstop") {
this.update({ 'system.secondary.moverange': "nomovement" })
}
if (speed == "crawling") {
this.update({ 'system.secondary.moverange': "threatzone" })
await this.update({ 'system.secondary.moverange': "threatzone" })
await this.manageVehicleSpeedBonus("crawling", "Crawling MAN Bonus", "man", 3)
}
if (speed == "slow") {
this.update({ 'system.secondary.moverange': "close" })
await this.update({ 'system.secondary.moverange': "close" })
await this.manageVehicleSpeedBonus("slow", "Slow MAN Bonus", "man", 1)
}
if (speed == "average") {
this.update({ 'system.secondary.moverange': "medium" })
await this.update({ 'system.secondary.moverange': "medium" })
await this.manageVehicleSpeedBonus("average", "Avoid attack Bonus", "all", 1)
}
if (speed == "fast") {
this.update({ 'system.secondary.moverange': "long" })
await this.update({ 'system.secondary.moverange': "long" })
await this.manageVehicleSpeedBonus("fast", "Avoid attack Bonus", "all", 3)
}
if (speed == "extfast") {
this.update({ 'system.secondary.moverange': "extreme" })
await this.update({ 'system.secondary.moverange': "extreme" })
await this.manageVehicleSpeedBonus("extfast", "Avoid attack Bonus", "all", 5)
}
}
@ -1894,22 +1905,14 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
manageVehicleSpeedBonus(speed, name, stat, level) {
if (this.system.statistics.ad.currentspeed == speed) {
if (!this.items.find(effect => effect.system.isspeed == speed)) {
let effect = duplicate(__bonusEffect)
effect.name = name
effect.system.stataffected = stat
effect.system.effectlevel = level
effect.system.isspeed = speed
this.createEmbeddedDocuments("Item", [effect])
}
} else {
let effect = this.items.find(effect => effect.system.isspeed == speed)
if (effect) {
this.deleteEmbeddedDocuments("Item", [effect.id])
}
}
async manageVehicleSpeedBonus(speed, name, stat, level) {
let effect = duplicate(__bonusEffect)
effect.id = randomID(16)
effect.name = name
effect.system.stataffected = stat
effect.system.effectlevel = level
effect.system.isspeed = speed
await this.createEmbeddedDocuments("Item", [effect])
}
/* -------------------------------------------- */
@ -1998,13 +2001,6 @@ export class PegasusActor extends Actor {
}
}
// Speed effect management
this.manageVehicleSpeedBonus("crawling", "Crawling MAN Bonus", "man", 3)
this.manageVehicleSpeedBonus("slow", "Slow MAN Bonus", "man", 1)
this.manageVehicleSpeedBonus("average", "Avoid attack Bonus", "all", 1)
this.manageVehicleSpeedBonus("fast", "Avoid attack Bonus", "all", 3)
this.manageVehicleSpeedBonus("extfast", "Avoid attack Bonus", "all", 5)
}
/* -------------------------------------------- */
@ -2066,10 +2062,10 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
addCrew(actorId) {
if ( this.system.crew.length >= this.system.crewmax) {
if (this.system.crew.length >= this.system.crewmax) {
ui.notifications.warn("Vehicle crew is already full.")
return
}
}
let crewList = duplicate(this.system.crew.filter(actorDef => actorDef.id != actorId) || [])
crewList.push({ id: actorId })
this.update({ 'system.crew': crewList })
@ -2127,7 +2123,7 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
addVehicleShields(rollData) {
let shields = this.items.filter( shield => shield.type == "vehiclemodule" && shield.system.activated && shield.system.shielddicevalue > 0) || []
let shields = this.items.filter(shield => shield.type == "vehiclemodule" && shield.system.activated && shield.system.shielddicevalue > 0) || []
for (let shield of shields) {
rollData.vehicleShieldList.push({ label: `${shield.name} (${shield.system.arccoverage})`, type: "vehicleshield", applied: false, value: shield.system.shielddicevalue })
}
@ -2141,7 +2137,7 @@ export class PegasusActor extends Actor {
let rollData = this.getCommonRollData("hr")
rollData.mode = "stat"
rollData.title = `Stat ${stat.label}`;
this.addVehicleShields(rollData)
this.startRoll(rollData)
}

View File

@ -215,7 +215,7 @@ export class PegasusVehicleSheet extends ActorSheet {
this.actor.rollPoolFromVehicle( 'per', false, "ranged-dmg");
});
html.find('.defense-roll').click((event) => {
this.actor.rollPoolFromVehicle( 'def', true, "defence");
this.actor.rollPoolFromVehicle( 'agi', true, "defence");
});
html.find('.damage-resistance').click((event) => {
this.actor.rollVehicleDamageResistance( );