From f73af2994995300df21e0d574feff8df6dbf8e57 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Wed, 21 Dec 2022 14:42:28 +0100 Subject: [PATCH] Various enhancements --- modules/avd12-actor.js | 32 +++++++++++++++++ modules/avd12-utility.js | 13 +++++++ styles/simple.css | 10 ++++-- template.json | 1 + templates/actors/actor-sheet.hbs | 34 ++++++++++--------- templates/items/item-shield-sheet.hbs | 9 +++++ .../items/partial-options-shield-types.hbs | 2 ++ 7 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 templates/items/partial-options-shield-types.hbs diff --git a/modules/avd12-actor.js b/modules/avd12-actor.js index 54a7aca..600b849 100644 --- a/modules/avd12-actor.js +++ b/modules/avd12-actor.js @@ -62,6 +62,9 @@ export class Avd12Actor extends Actor { /* -------------------------------------------- */ rebuildSkills() { + let armorPenalties = Avd12Utility.getArmorPenalty( this.items.find( item => item.type == "armor") ) + let shieldPenalties = Avd12Utility.getArmorPenalty( this.items.find( item => item.type == "shield") ) + for (let attrKey in this.system.attributes) { let attr = this.system.attributes[attrKey] for (let skillKey in attr.skills) { @@ -72,10 +75,38 @@ export class Avd12Actor extends Actor { for (let trait of availableTraits) { skill.modifier += Number(trait.system.bonusvalue) } + // Apply armor penalties + if ( armorPenalties[skillKey]) { + console.log("Found armor penalties : ", armorPenalties, skillKey) + skill.modifier += Number(armorPenalties[skillKey]) + } + // Apply shield penalties + if ( shieldPenalties[skillKey]) { + console.log("Found shield penalties : ", shieldPenalties, skillKey) + skill.modifier += Number(shieldPenalties[skillKey]) + } + // Process additionnal bonuses + for(let item of this.items) { + if (item.system.bonus && item.system.bonus[skillKey]) { + skill.modifier += Number(item.system.bonus[skillKey].value) + } + } skill.finalvalue = skill.modifier + attr.value } } } + + /* -------------------------------------------- */ + rebuildMitigations() { + for (let mitiKey in this.system.mitigation) { + let mitigation = this.system.mitigation[mitiKey] + for(let item of this.items) { + if (item.system.mitigation && item.system.mitigation[mitiKey]) { + mitigation.value += Number(item.system.mitigation[mitiKey].value) + } + } + } + } /* -------------------------------------------- */ prepareDerivedData() { @@ -86,6 +117,7 @@ export class Avd12Actor extends Actor { this.computeHitPoints() this.rebuildSkills() + this.rebuildMitigations() } super.prepareDerivedData(); diff --git a/modules/avd12-utility.js b/modules/avd12-utility.js index 16485df..d1cf67a 100644 --- a/modules/avd12-utility.js +++ b/modules/avd12-utility.js @@ -11,7 +11,11 @@ const __focusRegenBond = { "bondnone": 6, "bondeasy": 8, "bondcommon": 12, "bond const __bonusSpellDamageBond = { "bondnone": 0, "bondeasy": 1, "bondcommon": 1, "bonduncommon": 1, "bondrare": 2, "bondlegendary": 2, "bondmythic": 3, "bonddivine": 4 } const __bonusSpellAttackBond = { "bondnone": 0, "bondeasy": 0, "bondcommon": 1, "bonduncommon": 1, "bondrare": 2, "bondlegendary": 2, "bondmythic": 3, "bonddivine": 4 } const __spellCost = { "beginner": 1, "novice": 2, "expert": 4, "master": 6, "grandmaster": 8 } +const __armorPenalties = {"light": { block: -2, dodge: -1}, "medium": { dodge: -3, block: -2, castingtime: 1, stealth: -2, speed: -1, + "heavy": { dodge: -4, block: -3, stealth: -3, castingtime: 2, speed: -3 }, "ultraheavy": { dodge: -5, block: -4, stealth: -5, castingtime: 2, speed: -3 }, + "lightshield": {dodge: -1, block: +1}, "heavyshield": {dodge: -2, block: 2, speed: -1, stealth: -1} } +} /* -------------------------------------------- */ export class Avd12Utility { @@ -439,6 +443,15 @@ export class Avd12Utility { static getSpellCost(spell) { return __spellCost[spell.system.level] } + + /* -------------------------------------------- */ + static getArmorPenalty( item ) { + if (item && (item.type == "shield" || item.type == "armor")) { + return __armorPenalties[item.system.category] + } + return {} + } + /* -------------------------------------------- */ static chatDataSetup(content, modeOverride, isRoll = false, forceWhisper) { let chatData = { diff --git a/styles/simple.css b/styles/simple.css index d9f21be..83cc859 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -222,13 +222,14 @@ table {border: 1px solid #7a7971;} -webkit-box-flex: 0; -ms-flex: 0 0 128px; flex: 0 0 128px; - width: 196px; + width: 128px; height: auto; - max-height:260px; + max-height:160px; margin-top: 0px; margin-right: 10px; object-fit: cover; object-position: 50% 0; + border-width: 0px; } .button-img { @@ -1293,6 +1294,11 @@ ul, li { max-width: 6rem; min-width: 6rem; } +.item-field-skill { + flex-grow:1; + max-width: 6.8rem; + min-width: 6.8rem; +} .item-field-label-long { margin-top: 4px; flex-grow:1; diff --git a/template.json b/template.json index 0aeb99a..5b64475 100644 --- a/template.json +++ b/template.json @@ -457,6 +457,7 @@ "description": "" }, "shield": { + "category": "", "templates": [ "commonitem" ], diff --git a/templates/actors/actor-sheet.hbs b/templates/actors/actor-sheet.hbs index bb6d625..fe5aed0 100644 --- a/templates/actors/actor-sheet.hbs +++ b/templates/actors/actor-sheet.hbs @@ -17,7 +17,7 @@ {{#each attr.skills as |skill skillKey|}}
- {{upperFirst skillKey}} {{skill.finalvalue}} + {{upperFirst skillKey}} {{skill.finalvalue}}
{{/each}} @@ -69,20 +69,6 @@   - -
  • - Focus Regen - - - -   - - Focus Points - / - - -   -
  • @@ -156,6 +142,22 @@
    +
      +
    • + Focus Regen + + + +   + + Focus Points + / + + +   +
    • +
    +
    • @@ -174,7 +176,7 @@ - {{spell.name}} + {{spell.name}} {{upperFirst spell.system.spelltype}} {{upperFirst spell.system.level}} diff --git a/templates/items/item-shield-sheet.hbs b/templates/items/item-shield-sheet.hbs index d2df3eb..b8fa792 100644 --- a/templates/items/item-shield-sheet.hbs +++ b/templates/items/item-shield-sheet.hbs @@ -21,6 +21,15 @@ {{> systems/fvtt-avd12/templates/items/partial-common-item-fields.hbs}} +
    • + + +
    • +
    • diff --git a/templates/items/partial-options-shield-types.hbs b/templates/items/partial-options-shield-types.hbs new file mode 100644 index 0000000..38a4ec7 --- /dev/null +++ b/templates/items/partial-options-shield-types.hbs @@ -0,0 +1,2 @@ + +