Manage conditions

This commit is contained in:
2022-08-17 17:07:45 +02:00
parent 66f70897ed
commit aab562bed9
5 changed files with 193 additions and 117 deletions

View File

@ -499,8 +499,43 @@ export class CrucibleActor extends Actor {
}
}
/* -------------------------------------------- */
isForcedAdvantage() {
return this.items.find(cond => cond.type =="condition" && cond.system.advantage)
}
isForcedDisadvantage() {
return this.items.find(cond => cond.type =="condition" && cond.system.disadvantage)
}
isForcedRollAdvantage() {
return this.items.find(cond => cond.type =="condition" && cond.system.rolladvantage)
}
isForcedRollDisadvantage() {
return this.items.find(cond => cond.type =="condition" && cond.system.rolldisadvantage)
}
isNoAdvantage() {
return this.items.find(cond => cond.type =="condition" && cond.system.noadvantage)
}
isNoAction() {
return this.items.find(cond => cond.type =="condition" && cond.system.noaction)
}
isAttackDisadvantage() {
return this.items.find(cond => cond.type =="condition" && cond.system.attackdisadvantage)
}
isDefenseDisadvantage() {
return this.items.find(cond => cond.type =="condition" && cond.system.defensedisadvantage)
}
isAttackerAdvantage() {
return this.items.find(cond => cond.type =="condition" && cond.system.targetadvantage)
}
/* -------------------------------------------- */
getCommonRollData(abilityKey = undefined) {
let noAction = this.isNoAction()
if ( noAction) {
ui.notifications.warn("You can't do any actions du to the condition : " + noAction.name )
return
}
let rollData = CrucibleUtility.getBasicRollData()
rollData.alias = this.name
rollData.actorImg = this.img
@ -509,15 +544,27 @@ export class CrucibleActor extends Actor {
rollData.featsDie = this.getFeatsWithDie()
rollData.featsSL = this.getFeatsWithSL()
rollData.armors = this.getArmors()
rollData.conditions = this.getConditions()
rollData.featDieName = "none"
rollData.featSLName = "none"
rollData.rollAdvantage = "none"
rollData.advantage = "none"
rollData.disadvantage = "none"
rollData.forceAdvantage = this.isForcedAdvantage()
rollData.forceDisadvantage = this.isForcedDisadvantage()
rollData.forceRollAdvantage = this.isForcedRollAdvantage()
rollData.forceRollDisadvantage = this.isForcedRollDisadvantage()
rollData.noAdvantage = this.isNoAdvantage()
if ( rollData.defenderTokenId) {
let defender = game.canvas.tokens.get(rollData.defenderTokenId).actor
if (defender ) {
rollData.forceAdvantage = defender.isAttackerAdvantage()
rollData.advantageFromTarget = true
}
}
if (abilityKey) {
rollData.ability = this.getAbility(abilityKey)
//rollData.skillList = this.getRelevantSkill(abilityKey)
rollData.selectedKill = undefined
}
@ -575,7 +622,9 @@ export class CrucibleActor extends Actor {
rollData.skill = skill
rollData.weapon = weapon
rollData.img = weapon.img
if ( !rollData.forceDisadvantage) { // This is an attack, check if disadvantaged
rollData.forceDisadvantage = this.isAttackDisadvantage()
}
this.startRoll(rollData)
} else {
ui.notifications.warn("Unable to find the relevant skill for weapon " + weapon.name)
@ -601,6 +650,9 @@ export class CrucibleActor extends Actor {
rollData.skill = skill
rollData.weapon = weapon
rollData.img = weapon.img
if ( !rollData.forceDisadvantage) { // This is an attack, check if disadvantaged
rollData.forceDisadvantage = this.isDefenseDisadvantage()
}
this.startRoll(rollData)
} else {