diff --git a/modules/crucible-actor.js b/modules/crucible-actor.js index 32d9518..9fd51df 100644 --- a/modules/crucible-actor.js +++ b/modules/crucible-actor.js @@ -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 { diff --git a/modules/crucible-utility.js b/modules/crucible-utility.js index 89cbb4f..9a51535 100644 --- a/modules/crucible-utility.js +++ b/modules/crucible-utility.js @@ -532,7 +532,7 @@ export class CrucibleUtility { // advantage => 8 let advFormula = "+ 0d8cs>=5" - if (rollData.advantage == "advantage1") { + if (rollData.advantage == "advantage1" || rollData.forceAdvantage) { advFormula = "+ 1d8cs>=5" } if (rollData.advantage == "advantage2") { @@ -542,7 +542,7 @@ export class CrucibleUtility { // disadvantage => 10 let disFormula = "- 0d8cs>=5" - if (rollData.disadvantage == "disadvantage1") { + if (rollData.disadvantage == "disadvantage1" || rollData.forceDisadvantage) { disFormula = "- 1d8cs>=5" } if (rollData.disadvantage == "disadvantage2") { @@ -581,7 +581,14 @@ export class CrucibleUtility { rollData.rollOrder = 0 rollData.roll = myRoll rollData.nbSuccess = myRoll.total - if (rollData.rollAdvantage != "none") { + + if ( rollData.rollAdvantage == "none" && rollData.forceRollAdvantage) { + rollData.rollAdvantage = "roll-advantage" + } + if ( rollData.rollAdvantage == "none" && rollData.forceRollDisadvantage) { + rollData.rollAdvantage = "roll-disadvantage" + } + if (rollData.rollAdvantage != "none" ) { rollData.rollOrder = 1 rollData.rollType = (rollData.rollAdvantage == "roll-advantage") ? "Advantage": "Disadvantage" diff --git a/system.json b/system.json index 2e14bd0..c9477b4 100644 --- a/system.json +++ b/system.json @@ -1,6 +1,9 @@ { "authors": [ - {"name": "Uberwald"} + { + "name": "Uberwald", + "flags": {} + } ], "description": "Crucible RPG system for FoundryVTT", "esmodules": [ @@ -12,203 +15,182 @@ { "lang": "en", "name": "English", - "path": "lang/en.json" + "path": "lang/en.json", + "flags": {} } ], - "library": false, "license": "LICENSE.txt", - "media": [], - "name": "fvtt-crucible-rpg", "packs": [ { "type": "Item", "label": "Armors", "name": "armor", - "path": "./packs/armor.db", + "path": "packs/armor.db", "system": "fvtt-crucible-rpg", - "tags": [ - "armour" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Equipments", "name": "equipment", - "path": "./packs/equipment.db", + "path": "packs/equipment.db", "system": "fvtt-crucible-rpg", - "tags": [ - "equipment" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Shields", "name": "shields", - "path": "./packs/shields.db", + "path": "packs/shields.db", "system": "fvtt-crucible-rpg", - "tags": [ - "shield" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Weapons", "name": "weapons", - "path": "./packs/weapons.db", + "path": "packs/weapons.db", "system": "fvtt-crucible-rpg", - "tags": [ - "weapon", "melee", "ranged" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Conditions", "name": "conditions", - "path": "./packs/conditions.db", + "path": "packs/conditions.db", "system": "fvtt-crucible-rpg", - "tags": [ - "condition" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Currency", "name": "currency", - "path": "./packs/currency.db", + "path": "packs/currency.db", "system": "fvtt-crucible-rpg", - "tags": [ - "currency", "money" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Lore - Air", "name": "lore-air", - "path": "./packs/lore-air.db", + "path": "packs/lore-air.db", "system": "fvtt-crucible-rpg", - "tags": [ - "lore", "air" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Lore - Earth", "name": "lore-earth", - "path": "./packs/lore-earth.db", + "path": "packs/lore-earth.db", "system": "fvtt-crucible-rpg", - "tags": [ - "lore", "earth" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Lore - Fire", "name": "lore-fire", - "path": "./packs/lore-fire.db", + "path": "packs/lore-fire.db", "system": "fvtt-crucible-rpg", - "tags": [ - "lore", "fire" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Lore - Water", "name": "lore-water", - "path": "./packs/lore-water.db", + "path": "packs/lore-water.db", "system": "fvtt-crucible-rpg", - "tags": [ - "lore", "water" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Lore - Shadow", "name": "lore-shadow", - "path": "./packs/lore-shadow.db", + "path": "packs/lore-shadow.db", "system": "fvtt-crucible-rpg", - "tags": [ - "lore", "shadow" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Skills", "name": "skills", - "path": "./packs/skills.db", + "path": "packs/skills.db", "system": "fvtt-crucible-rpg", - "tags": [ - "skill" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Feats", "name": "feats", - "path": "./packs/feats.db", + "path": "packs/feats.db", "system": "fvtt-crucible-rpg", - "tags": [ - "feat" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Poisons", "name": "poisons", - "path": "./packs/poisons.db", + "path": "packs/poisons.db", "system": "fvtt-crucible-rpg", - "tags": [ - "poison" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Powers - Class", "name": "classpowers", - "path": "./packs/classpowers.db", + "path": "packs/classpowers.db", "system": "fvtt-crucible-rpg", - "tags": [ - "powers" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Tricks & Traps", "name": "trickstraps", - "path": "./packs/trickstraps.db", + "path": "packs/trickstraps.db", "system": "fvtt-crucible-rpg", - "tags": [ - "tricks", "traps" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Action Tokens", "name": "action-tokens", - "path": "./packs/action-tokens.db", + "path": "packs/action-tokens.db", "system": "fvtt-crucible-rpg", - "tags": [ - "action" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Powers - Monsters", "name": "monster-powers", - "path": "./packs/monster-powers.db", + "path": "packs/monster-powers.db", "system": "fvtt-crucible-rpg", - "tags": [ - "power" - ] + "private": false, + "flags": {} }, { "type": "RollTable", "label": "Rolltables", "name": "rolltables", - "path": "./packs/rolltables.db", + "path": "packs/rolltables.db", "system": "fvtt-crucible-rpg", - "tags": [ - "rolltable" - ] + "private": false, + "flags": {} } ], "primaryTokenAttribute": "secondary.hp", @@ -217,16 +199,16 @@ "styles": [ "styles/simple.css" ], - "version": "10.0.2", + "version": "10.0.3", "compatibility": { "minimum": "10", - "verified": "10.276", + "verified": "10.278", "maximum": "10" }, - "templateVersion": 20, "title": "Crucible RPG", "manifest": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/raw/master/system.json", "download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v10.0.2.zip", "url": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg", - "background" : "./images/ui/crucible_welcome_page.webp" -} + "background": "images/ui/crucible_welcome_page.webp", + "id": "fvtt-crucible-rpg" +} \ No newline at end of file diff --git a/templates/chat-generic-result.html b/templates/chat-generic-result.html index 29edb43..c209cf9 100644 --- a/templates/chat-generic-result.html +++ b/templates/chat-generic-result.html @@ -25,7 +25,7 @@
  • Roll with {{rollType}} - Roll 2
  • {{/if}} {{#if (eq rollOrder 3)}} -
  • Roll with advantage - Final result !
  • +
  • Roll with {{rollType}} - Final result !
  • {{/if}} {{#if save}} @@ -55,21 +55,26 @@ {{/if}} - {{#if (eq advantage "advantage1")}} -
  • 1 Advantage Die ! -  ({{#each roll.terms.8.results as |die idx|}} - {{die.result}}  - {{/each}}) -
  • + {{#if noAdvantage}} +
  • No advantage due to condition : {{noAdvantage.name}}
  • + {{else}} + {{#if (or (eq advantage "advantage1") forceAdvantage)}} +
  • 1 Advantage Die ! +  ({{#each roll.terms.8.results as |die idx|}} + {{die.result}}  + {{/each}}) +
  • + {{/if}} + {{#if (eq advantage "advantage2") }} +
  • 2 Advantage Dice ! +  ({{#each roll.terms.8.results as |die idx|}} + {{die.result}}  + {{/each}}) +
  • + {{/if}} {{/if}} - {{#if (eq advantage "advantage2")}} -
  • 2 Advantage Dice ! -  ({{#each roll.terms.8.results as |die idx|}} - {{die.result}}  - {{/each}}) -
  • - {{/if}} - {{#if (eq disadvantage "disadvantage1")}} + + {{#if (or (eq disadvantage "disadvantage1") forceDisadvantage)}}
  • 1 Disadvantage Die !  ({{#each roll.terms.10.results as |die idx|}} {{die.result}}  diff --git a/templates/roll-dialog-generic.html b/templates/roll-dialog-generic.html index fa24f29..080f15a 100644 --- a/templates/roll-dialog-generic.html +++ b/templates/roll-dialog-generic.html @@ -51,17 +51,23 @@ {{/if}} -
    - Advantage : - -
    - + {{#if noAdvantage}} +
    + No advantage due to condition : {{noAdvantage.name}} +
    + {{else}} +
    + Advantage : + +
    + {{/if}} +
    Disadvantage :
    + {{#if forceAdvantage}} +
    + 1 Advantage from condition : {{forceAdvantage.name}} + {{#if advantageFromTarget}} (Provided by targetted actor) {{/if}} + +
    + {{/if}} + {{#if forceDisadvantage}} +
    + 1 Disadvantage from condition : {{forceDisadvantage.name}} +
    + {{/if}} + {{#if forceRollAdvantage}} +
    + Roll Advantage from condition : {{forceRollAdvantage.name}} +
    + {{/if}} + {{#if forceRollDisadvantage}} +
    + Roll Disadvantage from condition : {{forceRollDisadvantage.name}} +
    + {{/if}} + + \ No newline at end of file