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