Fix #89 agitators hindrance

This commit is contained in:
sladecraven 2022-10-05 09:40:34 +02:00
parent ef740f4c0d
commit 5a062cc94e
2 changed files with 38 additions and 42 deletions

View File

@ -240,7 +240,7 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
getRoleLevel() {
let role = this.items.find(item => item.type == 'role')
if (role ) {
if (role) {
console.log("Role", role)
return role.system.rolelevel
}
@ -253,7 +253,7 @@ export class PegasusActor extends Actor {
return role && role.system.perksrole == "tactician"
}
hasTacticianBonus() {
let effect = this.items.find( item => item.name.toLowerCase().includes("tactician bonus dice") )
let effect = this.items.find(item => item.name.toLowerCase().includes("tactician bonus dice"))
return effect
}
async addTacticianEffect(name, level) {
@ -266,7 +266,7 @@ export class PegasusActor extends Actor {
ChatMessage.create({ content: `Tactician Bonus Dice has been added to ${this.name} (${level})` })
}
async removeTacticianEffect() {
let effect = this.items.find( item => item.name.toLowerCase().includes("tactician bonus dice") )
let effect = this.items.find(item => item.name.toLowerCase().includes("tactician bonus dice"))
if (effect) {
await this.deleteEmbeddedDocuments('Item', [effect.id])
ChatMessage.create({ content: `Tactician Bonus Dice has been removed to ${this.name}` })
@ -279,10 +279,10 @@ export class PegasusActor extends Actor {
return role && role.system.perksrole == "enhancer"
}
hasEnhancerBonus() {
let effect = this.items.find( item => item.name.toLowerCase().includes("enhancer bonus dice") )
let effect = this.items.find(item => item.name.toLowerCase().includes("enhancer bonus dice"))
return effect
}
async addEnhancerEffect( name, level) {
async addEnhancerEffect(name, level) {
let effect = duplicate(__bonusEffect)
effect.name = `${name} Enhancer Bonus Dice ALL`
effect.system.effectlevel = level
@ -292,7 +292,7 @@ export class PegasusActor extends Actor {
ChatMessage.create({ content: `Enhancer Bonus Dice has been added to ${this.name} (${level})` })
}
async removeEnhancerEffect() {
let effect = this.items.find( item => item.name.toLowerCase().includes("enhancer bonus dice") )
let effect = this.items.find(item => item.name.toLowerCase().includes("enhancer bonus dice"))
if (effect) {
await this.deleteEmbeddedDocuments('Item', [effect.id])
ChatMessage.create({ content: `Enhancer Bonus Dice has been removed to ${this.name}` })
@ -305,7 +305,7 @@ export class PegasusActor extends Actor {
return role && role.system.perksrole == "agitator"
}
hasAgitatorHindrance() {
let effect = this.items.find( item => item.name.toLowerCase().includes("hindered by agitator") )
let effect = this.items.find(item => item.name.toLowerCase().includes("hindered by agitator"))
return effect
}
async addAgitatorHindrance(name, level) {
@ -319,7 +319,7 @@ export class PegasusActor extends Actor {
ChatMessage.create({ content: `Agitator Hindrance has been added to ${this.name} (${level})` })
}
async removeAgitatorHindrance() {
let effect = this.items.find( item => item.name.toLowerCase().includes("hindered by agitator") )
let effect = this.items.find(item => item.name.toLowerCase().includes("hindered by agitator"))
if (effect) {
await this.deleteEmbeddedDocuments('Item', [effect.id])
ChatMessage.create({ content: `Agitator Hindrance has been removed to ${this.name}` })
@ -2025,6 +2025,13 @@ export class PegasusActor extends Actor {
console.log("MR ROLL", rollData)
if (isInit) {
rollData.title = "MR / Initiative"
rollData.mrVehicle = PegasusUtility.checkIsVehicleCrew(this.id)
if (rollData.mrVehicle) {
rollData.effectsList.push({
label: `Vehicle ${rollData.mrVehicle.name} MR Bonus`,
type: "effect", applied: false, isdynamic: true, value: rollData.mrVehicle.system.mr.currentlevel
})
}
}
this.startRoll(rollData);
} else {
@ -2299,7 +2306,6 @@ export class PegasusActor extends Actor {
return crew
}
/* -------------------------------------------- */
addCrew(actorId) {
if (this.system.crew.length >= this.system.crewmax) {
ui.notifications.warn("Vehicle crew is already full.")
@ -2309,11 +2315,13 @@ export class PegasusActor extends Actor {
crewList.push({ id: actorId })
this.update({ 'system.crew': crewList })
}
/* -------------------------------------------- */
delCrew(actorId) {
let crewList = duplicate(this.system.crew.filter(actorDef => actorDef.id != actorId) || [])
this.update({ 'system.crew': crewList })
}
inCrew(actorId) {
return this.system.crew.find(member => member.id == actorId)
}
/* -------------------------------------------- */
isVehicleFullStop() {

View File

@ -1027,7 +1027,12 @@ export class PegasusUtility {
if (target) {
let defenderActor = target.actor
rollData.defenderTokenId = target.id
rollData.defenderSize = 0
if ( defenderActor.type == "character") {
rollData.defenderSize = Number(defenderActor.system.biodata.sizenum) + Number(defenderActor.system.biodata.sizebonus)
} else if ( defenderActor.type == "vehicle" ){
rollData.defenderSize = Number(defenderActor.system.statistics.hr.size)
}
//rollData.attackerId = this.id
console.log("Target/DEFENDER", defenderActor)
defenderActor.addHindrancesList(rollData.effectsList)
@ -1068,31 +1073,14 @@ export class PegasusUtility {
}
/* -------------------------------------------- */
static glowToken(token) {
let params =
[{
filterType: "glow",
filterId: "superSpookyGlow",
outerStrength: 15,
innerStrength: 0,
color: 0x6AAB8E,
quality: 0.5,
padding: 40,
autoDestroy: true,
animated:
{
color:
{
active: true,
loopDuration: 3000,
loops: 2,
animType: "colorOscillation",
val1: 0x6AAB8E,
val2: 0x66FF33
static checkIsVehicleCrew(actorId) {
let vehicles = game.actors.filter( actor=> actor.type =="vehicle") || []
for(let vehicle of vehicles) {
if ( vehicle.inCrew(actorId) ) {
return vehicle
}
}
}]
TokenMagic.addUpdateFilters(token, params)
return false
}
/* -------------------------------------------- */