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() { getRoleLevel() {
let role = this.items.find(item => item.type == 'role') let role = this.items.find(item => item.type == 'role')
if (role ) { if (role) {
console.log("Role", role) console.log("Role", role)
return role.system.rolelevel return role.system.rolelevel
} }
@ -253,23 +253,23 @@ export class PegasusActor extends Actor {
return role && role.system.perksrole == "tactician" return role && role.system.perksrole == "tactician"
} }
hasTacticianBonus() { 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 return effect
} }
async addTacticianEffect(name, level) { async addTacticianEffect(name, level) {
let effect = duplicate(__bonusEffect) let effect = duplicate(__bonusEffect)
effect.name = `${name} Tactician Bonus Dice` effect.name = `${name} Tactician Bonus Dice`
effect.system.effectlevel = level effect.system.effectlevel = level
effect.system.stataffected = "mr" effect.system.stataffected = "mr"
effect.system.bonusdice = true effect.system.bonusdice = true
await this.createEmbeddedDocuments('Item', [effect]) await this.createEmbeddedDocuments('Item', [effect])
ChatMessage.create({ content: `Tactician Bonus Dice has been added to ${this.name} (${level})` }) ChatMessage.create({ content: `Tactician Bonus Dice has been added to ${this.name} (${level})` })
} }
async removeTacticianEffect() { 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) { if (effect) {
await this.deleteEmbeddedDocuments('Item', [effect.id]) await this.deleteEmbeddedDocuments('Item', [effect.id])
ChatMessage.create({ content: `Tactician Bonus Dice has been removed to ${this.name}` }) ChatMessage.create({ content: `Tactician Bonus Dice has been removed to ${this.name}` })
} }
} }
@ -279,23 +279,23 @@ export class PegasusActor extends Actor {
return role && role.system.perksrole == "enhancer" return role && role.system.perksrole == "enhancer"
} }
hasEnhancerBonus() { 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 return effect
} }
async addEnhancerEffect( name, level) { async addEnhancerEffect(name, level) {
let effect = duplicate(__bonusEffect) let effect = duplicate(__bonusEffect)
effect.name = `${name} Enhancer Bonus Dice ALL` effect.name = `${name} Enhancer Bonus Dice ALL`
effect.system.effectlevel = level effect.system.effectlevel = level
effect.system.stataffected = "all" effect.system.stataffected = "all"
effect.system.bonusdice = true effect.system.bonusdice = true
await this.createEmbeddedDocuments('Item', [effect]) await this.createEmbeddedDocuments('Item', [effect])
ChatMessage.create({ content: `Enhancer Bonus Dice has been added to ${this.name} (${level})` }) ChatMessage.create({ content: `Enhancer Bonus Dice has been added to ${this.name} (${level})` })
} }
async removeEnhancerEffect() { 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) { if (effect) {
await this.deleteEmbeddedDocuments('Item', [effect.id]) await this.deleteEmbeddedDocuments('Item', [effect.id])
ChatMessage.create({ content: `Enhancer Bonus Dice has been removed to ${this.name}` }) ChatMessage.create({ content: `Enhancer Bonus Dice has been removed to ${this.name}` })
} }
} }
@ -305,13 +305,13 @@ export class PegasusActor extends Actor {
return role && role.system.perksrole == "agitator" return role && role.system.perksrole == "agitator"
} }
hasAgitatorHindrance() { 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 return effect
} }
async addAgitatorHindrance(name, level) { async addAgitatorHindrance(name, level) {
let effect = duplicate(__bonusEffect) let effect = duplicate(__bonusEffect)
effect.name = `Hindered by Agitator ${name}` effect.name = `Hindered by Agitator ${name}`
effect.system.effectlevel = level effect.system.effectlevel = level
effect.system.stataffected = "all" effect.system.stataffected = "all"
effect.system.genre = "negative" effect.system.genre = "negative"
effect.system.hindrance = true effect.system.hindrance = true
@ -319,10 +319,10 @@ export class PegasusActor extends Actor {
ChatMessage.create({ content: `Agitator Hindrance has been added to ${this.name} (${level})` }) ChatMessage.create({ content: `Agitator Hindrance has been added to ${this.name} (${level})` })
} }
async removeAgitatorHindrance() { 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) { if (effect) {
await this.deleteEmbeddedDocuments('Item', [effect.id]) await this.deleteEmbeddedDocuments('Item', [effect.id])
ChatMessage.create({ content: `Agitator Hindrance has been removed to ${this.name}` }) 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) console.log("MR ROLL", rollData)
if (isInit) { if (isInit) {
rollData.title = "MR / Initiative" 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); this.startRoll(rollData);
} else { } else {
@ -2299,7 +2306,6 @@ export class PegasusActor extends Actor {
return crew return crew
} }
/* -------------------------------------------- */
addCrew(actorId) { 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.") ui.notifications.warn("Vehicle crew is already full.")
@ -2309,11 +2315,13 @@ export class PegasusActor extends Actor {
crewList.push({ id: actorId }) crewList.push({ id: actorId })
this.update({ 'system.crew': crewList }) this.update({ 'system.crew': crewList })
} }
/* -------------------------------------------- */
delCrew(actorId) { delCrew(actorId) {
let crewList = duplicate(this.system.crew.filter(actorDef => actorDef.id != actorId) || []) let crewList = duplicate(this.system.crew.filter(actorDef => actorDef.id != actorId) || [])
this.update({ 'system.crew': crewList }) this.update({ 'system.crew': crewList })
} }
inCrew(actorId) {
return this.system.crew.find(member => member.id == actorId)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
isVehicleFullStop() { isVehicleFullStop() {

View File

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