From 732d51b8b3655ef0f53def15a01b9d3e0a1c5a95 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Mon, 25 Jul 2022 21:33:00 +0200 Subject: [PATCH] Data model change --- modules/crucible-actor-sheet.js | 28 +- modules/crucible-actor.js | 31 ++- modules/crucible-utility.js | 40 +-- styles/simple.css | 23 +- templates/actor-sheet.html | 383 ++-------------------------- templates/chat-generic-result.html | 34 +-- templates/partial-actor-status.html | 67 ----- 7 files changed, 73 insertions(+), 533 deletions(-) diff --git a/modules/crucible-actor-sheet.js b/modules/crucible-actor-sheet.js index cef15b8..383e617 100644 --- a/modules/crucible-actor-sheet.js +++ b/modules/crucible-actor-sheet.js @@ -16,7 +16,7 @@ export class CrucibleActorSheet extends ActorSheet { template: "systems/fvtt-crucible-rpg/templates/actor-sheet.html", width: 960, height: 720, - tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "combat" }], + tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "skills" }], dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }], editScore: true }); @@ -213,29 +213,15 @@ export class CrucibleActorSheet extends ActorSheet { this.actor.rollPool( 'phy', false, "dmg-res"); }); - html.find('.roll-stat').click((event) => { - const statId = $(event.currentTarget).data("stat-key"); - this.actor.rollStat(statId); + html.find('.roll-ability').click((event) => { + const abilityKey = $(event.currentTarget).data("ability-key"); + this.actor.rollAbility(abilityKey); }); - html.find('.roll-mr').click((event) => { - this.actor.rollMR(); - }); - html.find('.roll-idr').click((event) => { - const diceValue = $(event.currentTarget).data("dice-value") - const li = $(event.currentTarget).parents(".item") - this.rollIDR( li.data("item-id"), diceValue) - }) - - html.find('.roll-spec').click((event) => { + html.find('.roll-skill').click((event) => { const li = $(event.currentTarget).parents(".item"); - const specId = li.data("item-id"); - this.actor.rollSpec(specId); + const skillId = li.data("item-id") + this.actor.rollSkill(skillId) }); - html.find('.power-roll').click((event) => { - const li = $(event.currentTarget).parents(".item"); - const powerId = li.data("item-id"); - this.actor.rollPower(powerId); - }); html.find('.weapon-roll').click((event) => { const li = $(event.currentTarget).parents(".item"); const weaponId = li.data("item-id"); diff --git a/modules/crucible-actor.js b/modules/crucible-actor.js index 2ef342f..c4ec8ee 100644 --- a/modules/crucible-actor.js +++ b/modules/crucible-actor.js @@ -361,19 +361,17 @@ export class CrucibleActor extends Actor { } /* -------------------------------------------- */ - getCommonRollData(abKey = undefined) { + getCommonRollData(abilityKey = undefined) { let rollData = CrucibleUtility.getBasicRollData() rollData.alias = this.name rollData.actorImg = this.img rollData.actorId = this.id rollData.img = this.img - if (abilKey) { - rollData.getRelevantSkill(abKey) - rollData.ability = this.getAbility(abKey) - rollData.skillList = this.getRelevantSkill(abKey) - rollData.selectedKill = "0" - rollData.img = `systems/fvtt-crucible-rpg/images/icons/${rollData.ability.abbrev}.webp` + if (abilityKey) { + rollData.ability = this.getAbility(abilityKey) + //rollData.skillList = this.getRelevantSkill(abilityKey) + rollData.selectedKill = undefined } console.log("ROLLDATA", rollData) @@ -381,6 +379,25 @@ export class CrucibleActor extends Actor { return rollData } + /* -------------------------------------------- */ + rollAbility(abilityKey) { + let rollData = this.getCommonRollData(abilityKey) + rollData.mode = "ability" + CrucibleUtility.rollCrucible(rollData) + } + + /* -------------------------------------------- */ + rollSkill(skillId) { + let skill = this.data.items.get(skillId) + if (skill) { + skill = duplicate(skill) + let abilityKey = skill.data.ability + let rollData = this.getCommonRollData(abilityKey) + rollData.mode = "skill" + rollData.skill = skill + CrucibleUtility.rollCrucible(rollData) + } + } /* -------------------------------------------- */ async startRoll(rollData) { diff --git a/modules/crucible-utility.js b/modules/crucible-utility.js index a59c449..2dd34c1 100644 --- a/modules/crucible-utility.js +++ b/modules/crucible-utility.js @@ -262,50 +262,24 @@ export class CrucibleUtility { let actor = game.actors.get(rollData.actorId) - let diceFormulaTab = [] - for (let dice of rollData.dicePool) { - let level = dice.level - if (dice.name == "stat") { - level += rollData.statLevelBonus - } - diceFormulaTab.push(this.getFoundryDiceFromLevel(level)) + let diceFormula = String(rollData.ability.value) + "d6cs>=5" + if (rollData.skill) { + diceFormula += "+" + String(rollData.skill.data.level) + "d8cs>=5" } - let diceFormula = '{' + diceFormulaTab.join(', ') + '}kh + ' + (rollData.stat?.mod || 0) // Performs roll let myRoll = rollData.roll - if (!myRoll || rollData.rerollHero || rollData.rerollMomentum) { // New rolls only of no rerolls + if (!myRoll) { // New rolls only of no rerolls myRoll = new Roll(diceFormula).roll({ async: false }) await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")) rollData.roll = myRoll } - // Final score and keep data - rollData.finalScore = myRoll.total - - if (rollData.damages) { - let dmgFormula = this.getFoundryDiceFromLevel(rollData.damages.value) - let dmgRoll = new Roll(dmgFormula).roll({ async: false }) - await this.showDiceSoNice(dmgRoll, game.settings.get("core", "rollMode")) - rollData.dmgResult = dmgRoll.total - } + rollData.nbSuccess = myRoll.total this.createChatWithRollMode(rollData.alias, { content: await renderTemplate(`systems/fvtt-crucible-rpg/templates/chat-generic-result.html`, rollData) - }); - - // Init stuf - if (rollData.isInit) { - let combat = game.combats.get(rollData.combatId) - combat.updateEmbeddedDocuments("Combatant", [{ _id: rollData.combatantId, initiative: rollData.finalScore }]) - } - - // Stun specific -> Suffere a stun level when dmg-res - if (rollData.subKey && rollData.subKey == "dmg-res") { - actor.modifyStun(+1) - } - - //this.removeUsedPerkEffects( rollData) // Unused for now - this.removeOneUseEffects(rollData) // Unused for now + }) + console.log("Rolldata result", rollData) // And save the roll this.saveRollData(rollData) diff --git a/styles/simple.css b/styles/simple.css index eb02bc2..619d1cd 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -605,7 +605,7 @@ ul, li { .devotion-label, .sort-label, .technique-label, -.stat-label, +.ability-label, .arme-label, .armure-label, .equipement-label, @@ -720,7 +720,7 @@ ul, li { flex-shrink: 1; flex-grow: 0; } -.npc-stat-label { +.npc-ability-label { flex-grow: 2; } @@ -739,7 +739,7 @@ ul, li { margin-left: 0.25rem; } -.stats-table { +.abilities-table { align-content: flex-start; } @@ -926,7 +926,7 @@ ul, li { height: 64px; } -.stat-icon { +.ability-icon { border: 0; padding: 2px 2px 2px 2px; max-width:32px; @@ -934,7 +934,7 @@ ul, li { width: auto; height: auto; } -.small-stat-icon { +.small-ability-icon { border: 0; padding: 2px 2px 2px 2px; max-width:16px; @@ -1348,15 +1348,15 @@ Focus FOC: #ff0084 max-width: 128px; justify-content: flex-start; } -.stat-item { +.ability-item { flex-grow: 1; justify-content: flex-start; margin: 2px; } -.stat-block { +.ability-block { min-width: 160px; } -.stat-margin { +.ability-margin { margin-left: 4px; margin-top: 5px; } @@ -1364,14 +1364,11 @@ Focus FOC: #ff0084 margin-left: 4px; margin-top: 3px; } -.stat-text-white { - color: white; -} -.item-stat-roll { +.item-ability-roll { max-height: 42px; min-height: 36px; } -.item-stat-roll select, .item-stat-roll input { +.item-ability-roll select, .item-ability-roll input { margin-top: 4px; margin-right: 2px; } diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 780761e..81e2c5a 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -9,7 +9,7 @@
-
+
    {{#each data.abilities as |ability key|}} {{#if (eq ability.col 1)}} @@ -19,7 +19,7 @@
-
+
    {{#each data.abilities as |ability key|}} {{#if (eq ability.col 2)}} @@ -29,7 +29,7 @@
-
+
{{> systems/fvtt-crucible-rpg/templates/partial-actor-status.html}}
@@ -52,7 +52,7 @@
{{!-- Skills Tab --}} -
+
  • @@ -73,9 +73,9 @@
  • - {{skill.name}} + {{skill.name}} {{upper skill.data.ability}} - {{skill.data.dice}} + {{skill.data.level}}d8  - 
     
    @@ -87,90 +87,9 @@
    {{!-- Combat Tab --}} -
    +
    -
    - - - - - - - - -
    - -

    Stun

    - - + -  - - -
    -
      -
    • - Current - - Threshold - -
    • -
    -
    -
    -
    • @@ -282,93 +201,24 @@
      -
    • - -

      -
      - - - - - - - - - - - - -
    • - - {{#each effects as |effect key|}} -
    • - - {{effect.name}} - {{effect.data.effectlevel}} - {{upperFirst effect.data.type}} - {{upperFirst effect.data.genre}} - {{upper effect.data.stataffected}} -
       
      -
      - -
      -
    • - {{/each}}
    +
    - {{!-- Powers Tab --}} -
    + {{!-- Lore Tab --}} +
    -
      -
    • - -

      {{data.nrg.label}}

      -
      - Activated -  Current -  Mod -  Max - / {{data.nrg.absolutemax}} -
    • -
    - -
      -
    • - -

      -
      - - - - - - - - - - - - -
    • - {{#each abilities as |ability key|}} -
    • - - {{ability.name}} - - {{upper ability.data.affectedstat}} - {{ability.data.statmodifier}} - {{upperFirst ability.data.statusaffected}} - {{ability.data.statusmodifier}} - -
       
      -
      - -
      -
    • - {{/each}}
    @@ -467,7 +249,6 @@

    Encumbrance

    Current : {{encCurrent}} Capacity : {{encCapacity}} - Hindrance : {{encHindrance}}
      @@ -530,27 +311,6 @@ - - - - - - - - - - - - - - - - - - - - -
      @@ -560,41 +320,8 @@ {{weapon.name}} - - - - - - - {{#if (gt weapon.data.ammomax 0)}} - - {{else}} - - - {{/if}} - - - {{#if (count weapon.data.effects)}} - {{#if weapon.data.activated}} - Deactivate - {{else}} - Activate - {{/if}} - {{else}} -  -  - {{/if}} - - - - - {{#if weapon.data.idrDice}} - {{weapon.data.idrDice}} - {{else}} -  -  - {{/if}} - + +
      {{#if weapon.data.equipped}} - + - - - - - - - - - - - - - +
       
      @@ -639,30 +354,8 @@
      {{armor.name}} - {{upper armor.data.statistic}} - {{armor.data.resistanceDice}} - {{armor.data.locationprotected}} - - - {{#if (count armor.data.effects)}} - {{#if armor.data.activated}} - Deactivate - {{else}} - Activate - {{/if}} - {{else}} -  -  - {{/if}} - - - {{armor.data.weight}} - - {{#if armor.data.idrDice}} - {{armor.data.idrDice}} - {{else}} -  -  - {{/if}} - + {{upper armor.data.armortype}} + {{armor.data.absorprionroll}}
       
      @@ -682,15 +375,6 @@ - - - - - - - - -
       
      @@ -703,26 +387,6 @@ {{shield.name}} {{shield.data.levelDice}} - - {{#if (count shield.data.effects)}} - {{#if shield.data.activated}} - Deactivate - {{else}} - Activate - {{/if}} - {{else}} -  -  - {{/if}} - - - {{shield.data.weight}} - - {{#if shield.data.idrDice}} - {{shield.data.idrDice}} - {{else}} -  -  - {{/if}} -
       
      {{#if shield.data.equipped}} - - - - - - - - -
       
      diff --git a/templates/chat-generic-result.html b/templates/chat-generic-result.html index ac0f288..23bc57b 100644 --- a/templates/chat-generic-result.html +++ b/templates/chat-generic-result.html @@ -18,37 +18,15 @@
        - {{#if power}} -
      • Power : {{power.name}}
      • + {{#if ability}} +
      • Ability : {{ability.label}} - {{ability.value}}d6
      • {{/if}} - {{#if isDamage}} -
      • Weapon Damage Dice : {{weaponDamageDice}}
      • - {{/if}} - {{#if isResistance}} -
      • Armor Resistance Dice : {{armor.data.resistanceDice}}
      • - {{/if}} - {{#if stat}} -
      • Statistic : {{stat.label}}
      • - {{/if}} - {{#if spec}} -
      • Specialisation : {{spec.name}}
      • + {{#if skill}} +
      • Skill : {{skill.name}} - {{skill.data.level}}d8
      • {{/if}} +
      • Number of successes {{nbSuccess}}
      • - {{#if weaponName}} -
      • Weapon : {{weaponName}}
      • - {{/if}} - - {{#if isResistance}} -
      • Defense Result : {{finalScore}} - {{else}} - {{#if isDamage}} -
      • Damages : {{finalScore}} - {{else}} -
      • Final Result : {{finalScore}} - {{/if}} - {{/if}} - - +
      diff --git a/templates/partial-actor-status.html b/templates/partial-actor-status.html index 67f3f57..0a84ccd 100644 --- a/templates/partial-actor-status.html +++ b/templates/partial-actor-status.html @@ -1,71 +1,4 @@
        -
      • - - - - -
      • - {{#each data.secondary as |stat2 key|}} -
      • - - - - - - -
      • - {{/each}} -
      • - - - - - - -  / {{data.nrg.absolutemax}} -
      • -
      • - - - - - - - -
      • -
      • - - - - - - + -  - - - -   -
      • - -
      - \ No newline at end of file