From c5a962936c741515d3ea32f8c5c18b767d64030f Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sun, 27 Nov 2022 16:06:26 +0100 Subject: [PATCH] Sync --- modules/avd12-actor-sheet.js | 19 +- modules/avd12-actor.js | 162 ++++++------- modules/avd12-item-sheet.js | 37 +-- modules/avd12-npc-sheet.js | 2 +- modules/avd12-roll-dialog.js | 31 +-- modules/avd12-utility.js | 182 +++------------ styles/simple.css | 4 + system.json | 4 +- template.json | 20 ++ templates/actors/actor-sheet.hbs | 263 ++++++++++------------ templates/chat/chat-generic-result.hbs | 127 +---------- templates/dialogs/roll-dialog-generic.hbs | 172 +++----------- templates/items/item-module-sheet.hbs | 1 + 13 files changed, 322 insertions(+), 702 deletions(-) diff --git a/modules/avd12-actor-sheet.js b/modules/avd12-actor-sheet.js index b7e32c4..783b292 100644 --- a/modules/avd12-actor-sheet.js +++ b/modules/avd12-actor-sheet.js @@ -13,7 +13,7 @@ export class Avd12ActorSheet extends ActorSheet { return mergeObject(super.defaultOptions, { classes: ["fvtt-avd12", "sheet", "actor"], - template: "systems/fvtt-avd12/templates/actor-sheet.html", + template: "systems/fvtt-avd12/templates/actors/actor-sheet.hbs", width: 960, height: 720, tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "skills" }], @@ -35,11 +35,12 @@ export class Avd12ActorSheet extends ActorSheet { cssClass: this.isEditable ? "editable" : "locked", system: duplicate(this.object.system), limited: this.object.limited, - skills: this.actor.getSkills( ), + modules: this.actor.getModules(), + traits: this.actor.getTraits(), weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ), armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())), shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())), - spells: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getLore())), + spells: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getSpells())), equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ), equippedWeapons: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquippedWeapons()) ), equippedArmor: this.actor.getEquippedArmor(), @@ -81,7 +82,7 @@ export class Avd12ActorSheet extends ActorSheet { // Delete Inventory Item html.find('.item-delete').click(ev => { const li = $(ev.currentTarget).parents(".item") - CrucibleUtility.confirmDelete(this, li) + Avd12Utility.confirmDelete(this, li) }) html.find('.item-add').click(ev => { let dataType = $(ev.currentTarget).data("type") @@ -129,14 +130,10 @@ export class Avd12ActorSheet extends ActorSheet { this.actor.incDecAmmo( li.data("item-id"), +1 ) } ); - html.find('.roll-ability').click((event) => { - const abilityKey = $(event.currentTarget).data("ability-key"); - this.actor.rollAbility(abilityKey); - }); html.find('.roll-skill').click((event) => { - const li = $(event.currentTarget).parents(".item") - const skillId = li.data("item-id") - this.actor.rollSkill(skillId) + let attrKey = $(event.currentTarget).data("attr-key") + let skillKey = $(event.currentTarget).data("skill-key") + this.actor.rollSkill(attrKey, skillKey) }); html.find('.roll-weapon').click((event) => { diff --git a/modules/avd12-actor.js b/modules/avd12-actor.js index 5411833..22f89d7 100644 --- a/modules/avd12-actor.js +++ b/modules/avd12-actor.js @@ -49,13 +49,32 @@ export class Avd12Actor extends Actor { /* -------------------------------------------- */ async prepareData() { - super.prepareData(); + + super.prepareData() + } /* -------------------------------------------- */ computeHitPoints() { if (this.type == "character") { } + } + + /* -------------------------------------------- */ + rebuildSkills() { + for (let attrKey in this.system.attributes) { + let attr = this.system.attributes[attrKey] + for (let skillKey in attr.skills) { + let dataPath = attrKey + ".skills." + skillKey + ".modifier" + let skill = attr.skills[skillKey] + skill.modifier = 0 + let availableTraits = this.items.filter(t => t.type == "trait" && t.system.computebonus && t.system.bonusdata == dataPath) + for (let trait of availableTraits) { + skill.modifier += Number(trait.system.bonusvalue) + } + skill.finalvalue = skill.modifier + attr.value + } + } } /* -------------------------------------------- */ @@ -65,7 +84,8 @@ export class Avd12Actor extends Actor { this.system.encCapacity = this.getEncumbranceCapacity() this.buildContainerTree() this.computeHitPoints() - this.computeEffortPoints() + + this.rebuildSkills() } super.prepareDerivedData(); @@ -77,6 +97,11 @@ export class Avd12Actor extends Actor { super._preUpdate(changed, options, user); } + /*_onUpdateEmbeddedDocuments( embeddedName, ...args ) { + this.rebuildSkills() + super._onUpdateEmbeddedDocuments(embeddedName, ...args) + }*/ + /* -------------------------------------------- */ getEncumbranceCapacity() { return 1; @@ -106,6 +131,10 @@ export class Avd12Actor extends Actor { } return undefined } + getSpells() { + let comp = duplicate(this.items.filter(item => item.type == 'spell') || []); + return comp + } /* -------------------------------------------- */ getShields() { let comp = duplicate(this.items.filter(item => item.type == 'shield') || []); @@ -153,15 +182,14 @@ export class Avd12Actor extends Actor { } /* -------------------------------------------- */ - getSkills() { - let comp = duplicate(this.items.filter(item => item.type == 'skill') || []) - for (let skill of comp) { - Avd12Utility.updateSkill(skill) - } - Avd12Utility.sortArrayObjectsByName(comp) + getModules() { + let comp = duplicate(this.items.filter(item => item.type == 'module') || []) + return comp + } + getTraits() { + let comp = duplicate(this.items.filter(item => item.type == 'trait') || []) return comp } - /* -------------------------------------------- */ getRelevantAttribute(attrKey) { let comp = duplicate(this.items.filter(item => item.type == 'skill' && item.system.attribute == attrKey) || []); @@ -212,6 +240,31 @@ export class Avd12Actor extends Actor { return duplicate(this.items.filter(item => item.type == "equipment") || []) } + /* ------------------------------------------- */ + async addModuleLevel(moduleId, levelChoice) { + for (let itemId in levelChoice.features) { + let itemData = duplicate(levelChoice.features[itemId]) + itemData.system.moduleId = moduleId + itemData.system.originalId = itemId + //let item = await Item.create(itemData, { temporary: true }); + await this.createEmbeddedDocuments('Item', [itemData]) + } + } + /* ------------------------------------------- */ + async deleteModuleLevel(moduleId, levelChoice) { + let toDelete = [] + for (let itemId in levelChoice.features) { + let item = this.items.find(it => Avd12Utility.isModuleItemAllowed(it.type) && it.system.moduleId == moduleId && it.system.originalId == itemId) + if (item) { + toDelete.push(item.id) + } + } + console.log("toele", toDelete, moduleId, levelChoice) + if (toDelete.length > 0) { + await this.deleteEmbeddedDocuments('Item', toDelete) + } + } + /* ------------------------------------------- */ async buildContainerTree() { let equipments = duplicate(this.items.filter(item => item.type == "equipment") || []) @@ -451,59 +504,13 @@ export class Avd12Actor extends Actor { } /* -------------------------------------------- */ - 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 - } + getCommonRollData() { let rollData = Avd12Utility.getBasicRollData() rollData.alias = this.name rollData.actorImg = this.img rollData.actorId = this.id rollData.img = this.img - 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 defenderToken = game.canvas.tokens.get(rollData.defenderTokenId) - let defender = defenderToken.actor - - // Distance management - let token = this.token - if (!token) { - let tokens = this.getActiveTokens() - token = tokens[0] - } - if (token) { - const ray = new Ray(token.object?.center || token.center, defenderToken.center) - rollData.tokensDistance = canvas.grid.measureDistances([{ ray }], { gridSpaces: false })[0] / canvas.grid.grid.options.dimensions.distance - } else { - ui.notifications.info("No token connected to this actor, unable to compute distance.") - return - } - if (defender) { - rollData.forceAdvantage = defender.isAttackerAdvantage() - rollData.advantageFromTarget = true - } - } - - if (abilityKey) { - rollData.ability = this.getAbility(abilityKey) - rollData.selectedKill = undefined - } console.log("ROLLDATA", rollData) @@ -518,28 +525,22 @@ export class Avd12Actor extends Actor { ui.notifications.warn("You are targetting a token with a skill : please use a Weapon instead.") return } - Avd12Utility.rollCrucible(rollData) + Avd12Utility.rollAvd12(rollData) } /* -------------------------------------------- */ - rollSkill(skillId) { - let skill = this.items.get(skillId) + rollSkill(attrKey, skillKey) { + let attr = this.system.attributes[attrKey] + let skill = attr.skills[skillKey] if (skill) { - if (skill.system.islore && skill.system.level == 0) { - ui.notifications.warn("You can't use Lore Skills with a SL of 0.") - return - } skill = duplicate(skill) - Avd12Utility.updateSkill(skill) - let abilityKey = skill.system.ability - let rollData = this.getCommonRollData(abilityKey) + skill.name = Avd12Utility.upperFirst(skillKey) + skill.attr = duplicate(attr) + let rollData = this.getCommonRollData() rollData.mode = "skill" rollData.skill = skill + rollData.title = "Roll Skill " + skill.name rollData.img = skill.img - if (rollData.target) { - ui.notifications.warn("You are targetting a token with a skill : please use a Weapon instead.") - return - } this.startRoll(rollData) } } @@ -609,7 +610,7 @@ export class Avd12Actor extends Actor { let rollData = this.getCommonRollData() rollData.defenderTokenId = undefined // Cleanup rollData.mode = "rangeddefense" - if ( attackRollData) { + if (attackRollData) { rollData.attackRollData = duplicate(attackRollData) rollData.effectiveRange = Avd12Utility.getWeaponRange(attackRollData.weapon) rollData.tokensDistance = attackRollData.tokensDistance // QoL copy @@ -699,27 +700,10 @@ export class Avd12Actor extends Actor { return { armorIgnored: true, nbSuccess: 0, messages: ["No armor equipped."] } } - /* -------------------------------------------- */ - rollSave(saveKey) { - let saves = this.getSaveRoll() - let save = saves[saveKey] - if (save) { - save = duplicate(save) - let rollData = this.getCommonRollData() - rollData.mode = "save" - rollData.save = save - if (rollData.target) { - ui.notifications.warn("You are targetting a token with a save roll - Not authorized.") - return - } - this.startRoll(rollData) - } - - } /* -------------------------------------------- */ async startRoll(rollData) { this.syncRoll(rollData) - let rollDialog = await CrucibleRollDialog.create(this, rollData) + let rollDialog = await Avd12RollDialog.create(this, rollData) rollDialog.render(true) } diff --git a/modules/avd12-item-sheet.js b/modules/avd12-item-sheet.js index 59b4ac8..b9d11af 100644 --- a/modules/avd12-item-sheet.js +++ b/modules/avd12-item-sheet.js @@ -1,7 +1,5 @@ import { Avd12Utility } from "./avd12-utility.js"; -const __ALLOWED_MODULE_TYPES = { "action": 1, "reaction": 1, "freeaction": 1, "trait": 1 } - /** * Extend the basic ItemSheet with some very simple modifications * @extends {ItemSheet} @@ -16,11 +14,12 @@ export class Avd12ItemSheet extends ItemSheet { template: "systems/fvtt-avd12/templates/item-sheet.hbs", dragDrop: [{ dragSelector: null, dropSelector: null }], width: 620, - height: 'fit-content', + height: 480, tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }] }); } + /* -------------------------------------------- */ _getHeaderButtons() { let buttons = super._getHeaderButtons(); @@ -96,7 +95,7 @@ export class Avd12ItemSheet extends ItemSheet { /* -------------------------------------------- */ postItem() { - let chatData = duplicate(CrucibleUtility.data(this.item)); + let chatData = duplicate(this.item) if (this.actor) { chatData.actor = { id: this.actor.id }; } @@ -112,7 +111,7 @@ export class Avd12ItemSheet extends ItemSheet { }); renderTemplate('systems/avd12/templates/post-item.html', chatData).then(html => { - let chatOptions = CrucibleUtility.chatDataSetup(html); + let chatOptions = Avd12Utility.chatDataSetup(html); ChatMessage.create(chatOptions) }); } @@ -133,7 +132,7 @@ export class Avd12ItemSheet extends ItemSheet { ui.notifications.warn("Unable to find relevant item - Aborting drag&drop " + data.uuid) return } - if (this.object.type == "module" && __ALLOWED_MODULE_TYPES[item.type]) { + if (this.object.type == "module" && Avd12Utility.isModuleItemAllowed(item.type) ) { let levels = duplicate(this.object.system.levels) levels[levelIndex].choices[choiceIndex].features[item.id] = duplicate(item) this.object.update({ 'system.levels': levels }) @@ -144,13 +143,16 @@ export class Avd12ItemSheet extends ItemSheet { /* -------------------------------------------- */ async viewSubitem(ev) { - let field = $(ev.currentTarget).data('type'); - let idx = Number($(ev.currentTarget).data('index')); - let itemData = this.object.system[field][idx]; + let levelIndex = Number($(ev.currentTarget).parents(".item").data("level-index")) + let choiceIndex = Number($(ev.currentTarget).parents(".item").data("choice-index")) + let featureId = $(ev.currentTarget).parents(".item").data("feature-id") + + let itemData = this.object.system.levels[levelIndex].choices[choiceIndex].features[featureId] + if (itemData.name != 'None') { - let spec = await Item.create(itemData, { temporary: true }); - spec.system.origin = "embeddedItem"; - new Avd12ItemSheet(spec).render(true); + let item = await Item.create(itemData, { temporary: true }); + item.system.origin = "embeddedItem"; + new Avd12ItemSheet(item).render(true); } } @@ -198,7 +200,7 @@ export class Avd12ItemSheet extends ItemSheet { let itemType = li.data("item-type"); }); - html.find('.view-subitem').click(ev => { + html.find('.module-feature-view').click(ev => { this.viewSubitem(ev); }); @@ -228,8 +230,15 @@ export class Avd12ItemSheet extends ItemSheet { for (let choice of levels[levelIndex].choices) { choice.selected = false // Everybody to false } - levels[levelIndex].choices[choiceIndex].selected = ev.currentTarget.value + levels[levelIndex].choices[choiceIndex].selected = ev.currentTarget.checked this.object.update({ 'system.levels': levels }) + if ( this.object.actor ) { + if ( ev.currentTarget.checked ) { + this.object.actor.addModuleLevel( this.object.id, levels[levelIndex].choices[choiceIndex] ) + } else { + this.object.actor.deleteModuleLevel( this.object.id, levels[levelIndex].choices[choiceIndex] ) + } + } }) } diff --git a/modules/avd12-npc-sheet.js b/modules/avd12-npc-sheet.js index 7bba8ab..57e174d 100644 --- a/modules/avd12-npc-sheet.js +++ b/modules/avd12-npc-sheet.js @@ -86,7 +86,7 @@ export class Avd12NPCSheet extends ActorSheet { // Delete Inventory Item html.find('.item-delete').click(ev => { const li = $(ev.currentTarget).parents(".item") - CrucibleUtility.confirmDelete(this, li) + Avd12Utility.confirmDelete(this, li) }) html.find('.item-add').click(ev => { let dataType = $(ev.currentTarget).data("type") diff --git a/modules/avd12-roll-dialog.js b/modules/avd12-roll-dialog.js index 531bdfc..85f1f19 100644 --- a/modules/avd12-roll-dialog.js +++ b/modules/avd12-roll-dialog.js @@ -6,9 +6,9 @@ export class Avd12RollDialog extends Dialog { static async create(actor, rollData) { let options = { classes: ["Avd12Dialog"], width: 540, height: 'fit-content', 'z-index': 99999 }; - let html = await renderTemplate('systems/fvtt-avd12/templates/dialogs/roll-dialog-generic.html', rollData); + let html = await renderTemplate('systems/fvtt-avd12/templates/dialogs/roll-dialog-generic.hbs', rollData); - return new CrucibleRollDialog(actor, rollData, html, options); + return new Avd12RollDialog(actor, rollData, html, options); } /* -------------------------------------------- */ @@ -44,7 +44,7 @@ export class Avd12RollDialog extends Dialog { /* -------------------------------------------- */ async refreshDialog() { - const content = await renderTemplate("systems/fvtt-avd12/templates/dialogs/roll-dialog-generic.html", this.rollData) + const content = await renderTemplate("systems/fvtt-avd12/templates/dialogs/roll-dialog-generic.hbs", this.rollData) this.data.content = content this.render(true) } @@ -58,27 +58,12 @@ export class Avd12RollDialog extends Dialog { } $(function () { onLoad(); }); - html.find('#advantage').change((event) => { - this.rollData.advantage = event.currentTarget.value + html.find('#bonusMalusRoll').change((event) => { + this.rollData.bonusMalusRoll = event.currentTarget.value }) - html.find('#disadvantage').change((event) => { - this.rollData.disadvantage = event.currentTarget.value + html.find('#targetCheck').change((event) => { + this.rollData.targetCheck = event.currentTarget.value }) - html.find('#rollAdvantage').change((event) => { - this.rollData.rollAdvantage = event.currentTarget.value - }) - html.find('#useshield').change((event) => { - this.rollData.useshield = event.currentTarget.checked - }) - html.find('#hasCover').change((event) => { - this.rollData.hasCover = event.currentTarget.value - }) - html.find('#situational').change((event) => { - this.rollData.situational = event.currentTarget.value - }) - html.find('#distanceBonusDice').change((event) => { - this.rollData.distanceBonusDice = Number(event.currentTarget.value) - }) - + } } \ No newline at end of file diff --git a/modules/avd12-utility.js b/modules/avd12-utility.js index 6665186..5f57173 100644 --- a/modules/avd12-utility.js +++ b/modules/avd12-utility.js @@ -2,6 +2,9 @@ import { Avd12Combat } from "./avd12-combat.js"; import { Avd12Commands } from "./avd12-commands.js"; +/* -------------------------------------------- */ +const __ALLOWED_MODULE_TYPES = { "action": 1, "reaction": 1, "freeaction": 1, "trait": 1 } + /* -------------------------------------------- */ export class Avd12Utility { @@ -65,6 +68,11 @@ export class Avd12Utility { return duplicate(this.shieldSkills) } + /* -------------------------------------------- */ + static isModuleItemAllowed(type) { + return __ALLOWED_MODULE_TYPES[type] + } + /* -------------------------------------------- */ static buildBonusList() { let bonusList = [] @@ -466,95 +474,17 @@ export class Avd12Utility { let actor = game.actors.get(rollData.actorId) - // ability/save/size => 0 - let diceFormula - let startFormula = "0d6cs>=5" - if (rollData.ability) { - startFormula = String(rollData.ability.value) + "d6cs>=5" - } - if (rollData.save) { - startFormula = String(rollData.save.value) + "d6cs>=5" - } - if (rollData.sizeDice) { - let nb = rollData.sizeDice.nb + rollData.distanceBonusDice + this.getDiceFromCover(rollData.hasCover) + this.getDiceFromSituational(rollData.situational) - startFormula = String(nb) + String(rollData.sizeDice.dice) + "cs>=5" - } - diceFormula = startFormula - - // skill => 2 - // feat => 4 - // bonus => 6 + // Build the dice formula + let diceFormula = "1d12" if (rollData.skill) { - let level = rollData.skill.system.level - if (rollData.skill.system.issl2) { - rollData.hasSLBonus = true - level += 2 - if (level > 7) { level = 7 } - } - rollData.skill.system.skilldice = __skillLevel2Dice[level] - diceFormula += "+" + String(rollData.skill.system.skilldice) + "cs>=5" - - if (rollData.skill.system.skilltype == "complex" && rollData.skill.system.level == 0) { - rollData.complexSkillDisadvantage = true - rollData.rollAdvantage = "roll-disadvantage" - } - - if (rollData.skill.system.isfeatdie) { - rollData.hasFeatDie = true - diceFormula += "+ 1d10cs>=5" - } else { - diceFormula += `+ 0d10cs>=5` - } - if (rollData.skill.system.bonusdice != "none") { - rollData.hasBonusDice = rollData.skill.system.bonusdice - diceFormula += `+ ${rollData.hasBonusDice}cs>=5` - } else { - diceFormula += `+ 0d6cs>=5` - } - } else { - diceFormula += `+ 0d8cs=>5 + 0d10cs>=5 + 0d6cs>=5` + diceFormula += "+"+rollData.skill.finalvalue } - - // advantage => 8 - let advFormula = "+ 0d8cs>=5" - if (rollData.advantage == "advantage1" || rollData.forceAdvantage) { - advFormula = "+ 1d8cs>=5" - } - if (rollData.advantage == "advantage2") { - advFormula = "+ 2d8cs>=5" - } - diceFormula += advFormula - - // disadvantage => 10 - let disFormula = "- 0d8cs>=5" - if (rollData.disadvantage == "disadvantage1" || rollData.forceDisadvantage) { - disFormula = "- 1d8cs>=5" - } - if (rollData.disadvantage == "disadvantage2") { - disFormula = "- 2d8cs>=5" - } - diceFormula += disFormula - - // armor => 12 - let skillArmorPenalty = 0 - for (let armor of rollData.armors) { - if (armor.system.equipped) { - skillArmorPenalty += armor.system.skillpenalty - } - } - if (rollData.skill && rollData.skill.system.armorpenalty && skillArmorPenalty > 0) { - rollData.skillArmorPenalty = skillArmorPenalty - diceFormula += `- ${skillArmorPenalty}d8cs>=5` - } else { - diceFormula += `- 0d8cs>=5` - } - - // shield => 14 - if (rollData.useshield && rollData.shield) { - diceFormula += "+ 1" + String(rollData.shield.system.shielddie) + "cs>=5" - } else { - diceFormula += " + 0d6cs>=5" + diceFormula += "+"+rollData.bonusMalusRoll + + if (rollData.skill && rollData.skill.good) { + diceFormula += "+1d4" } + rollData.diceFormula = diceFormula // Performs roll console.log("Roll formula", diceFormula) @@ -563,74 +493,21 @@ export class Avd12Utility { myRoll = new Roll(diceFormula).roll({ async: false }) await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")) } - rollData.rollOrder = 0 rollData.roll = myRoll - rollData.nbSuccess = myRoll.total - - 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" - this.createChatWithRollMode(rollData.alias, { - content: await renderTemplate(`systems/fvtt-avd12/templates/chat-generic-result.html`, rollData) - }) - - rollData.rollOrder = 2 - let myRoll2 = new Roll(diceFormula).roll({ async: false }) - await this.showDiceSoNice(myRoll2, game.settings.get("core", "rollMode")) - - rollData.roll = myRoll2 // Tmp switch to display the proper results - rollData.nbSuccess = myRoll2.total - this.createChatWithRollMode(rollData.alias, { - content: await renderTemplate(`systems/fvtt-avd12/templates/chat-generic-result.html`, rollData) - }) - rollData.roll = myRoll // Revert the tmp switch - rollData.nbSuccess = myRoll.total - - if (rollData.rollAdvantage == "roll-advantage") { - if (myRoll2.total > rollData.nbSuccess) { - hasChanged = true - rollData.roll = myRoll2 - rollData.nbSuccess = myRoll2.total - } - } else { - if (myRoll2.total < rollData.nbSuccess) { - rollData.roll = myRoll2 - rollData.nbSuccess = myRoll2.total - } - } - rollData.rollOrder = 3 - } - rollData.nbSuccess = Math.max(0, rollData.nbSuccess) - - rollData.isFirstRollAdvantage = false - // Manage exp - if (rollData.skill && rollData.skill.system.level > 0) { - let nbSkillSuccess = rollData.roll.terms[2].total - if (nbSkillSuccess == 0 || nbSkillSuccess == rollData.skill.system.level) { - actor.incrementSkillExp(rollData.skill.id, 1) + + rollData.isSuccess = false + if ( rollData.targetCheck != "none") { + if( myRoll.total >= Number(rollData.targetCheck)) { + rollData.isSuccess = true } } - this.saveRollData(rollData) - actor.lastRoll = rollData - - this.createChatWithRollMode(rollData.alias, { - content: await renderTemplate(`systems/fvtt-avd12/templates/chat-generic-result.html`, rollData) + let msg = await this.createChatWithRollMode(rollData.alias, { + content: await renderTemplate(`systems/fvtt-avd12/templates/chat/chat-generic-result.hbs`, rollData) }) + msg.setFlag("world", "rolldata", rollData) + console.log("Rolldata result", rollData) - - // Message response - this.displayDefenseMessage(rollData) - - // Manage defense result - this.processAttackDefense(rollData) } /* -------------------------------------------- */ @@ -724,15 +601,16 @@ export class Avd12Utility { break; } chatOptions.alias = chatOptions.alias || name; - ChatMessage.create(chatOptions); + return ChatMessage.create(chatOptions); } /* -------------------------------------------- */ static getBasicRollData() { let rollData = { rollId: randomID(16), - rollMode: game.settings.get("core", "rollMode"), - advantage: "none" + bonusMalusRoll: 0, + targetCheck : "none", + rollMode: game.settings.get("core", "rollMode") } Avd12Utility.updateWithTarget(rollData) return rollData @@ -748,7 +626,7 @@ export class Avd12Utility { /* -------------------------------------------- */ static createChatWithRollMode(name, chatOptions) { - this.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions) + return this.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions) } /* -------------------------------------------- */ diff --git a/styles/simple.css b/styles/simple.css index 03bd6b3..1654c67 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -800,6 +800,10 @@ ul, li { text-align: center; } +.skill-good-checkbox { + height: 14px; + width: 14px; +} .flex-actions-bar { flex-grow: 2; diff --git a/system.json b/system.json index d2b55cb..8493288 100644 --- a/system.json +++ b/system.json @@ -35,7 +35,7 @@ ], "title": "AnyVenture D12 RPG", "url": "https://www.uberwald.me/gitea/public/fvtt-avd12", - "version": "10.0.9", - "download": "https://www.uberwald.me/gitea/public/fvtt-avd12/archive/fvtt-avd12-v10.0.9.zip", + "version": "10.0.10", + "download": "https://www.uberwald.me/gitea/public/fvtt-avd12/archive/fvtt-avd12-v10.0.10.zip", "background": "systems/fvtt-avd12/images/ui/avd12_welcome_page.webp" } \ No newline at end of file diff --git a/template.json b/template.json index 7966d92..fe7ff7c 100644 --- a/template.json +++ b/template.json @@ -30,14 +30,17 @@ "skills": { "athletics": { "modifier": 0, + "finalvalue": 0, "good": false }, "block": { "modifier": 0, + "finalvalue": 0, "good": false }, "strength": { "modifier": 0, + "finalvalue": 0, "good": false } } @@ -52,14 +55,17 @@ "skills": { "acrobatics": { "modifier": 0 , + "finalvalue": 0, "good": false }, "stealth": { "modifier": 0, + "finalvalue": 0, "good": false }, "dodge": { "modifier": 0, + "finalvalue": 0, "good": false } } @@ -74,14 +80,17 @@ "skills": { "concentration": { "modifier": 0, + "finalvalue": 0, "good": false }, "endurance": { "modifier": 0 , + "finalvalue": 0, "good": false }, "resistance": { "modifier": 0, + "finalvalue": 0, "good": false } } @@ -96,22 +105,27 @@ "skills": { "wilderness": { "modifier": 0, + "finalvalue": 0, "good": false }, "academic": { "modifier": 0, + "finalvalue": 0, "good": false }, "arcanum": { "modifier": 0, + "finalvalue": 0, "good": false }, "medicine": { "modifier": 0, + "finalvalue": 0, "good": false }, "thievery": { "modifier": 0, + "finalvalue": 0, "good": false } } @@ -126,18 +140,22 @@ "skills": { "persuasion": { "modifier": 0, + "finalvalue": 0, "good": false }, "insight": { "modifier": 0, + "finalvalue": 0, "good": false }, "performance": { "modifier": 0, + "finalvalue": 0, "good": false }, "animals": { "modifier": 0, + "finalvalue": 0, "good": false } } @@ -147,10 +165,12 @@ "skills": { "search": { "modifier": 0, + "finalvalue": 0, "good": false }, "initiative": { "modifier": 0, + "finalvalue": 0, "good": false } } diff --git a/templates/actors/actor-sheet.hbs b/templates/actors/actor-sheet.hbs index 7877621..2d8ab72 100644 --- a/templates/actors/actor-sheet.hbs +++ b/templates/actors/actor-sheet.hbs @@ -9,68 +9,26 @@
-
-
    - {{#each system.attributes as |attribute key|}} - {{#if (eq attribute.col 1)}} - {{> systems/fvtt-crucible-rpg/templates/actors/partial-actor-attribute-block.html attribute=attribute key=key}} - {{/if}} - {{/each}} -
- -
  • - -

    Class

    -
    - -
  • - -
    + {{#each system.attributes as |attr attrKey|}} +
    +
    + {{attr.label}} + +
    + {{#each attr.skills as |skill skillKey|}} + + {{/each}} +
    + {{/each}} +
    -
      - {{#each data.abilities as |ability key|}} - {{#if (eq ability.col 2)}} - {{> systems/fvtt-crucible-rpg/templates/partial-actor-ability-block.html ability=ability key=key}} - {{/if}} - {{/each}} - - {{#if equippedArmor}} -
    • - - -

      {{equippedArmor.name}}

      -
      -
    • - {{/if}} - {{#if equippedShield}} -
    • - - -

      {{equippedShield.name}}

      -
      -
    • - {{/if}} -
    • - - -

      Target Roll

      -
      -
    • - -
    - {{> systems/fvtt-crucible-rpg/templates/partial-actor-status.html}}
    @@ -81,10 +39,13 @@ {{!-- Sheet Tab Navigation --}} @@ -92,7 +53,7 @@
    {{!-- Skills Tab --}} -
    +
    • @@ -127,31 +88,20 @@
    {{!-- Combat Tab --}} -
    +
    +
    - -
    • -

      -
      - - - - - +

    • - {{#each equippedWeapons as |weapon key|}} -
    • + {{#each modules as |module key|}} +
    • - {{weapon.name}} - - {{weapon.system.ability}} - - {{perk.system.range}} + src="{{module.img}}" /> + {{module.name}}
       
      @@ -162,84 +112,24 @@
    -
    -
      -
    • - -

      -
      - - - - - - - - - -
    • - {{#each feats as |feat key|}} -
    • - - {{feat.name}} - - {{upperFirst feat.system.isfeatdie}} - {{upperFirst feat.system.issl}} - {{feat.system.sl}} - -
       
      -
      - -
      -
    • - {{/each}} -
    -
    - -
    -
      -
    • - -

      -
      -
    • - {{#each conditions as |condition key|}} -
    • - - {{condition.name}} -
       
      -
      - -
      -
    • - {{/each}} -
    -
    - -
    - {{!-- Lore Tab --}} -
    + {{!-- Spells Tab --}} +
    • -

      +

      - - - - + - +
    • @@ -248,11 +138,88 @@ - {{spell.name}} + {{spell.name}} - {{upperFirst spell.system.lore}} - {{upperFirst spell.system.circle}} - {{upperFirst spell.system.range}} + {{upperFirst spell.system.spelltype}} + {{upperFirst spell.system.level}} +
       
      +
      + +
      + + {{/each}} + +
    + +
    +
    + + {{!-- moves Tab --}} +
    + +
    + +
      +
    • + +

      +
      + + + + + + +
    • + + {{#each spells as |spell key|}} +
    • + + + {{spell.name}} + + {{upperFirst spell.system.spelltype}} + {{upperFirst spell.system.level}} +
       
      +
      + +
      +
    • + {{/each}} + +
    + +
    +
    + + {{!-- traits Tab --}} +
    + +
    + +
      +
    • + +

      +
      + + + + + + +
    • + + {{#each traits as |trait key|}} +
    • + + + {{trait.name}} + + {{upperFirst trait.system.spelltype}} + {{upperFirst trait.system.level}}
       
      diff --git a/templates/chat/chat-generic-result.hbs b/templates/chat/chat-generic-result.hbs index e6633de..695250b 100644 --- a/templates/chat/chat-generic-result.hbs +++ b/templates/chat/chat-generic-result.hbs @@ -18,131 +18,22 @@
        - {{#if (eq rollOrder 1)}} -
      • Roll with {{rollType}} - Roll 1
      • - {{/if}} - {{#if (eq rollOrder 2)}} -
      • Roll with {{rollType}} - Roll 2
      • - {{/if}} - {{#if (eq rollOrder 3)}} -
      • Roll with {{rollType}} - Final result !
      • - {{/if}} - - {{#if save}} -
      • Save : {{save.label}} - {{save.value}}d6 - ({{#each roll.terms.0.results as |die idx|}} - {{die.result}}  - {{/each}}) -
      • - {{/if}} - - {{#if sizeDice}} -
      • Size/Range/Cover/Situational dices - ({{#each roll.terms.0.results as |die idx|}} - {{die.result}}  - {{/each}}) -
      • - {{/if}} - - {{#if ability}} -
      • Ability : {{ability.label}} - {{ability.value}}d6 - ({{#each roll.terms.0.results as |die idx|}} - {{die.result}}  - {{/each}}) -
      • - {{/if}} - {{#if skill}} -
      • Skill : {{skill.name}} - {{skill.data.skilldice}} - {{#if featSL}} - - with Feat SL +{{featSL}} - {{/if}} -  ({{#each roll.terms.2.results as |die idx|}} - {{die.result}}  - {{/each}}) +
      • Skill : {{skill.name}} ({{skill.finalvalue}})
      • {{/if}} - {{#if noAdvantage}} -
      • No advantage due to condition : {{noAdvantage.name}}
      • - {{else}} - {{#if (or (eq advantage "advantage1") forceAdvantage)}} -
      • 1 Advantage Die ! -  ({{#each roll.terms.8.results as |die idx|}} - {{die.result}}  - {{/each}}) -
      • - {{/if}} - {{#if (eq advantage "advantage2") }} -
      • 2 Advantage Dice ! -  ({{#each roll.terms.8.results as |die idx|}} - {{die.result}}  - {{/each}}) -
      • +
      • Dice Formula {{diceFormula}}
      • +
      • Result {{roll.total}}
      • + + {{#if (ne targetCheck "none")}} + {{#if isSuccess}} +
      • Success !
      • + {{else}} +
      • Failure !
      • {{/if}} {{/if}} - {{#if (or (eq disadvantage "disadvantage1") forceDisadvantage)}} -
      • 1 Disadvantage Die ! -  ({{#each roll.terms.10.results as |die idx|}} - {{die.result}}  - {{/each}}) -
      • - {{/if}} - {{#if (eq disadvantage "disadvantage2")}} -
      • 2 Disadvantage Dice ! -  ({{#each roll.terms.10.results as |die idx|}} - {{die.result}}  - {{/each}}) -
      • - {{/if}} - {{#if (eq rollAdvantage "roll-advantage")}} -
      • Roll with Advantage !
      • - {{/if}} - {{#if (eq rollAdvantage "roll-disadvantage")}} -
      • Roll with Disadvantage !
      • - {{/if}} - - {{#if skillArmorPenalty}} -
      • Armor Penalty : {{skillArmorPenalty}} Disadvantage Dice -  ({{#each roll.terms.12.results as |die idx|}} - {{die.result}}  - {{/each}}) -
      • - {{/if}} - - {{#if hasBonusDice}} -
      • Skill bonus dice : {{hasBonusDice}} -  ({{#each roll.terms.6.results as |die idx|}} - {{die.result}}  - {{/each}}) -
      • - {{/if}} - - {{#if complexSkillDisadvantage}} -
      • Roll with Disadvantage because of Complex Skill at SL 0 !
      • - {{/if}} - - {{#if hasFeatDie}} -
      • Feat Die : d10 -  ({{#each roll.terms.4.results as |die idx|}} - {{die.result}}  - {{/each}}) -
      • - {{/if}} - - {{#if useshield}} -
      • Shield : {{shield.name}} - {{shield.data.shielddie}} - ({{#each roll.terms.14.results as |die idx|}} - {{die.result}}  - {{/each}}) -
      • - {{/if}} - -
      • Number of successes {{nbSuccess}}
      • - - -
      diff --git a/templates/dialogs/roll-dialog-generic.hbs b/templates/dialogs/roll-dialog-generic.hbs index e9d1241..fbb9506 100644 --- a/templates/dialogs/roll-dialog-generic.hbs +++ b/templates/dialogs/roll-dialog-generic.hbs @@ -8,160 +8,44 @@
      - {{#if sizeDice}} -
      - Size basic dices : - {{sizeDice.nb}}{{sizeDice.dice}} -
      - -
      - Distance bonus dice(s) : - -
      - {{/if}} - - {{#if hasCover}} -
      - Cover : - -
      - {{/if}} - - {{#if situational}} -
      - Situational : - -
      - {{/if}} - - - {{#if save}} -
      - {{save.label}} : - {{save.value}}d6 -
      - {{/if}} - - {{#if ability}} -
      - Ability : - {{ability.value}}d6 -
      - {{/if}} - - {{#if weapon}} -
      - Weapon : - {{weapon.name}} -
      - {{/if}} - - {{#if shield}} -
      - Use shield ? : - -
      -
      - {{shield.name}} : - {{shield.data.shielddie}} -
      - {{/if}} - {{#if skill}}
      Skill : - {{skill.name}} - {{skill.data.skilldice}} -
      -
      - Feature die or SL+2? : - {{#if skill.data.isfeatdie}} Yes {{else}} No {{/if}} + {{skill.name}} ({{skill.finalvalue}})
      {{/if}} - {{#if noAdvantage}} -
      - No advantage due to condition : {{noAdvantage.name}} -
      - {{else}} -
      - Advantage : - + {{#select bonusMalusRoll}} + + + + + + + + + + {{/select}} + +
      + +
      + Target check : + -
      - {{/if}} - -
      - Disadvantage : - +
      -
      - Roll with Advantage/Disadvantage : - -
      - - {{#if forceAdvantage}} -
      - 1 Advantage from condition : {{forceAdvantage.name}} - {{#if advantageFromTarget}} (Provided by targetted actor) {{/if}} - -
      - {{/if}} - {{#if forceDisadvantage}} -
      - 1 Disadvantage from condition : {{forceDisadvantage.name}} -
      - {{/if}} - {{#if forceRollAdvantage}} -
      - Roll Advantage from condition : {{forceRollAdvantage.name}} -
      - {{/if}} - {{#if forceRollDisadvantage}} -
      - Roll Disadvantage from condition : {{forceRollDisadvantage.name}} -
      - {{/if}} - -
      \ No newline at end of file diff --git a/templates/items/item-module-sheet.hbs b/templates/items/item-module-sheet.hbs index ad6f281..37c4a7c 100644 --- a/templates/items/item-module-sheet.hbs +++ b/templates/items/item-module-sheet.hbs @@ -46,6 +46,7 @@
    • +