Manage conditions

This commit is contained in:
sladecraven 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) { 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() let rollData = CrucibleUtility.getBasicRollData()
rollData.alias = this.name rollData.alias = this.name
rollData.actorImg = this.img rollData.actorImg = this.img
@ -509,15 +544,27 @@ export class CrucibleActor extends Actor {
rollData.featsDie = this.getFeatsWithDie() rollData.featsDie = this.getFeatsWithDie()
rollData.featsSL = this.getFeatsWithSL() rollData.featsSL = this.getFeatsWithSL()
rollData.armors = this.getArmors() rollData.armors = this.getArmors()
rollData.conditions = this.getConditions()
rollData.featDieName = "none" rollData.featDieName = "none"
rollData.featSLName = "none" rollData.featSLName = "none"
rollData.rollAdvantage = "none" rollData.rollAdvantage = "none"
rollData.advantage = "none" rollData.advantage = "none"
rollData.disadvantage = "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) { if (abilityKey) {
rollData.ability = this.getAbility(abilityKey) rollData.ability = this.getAbility(abilityKey)
//rollData.skillList = this.getRelevantSkill(abilityKey)
rollData.selectedKill = undefined rollData.selectedKill = undefined
} }
@ -575,7 +622,9 @@ export class CrucibleActor extends Actor {
rollData.skill = skill rollData.skill = skill
rollData.weapon = weapon rollData.weapon = weapon
rollData.img = weapon.img rollData.img = weapon.img
if ( !rollData.forceDisadvantage) { // This is an attack, check if disadvantaged
rollData.forceDisadvantage = this.isAttackDisadvantage()
}
this.startRoll(rollData) this.startRoll(rollData)
} else { } else {
ui.notifications.warn("Unable to find the relevant skill for weapon " + weapon.name) 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.skill = skill
rollData.weapon = weapon rollData.weapon = weapon
rollData.img = weapon.img rollData.img = weapon.img
if ( !rollData.forceDisadvantage) { // This is an attack, check if disadvantaged
rollData.forceDisadvantage = this.isDefenseDisadvantage()
}
this.startRoll(rollData) this.startRoll(rollData)
} else { } else {

View File

@ -532,7 +532,7 @@ export class CrucibleUtility {
// advantage => 8 // advantage => 8
let advFormula = "+ 0d8cs>=5" let advFormula = "+ 0d8cs>=5"
if (rollData.advantage == "advantage1") { if (rollData.advantage == "advantage1" || rollData.forceAdvantage) {
advFormula = "+ 1d8cs>=5" advFormula = "+ 1d8cs>=5"
} }
if (rollData.advantage == "advantage2") { if (rollData.advantage == "advantage2") {
@ -542,7 +542,7 @@ export class CrucibleUtility {
// disadvantage => 10 // disadvantage => 10
let disFormula = "- 0d8cs>=5" let disFormula = "- 0d8cs>=5"
if (rollData.disadvantage == "disadvantage1") { if (rollData.disadvantage == "disadvantage1" || rollData.forceDisadvantage) {
disFormula = "- 1d8cs>=5" disFormula = "- 1d8cs>=5"
} }
if (rollData.disadvantage == "disadvantage2") { if (rollData.disadvantage == "disadvantage2") {
@ -581,7 +581,14 @@ export class CrucibleUtility {
rollData.rollOrder = 0 rollData.rollOrder = 0
rollData.roll = myRoll rollData.roll = myRoll
rollData.nbSuccess = myRoll.total 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.rollOrder = 1
rollData.rollType = (rollData.rollAdvantage == "roll-advantage") ? "Advantage": "Disadvantage" rollData.rollType = (rollData.rollAdvantage == "roll-advantage") ? "Advantage": "Disadvantage"

View File

@ -1,6 +1,9 @@
{ {
"authors": [ "authors": [
{"name": "Uberwald"} {
"name": "Uberwald",
"flags": {}
}
], ],
"description": "Crucible RPG system for FoundryVTT", "description": "Crucible RPG system for FoundryVTT",
"esmodules": [ "esmodules": [
@ -12,203 +15,182 @@
{ {
"lang": "en", "lang": "en",
"name": "English", "name": "English",
"path": "lang/en.json" "path": "lang/en.json",
"flags": {}
} }
], ],
"library": false,
"license": "LICENSE.txt", "license": "LICENSE.txt",
"media": [],
"name": "fvtt-crucible-rpg",
"packs": [ "packs": [
{ {
"type": "Item", "type": "Item",
"label": "Armors", "label": "Armors",
"name": "armor", "name": "armor",
"path": "./packs/armor.db", "path": "packs/armor.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"armour" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Equipments", "label": "Equipments",
"name": "equipment", "name": "equipment",
"path": "./packs/equipment.db", "path": "packs/equipment.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"equipment" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Shields", "label": "Shields",
"name": "shields", "name": "shields",
"path": "./packs/shields.db", "path": "packs/shields.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"shield" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Weapons", "label": "Weapons",
"name": "weapons", "name": "weapons",
"path": "./packs/weapons.db", "path": "packs/weapons.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"weapon", "melee", "ranged" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Conditions", "label": "Conditions",
"name": "conditions", "name": "conditions",
"path": "./packs/conditions.db", "path": "packs/conditions.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"condition" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Currency", "label": "Currency",
"name": "currency", "name": "currency",
"path": "./packs/currency.db", "path": "packs/currency.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"currency", "money" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Lore - Air", "label": "Lore - Air",
"name": "lore-air", "name": "lore-air",
"path": "./packs/lore-air.db", "path": "packs/lore-air.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"lore", "air" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Lore - Earth", "label": "Lore - Earth",
"name": "lore-earth", "name": "lore-earth",
"path": "./packs/lore-earth.db", "path": "packs/lore-earth.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"lore", "earth" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Lore - Fire", "label": "Lore - Fire",
"name": "lore-fire", "name": "lore-fire",
"path": "./packs/lore-fire.db", "path": "packs/lore-fire.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"lore", "fire" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Lore - Water", "label": "Lore - Water",
"name": "lore-water", "name": "lore-water",
"path": "./packs/lore-water.db", "path": "packs/lore-water.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"lore", "water" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Lore - Shadow", "label": "Lore - Shadow",
"name": "lore-shadow", "name": "lore-shadow",
"path": "./packs/lore-shadow.db", "path": "packs/lore-shadow.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"lore", "shadow" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Skills", "label": "Skills",
"name": "skills", "name": "skills",
"path": "./packs/skills.db", "path": "packs/skills.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"skill" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Feats", "label": "Feats",
"name": "feats", "name": "feats",
"path": "./packs/feats.db", "path": "packs/feats.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"feat" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Poisons", "label": "Poisons",
"name": "poisons", "name": "poisons",
"path": "./packs/poisons.db", "path": "packs/poisons.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"poison" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Powers - Class", "label": "Powers - Class",
"name": "classpowers", "name": "classpowers",
"path": "./packs/classpowers.db", "path": "packs/classpowers.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"powers" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Tricks & Traps", "label": "Tricks & Traps",
"name": "trickstraps", "name": "trickstraps",
"path": "./packs/trickstraps.db", "path": "packs/trickstraps.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"tricks", "traps" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Action Tokens", "label": "Action Tokens",
"name": "action-tokens", "name": "action-tokens",
"path": "./packs/action-tokens.db", "path": "packs/action-tokens.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"action" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Powers - Monsters", "label": "Powers - Monsters",
"name": "monster-powers", "name": "monster-powers",
"path": "./packs/monster-powers.db", "path": "packs/monster-powers.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"power" "flags": {}
]
}, },
{ {
"type": "RollTable", "type": "RollTable",
"label": "Rolltables", "label": "Rolltables",
"name": "rolltables", "name": "rolltables",
"path": "./packs/rolltables.db", "path": "packs/rolltables.db",
"system": "fvtt-crucible-rpg", "system": "fvtt-crucible-rpg",
"tags": [ "private": false,
"rolltable" "flags": {}
]
} }
], ],
"primaryTokenAttribute": "secondary.hp", "primaryTokenAttribute": "secondary.hp",
@ -217,16 +199,16 @@
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"
], ],
"version": "10.0.2", "version": "10.0.3",
"compatibility": { "compatibility": {
"minimum": "10", "minimum": "10",
"verified": "10.276", "verified": "10.278",
"maximum": "10" "maximum": "10"
}, },
"templateVersion": 20,
"title": "Crucible RPG", "title": "Crucible RPG",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/raw/master/system.json", "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", "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", "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"
}

View File

@ -25,7 +25,7 @@
<li><strong>Roll with {{rollType}} - Roll 2</strong></li> <li><strong>Roll with {{rollType}} - Roll 2</strong></li>
{{/if}} {{/if}}
{{#if (eq rollOrder 3)}} {{#if (eq rollOrder 3)}}
<li><strong>Roll with advantage - Final result !</strong></li> <li><strong>Roll with {{rollType}} - Final result !</strong></li>
{{/if}} {{/if}}
{{#if save}} {{#if save}}
@ -55,21 +55,26 @@
</li> </li>
{{/if}} {{/if}}
{{#if (eq advantage "advantage1")}} {{#if noAdvantage}}
<li>1 Advantage Die ! <li>No advantage due to condition : {{noAdvantage.name}}</li>
&nbsp;({{#each roll.terms.8.results as |die idx|}} {{else}}
{{die.result}}&nbsp; {{#if (or (eq advantage "advantage1") forceAdvantage)}}
{{/each}}) <li>1 Advantage Die !
</li> &nbsp;({{#each roll.terms.8.results as |die idx|}}
{{die.result}}&nbsp;
{{/each}})
</li>
{{/if}}
{{#if (eq advantage "advantage2") }}
<li>2 Advantage Dice !
&nbsp;({{#each roll.terms.8.results as |die idx|}}
{{die.result}}&nbsp;
{{/each}})
</li>
{{/if}}
{{/if}} {{/if}}
{{#if (eq advantage "advantage2")}}
<li>2 Advantage Dice ! {{#if (or (eq disadvantage "disadvantage1") forceDisadvantage)}}
&nbsp;({{#each roll.terms.8.results as |die idx|}}
{{die.result}}&nbsp;
{{/each}})
</li>
{{/if}}
{{#if (eq disadvantage "disadvantage1")}}
<li>1 Disadvantage Die ! <li>1 Disadvantage Die !
&nbsp;({{#each roll.terms.10.results as |die idx|}} &nbsp;({{#each roll.terms.10.results as |die idx|}}
{{die.result}}&nbsp; {{die.result}}&nbsp;

View File

@ -51,17 +51,23 @@
</div> </div>
{{/if}} {{/if}}
<div class="flexrow"> {{#if noAdvantage}}
<span class="roll-dialog-label">Advantage : </span> <div>
<select class="status-small-label color-class-common" type="text" id="advantage" value="{{advantage}}" data-dtype="String" > <span class="roll-dialog-label">No advantage due to condition : {{noAdvantage.name}}</span>
{{#select advantage}} </div>
<option value="none">None</option> {{else}}
<option value="advantage1">1 Advantage</option> <div class="flexrow">
<option value="advantage2">2 Advantages</option> <span class="roll-dialog-label">Advantage : </span>
{{/select}} <select class="status-small-label color-class-common" type="text" id="advantage" value="{{advantage}}" data-dtype="String" >
</select> {{#select advantage}}
</div> <option value="none">None</option>
<option value="advantage1">1 Advantage</option>
<option value="advantage2">2 Advantages</option>
{{/select}}
</select>
</div>
{{/if}}
<div class="flexrow"> <div class="flexrow">
<span class="roll-dialog-label">Disadvantage : </span> <span class="roll-dialog-label">Disadvantage : </span>
<select class="status-small-label color-class-common" type="text" id="disadvantage" value="{{disadvantage}}" data-dtype="String" > <select class="status-small-label color-class-common" type="text" id="disadvantage" value="{{disadvantage}}" data-dtype="String" >
@ -84,6 +90,30 @@
</select> </select>
</div> </div>
{{#if forceAdvantage}}
<div class="flexrow">
<span class="roll-dialog-label">1 Advantage from condition : {{forceAdvantage.name}}
{{#if advantageFromTarget}} (Provided by targetted actor) {{/if}}
</span>
</div>
{{/if}}
{{#if forceDisadvantage}}
<div class="flexrow">
<span class="roll-dialog-label">1 Disadvantage from condition : {{forceDisadvantage.name}} </span>
</div>
{{/if}}
{{#if forceRollAdvantage}}
<div class="flexrow">
<span class="roll-dialog-label">Roll Advantage from condition : {{forceRollAdvantage.name}} </span>
</div>
{{/if}}
{{#if forceRollDisadvantage}}
<div class="flexrow">
<span class="roll-dialog-label">Roll Disadvantage from condition : {{forceRollDisadvantage.name}} </span>
</div>
{{/if}}
</div> </div>
</form> </form>