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) {
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 {

View File

@ -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"

View File

@ -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"
}

View File

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

View File

@ -51,6 +51,11 @@
</div>
{{/if}}
{{#if noAdvantage}}
<div>
<span class="roll-dialog-label">No advantage due to condition : {{noAdvantage.name}}</span>
</div>
{{else}}
<div class="flexrow">
<span class="roll-dialog-label">Advantage : </span>
<select class="status-small-label color-class-common" type="text" id="advantage" value="{{advantage}}" data-dtype="String" >
@ -61,6 +66,7 @@
{{/select}}
</select>
</div>
{{/if}}
<div class="flexrow">
<span class="roll-dialog-label">Disadvantage : </span>
@ -84,6 +90,30 @@
</select>
</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>
</form>