Add weapons attacks

This commit is contained in:
2023-04-14 17:01:29 +02:00
parent 606271e725
commit 32b5868646
10 changed files with 218 additions and 137 deletions

View File

@@ -511,6 +511,13 @@ export class DarkStarsActor extends Actor {
return this.items.find(cond => cond.type == "condition" && cond.system.targetadvantage)
}
/* -------------------------------------------- */
modifyRerolls( value) {
let rerolls = duplicate(this.system.various.rerolls)
rerolls.value += value
this.update({ 'system.various.rerolls': rerolls })
}
/* -------------------------------------------- */
getCommonRollData(abilityKey = undefined) {
let noAction = this.isNoAction()
@@ -526,6 +533,8 @@ export class DarkStarsActor extends Actor {
rollData.img = this.img
rollData.armors = this.getArmors()
rollData.conditions = this.getConditions()
rollData.rerolls = this.system.various.rerolls.value
if (rollData.defenderTokenId) {
let defenderToken = game.canvas.tokens.get(rollData.defenderTokenId)
let defender = defenderToken.actor
@@ -597,20 +606,12 @@ export class DarkStarsActor extends Actor {
let skill = this.items.find(item => item.name.toLowerCase() == weapon.system.skill.toLowerCase())
if (skill) {
skill = duplicate(skill)
DarkStarsUtility.updateSkill(skill)
let abilityKey = skill.system.ability
let rollData = this.getCommonRollData(abilityKey)
this.updateSkill(skill)
let rollData = this.getCommonRollData()
rollData.mode = "weapon"
rollData.skill = skill
rollData.weapon = weapon
rollData.img = weapon.img
if (!rollData.forceDisadvantage) { // This is an attack, check if disadvantaged
rollData.forceDisadvantage = this.isAttackDisadvantage()
}
/*if (rollData.weapon.system.isranged && rollData.tokensDistance > DarkStarsUtility.getWeaponMaxRange(rollData.weapon) ) {
ui.notifications.warn(`Your target is out of range of your weapon (max: ${DarkStarsUtility.getWeaponMaxRange(rollData.weapon)} - current : ${rollData.tokensDistance})` )
return
}*/
this.startRoll(rollData)
} else {
ui.notifications.warn("Unable to find the relevant skill for weapon " + weapon.name)