From 46b129cf81664361e659afcd87ea00bb6ff1490b Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Sat, 18 Feb 2023 23:19:10 +0100 Subject: [PATCH] Various fixes --- lang/en.json | 5 +++ modules/warhero-actor-sheet.js | 3 +- modules/warhero-actor.js | 54 +++++++++++++------------ modules/warhero-item-sheet.js | 20 --------- modules/warhero-item.js | 1 + modules/warhero-main.js | 4 +- modules/warhero-utility.js | 13 +++++- styles/simple.css | 4 ++ system.json | 4 +- template.json | 3 +- templates/actor-sheet.html | 32 +++++++-------- templates/item-class-sheet.html | 6 +-- templates/item-equipment-sheet.html | 4 ++ templates/item-race-sheet.html | 6 +-- templates/partial-actor-stat-block.html | 6 +-- templates/roll-dialog-generic.html | 2 +- 16 files changed, 88 insertions(+), 79 deletions(-) diff --git a/lang/en.json b/lang/en.json index dba7ff8..3e5f122 100644 --- a/lang/en.json +++ b/lang/en.json @@ -44,6 +44,9 @@ "WH.ui.Strength": "Strength", "WH.ui.Instinct": "Instinct", "WH.ui.Dexterity": "Dexterity", + "WH.ui.savestr": "Str Save", + "WH.ui.savedex": "Dex Save", + "WH.ui.savemin": "Mind Save", "WH.ui.Mind": "Mind", "WH.ui.Type": "Type", "WH.ui.HitPoints": "Hit Points", @@ -113,6 +116,8 @@ "WH.ui.quantity": "Quantity", "WH.ui.cost": "Cost", "WH.ui.details": "Details", + "WH.ui.magicschool": "Magic School", + "WH.ui.providedslot": "Provided slot", "WH.chat.save": "Save", "WH.chat.mweaponmalus": "Multiple weapons malus ", diff --git a/modules/warhero-actor-sheet.js b/modules/warhero-actor-sheet.js index 18220c3..c59de59 100644 --- a/modules/warhero-actor-sheet.js +++ b/modules/warhero-actor-sheet.js @@ -99,7 +99,8 @@ export class WarheroActorSheet extends ActorSheet { }) html.find('.item-add').click(ev => { let dataType = $(ev.currentTarget).data("type") - this.actor.createEmbeddedDocuments('Item', [{ name: "NewItem", type: dataType }], { renderSheet: true }) + let slotKey = $(ev.currentTarget).data("slot") + this.actor.createEmbeddedDocuments('Item', [{ name: "NewItem", type: dataType, system: { slotlocation: slotKey} }], { renderSheet: true }) }) html.find('.equip-activate').click(ev => { diff --git a/modules/warhero-actor.js b/modules/warhero-actor.js index fc2fd7f..6c6cc2e 100644 --- a/modules/warhero-actor.js +++ b/modules/warhero-actor.js @@ -135,7 +135,7 @@ export class WarheroActor extends Actor { } sortPowers() { let schools = {} - for(let power of this.items) { + for (let power of this.items) { if (power.type == "power") { power = duplicate(power) let school = schools[power.system.magicschool] || [] @@ -176,14 +176,16 @@ export class WarheroActor extends Actor { /* -------------------------------------------- */ buildEquipmentsSlot() { let containers = {} - for(let slotName in game.system.warhero.config.slotNames) { + for (let slotName in game.system.warhero.config.slotNames) { let slotDef = game.system.warhero.config.slotNames[slotName] containers[slotName] = duplicate(slotDef) - containers[slotName].content = this.items.filter(it => (it.type == 'weapon' || it.type == 'armor' || it.type == 'shield'||it.type == 'equipment') - && it.system.slotlocation == slotName ) + containers[slotName].content = this.items.filter(it => (it.type == 'weapon' || it.type == 'armor' || it.type == 'shield' || it.type == 'equipment') + && it.system.slotlocation == slotName) let slotUsed = 0 - for(let item of containers[slotName].content) { - slotUsed += item.system.slotused * ((item.system.quantity) ? item.system.quantity : 1) + for (let item of containers[slotName].content) { + let q = (item.system.quantity) ? item.system.quantity : 1 + containers[slotName].nbslots += (item.system.providedslot?? 0) * q + slotUsed += item.system.slotused * q } slotUsed = Math.ceil(slotUsed) containers[slotName].slotUsed = slotUsed @@ -203,11 +205,11 @@ export class WarheroActor extends Actor { formula += "+" + this.system.statistics.str.value } if (weapon.system.weapontype == "twohanded") { - formula += "+" + Math.floor(this.system.statistics.str.value*1.5) + formula += "+" + Math.floor(this.system.statistics.str.value * 1.5) } if (weapon.system.weapontype == "polearm") { - formula += "+" + Math.floor(this.system.statistics.str.value*1) - weapon.damageFormula2Hands = weapon.system.damage2hands + "+" + Math.floor(this.system.statistics.str.value*1.5) + formula += "+" + Math.floor(this.system.statistics.str.value * 1) + weapon.damageFormula2Hands = weapon.system.damage2hands + "+" + Math.floor(this.system.statistics.str.value * 1.5) } weapon.damageFormula = formula } @@ -382,7 +384,7 @@ export class WarheroActor extends Actor { /* -------------------------------------------- */ async incDecHP(formula) { - let dmgRoll = new Roll(formula+"[warhero-orange]").roll({ async: false }) + let dmgRoll = new Roll(formula + "[warhero-orange]").roll({ async: false }) await WarheroUtility.showDiceSoNice(dmgRoll, game.settings.get("core", "rollMode")) let hp = duplicate(this.system.secondary.hp) hp.value = Number(hp.value) + Number(dmgRoll.total) @@ -391,7 +393,7 @@ export class WarheroActor extends Actor { } /* -------------------------------------------- */ updateCompetency(competency, obj, labelTab) { - for(let key in obj) { + for (let key in obj) { if (obj[key]) { //console.log("Parsing", key) //game.system.warhero.config.weaponTypes[key].label) competency[key] = { enabled: true, label: labelTab[key].label } @@ -401,11 +403,13 @@ export class WarheroActor extends Actor { getCompetency() { let myRace = this.getRace() let myClass = this.getClass() - let competency = { weapons: {}, armors: {}, shields: {}} - if ( myRace.system && myClass.system) { + let competency = { weapons: {}, armors: {}, shields: {} } + if (myRace.system) { this.updateCompetency(competency.weapons, myRace.system.weapons, game.system.warhero.config.weaponTypes) this.updateCompetency(competency.armors, myRace.system.armors, game.system.warhero.config.armorTypes) this.updateCompetency(competency.shields, myRace.system.shields, game.system.warhero.config.shieldTypes) + } + if (myClass.system) { this.updateCompetency(competency.weapons, myClass.system.weapons, game.system.warhero.config.weaponTypes) this.updateCompetency(competency.armors, myClass.system.armors, game.system.warhero.config.armorTypes) this.updateCompetency(competency.shields, myClass.system.shields, game.system.warhero.config.shieldTypes) @@ -596,7 +600,7 @@ export class WarheroActor extends Actor { /* -------------------------------------------- */ setLevel() { let xp = this.system.secondary.xp.value - this.system.secondary.xp.level = 1 + Math.floor(xp/10) + this.system.secondary.xp.level = 1 + Math.floor(xp / 10) } /* -------------------------------------------- */ computeDRTotal() { @@ -605,7 +609,7 @@ export class WarheroActor extends Actor { for (let armor of armors) { dr += armor.system.damagereduction } - this.system.secondary.drbonustotal.value = this.system.secondary.drbonus.value + dr + this.system.secondary.drbonustotal.value = this.system.secondary.drbonus.value + dr } /* -------------------------------------------- */ computeParryBonusTotal() { @@ -614,21 +618,21 @@ export class WarheroActor extends Actor { for (let shield of shields) { parry += shield.system.parrybonus } - this.system.secondary.parrybonustotal.value = this.system.secondary.parrybonus.value + parry + this.system.secondary.parrybonustotal.value = this.system.secondary.parrybonus.value + parry } /* -------------------------------------------- */ computeBonusLanguages() { this.system.secondary.nblanguage.value = Math.floor(this.system.statistics.min.value / 2) } /* -------------------------------------------- */ - spentMana( mana) { - if ( Number(mana) > this.system.attributes.mana.value) { + spentMana(mana) { + if (Number(mana) > this.system.attributes.mana.value) { ui.notifications.warn("Not enough Mana points !") return false } - this.update({'system.attributes.mana.value': this.system.attributes.mana.value-mana}) + this.update({ 'system.attributes.mana.value': this.system.attributes.mana.value - mana }) return true - } + } /* -------------------------------------------- */ getCommonRollData() { let rollData = WarheroUtility.getBasicRollData() @@ -647,7 +651,7 @@ export class WarheroActor extends Actor { let rollData = this.getCommonRollData() rollData.mode = rollType rollData.stat = stat - if ( rollKey == "parrybonustotal") { + if (rollKey == "parrybonustotal") { WarheroUtility.rollParry(rollData) return } @@ -661,7 +665,7 @@ export class WarheroActor extends Actor { rollData.stat = stat this.startRoll(rollData) } - + /* -------------------------------------------- */ rollWeapon(weaponId) { let weapon = this.items.get(weaponId) @@ -669,13 +673,13 @@ export class WarheroActor extends Actor { weapon = duplicate(weapon) let rollData = this.getCommonRollData() rollData.mode = "weapon" - if (weapon.system.weapontype ==="shooting" || weapon.system.weapontype ==="throwing") { + if (weapon.system.weapontype === "shooting" || weapon.system.weapontype === "throwing") { rollData.stat = duplicate(this.system.attributes.txcr) } else { rollData.stat = duplicate(this.system.attributes.txcm) } rollData.usemWeaponMalus = - rollData.mWeaponMalus = this.system.secondary.malusmultiweapon.value + rollData.mWeaponMalus = this.system.secondary.malusmultiweapon.value rollData.weapon = weapon rollData.img = weapon.img this.startRoll(rollData) @@ -709,7 +713,7 @@ export class WarheroActor extends Actor { this.startRoll(rollData) } } - + /* -------------------------------------------- */ async startRoll(rollData) { this.syncRoll(rollData) diff --git a/modules/warhero-item-sheet.js b/modules/warhero-item-sheet.js index 939ff93..5b82a63 100644 --- a/modules/warhero-item-sheet.js +++ b/modules/warhero-item-sheet.js @@ -69,12 +69,6 @@ export class WarheroItemSheet extends ItemSheet { owner: this.document.isOwner, isGM: game.user.isGM } - if ( this.object.type == "power") { - formData.level1 = await TextEditor.enrichHTML(this.object.system.level1, {async: true}) - formData.level2 = await TextEditor.enrichHTML(this.object.system.level2, {async: true}) - formData.level3 = await TextEditor.enrichHTML(this.object.system.level3, {async: true}) - formData.level4 = await TextEditor.enrichHTML(this.object.system.level4, {async: true}) - } this.options.editable = !(this.object.origin == "embeddedItem"); console.log("ITEM DATA", formData, this); return formData; @@ -130,11 +124,6 @@ export class WarheroItemSheet extends ItemSheet { const item = this.object.options.actor.getOwnedItem(li.data("item-id")); item.sheet.render(true); }); - - html.find('.delete-spec').click(ev => { - this.object.update({ "data.specialisation": [{ name: 'None' }] }); - }); - html.find('.delete-subitem').click(ev => { this.deleteSubitem(ev); }); @@ -145,15 +134,6 @@ export class WarheroItemSheet extends ItemSheet { let itemId = li.data("item-id"); let itemType = li.data("item-type"); }); - - html.find('.view-subitem').click(ev => { - this.viewSubitem(ev); - }); - - html.find('.view-spec').click(ev => { - this.manageSpec(); - }); - } diff --git a/modules/warhero-item.js b/modules/warhero-item.js index 2d7690a..c49f5fa 100644 --- a/modules/warhero-item.js +++ b/modules/warhero-item.js @@ -11,6 +11,7 @@ export const defaultItemImg = { money: "systems/fvtt-warhero/images/icons/two-coins.svg", power: "systems/fvtt-warhero/images/icons/magia.webp", condition: "systems/fvtt-warhero/images/icons/stordenti.webp", + language: "systems/fvtt-warhero/images/icons/linguaggi.webp" } /** diff --git a/modules/warhero-main.js b/modules/warhero-main.js index 60e7ea2..685ee0e 100644 --- a/modules/warhero-main.js +++ b/modules/warhero-main.js @@ -73,12 +73,12 @@ Hooks.once("init", async function () { /* -------------------------------------------- */ function welcomeMessage() { - ChatMessage.create({ + /*ChatMessage.create({ user: game.user.id, whisper: [game.user.id], content: `
Welcome to the Warhero RPG. - ` }); + ` });*/ } /* -------------------------------------------- */ diff --git a/modules/warhero-utility.js b/modules/warhero-utility.js index 375c815..6660b8b 100644 --- a/modules/warhero-utility.js +++ b/modules/warhero-utility.js @@ -19,7 +19,16 @@ export class WarheroUtility { this.defenderStore = {} WarheroCommands.init(); - + + Handlebars.registerHelper('concat', function () { + var outStr = ''; + for (var arg in arguments) { + if (typeof arguments[arg] != 'object') { + outStr += arguments[arg]; + } + } + return outStr; + }); Handlebars.registerHelper('count', function (list) { return list.length; }) @@ -575,7 +584,7 @@ export class WarheroUtility { } let diceFormula - if (rollData.weapon.system.weapontype == "special") { + if (rollData.weapon && rollData.weapon.system.weapontype == "special") { diceFormula = rollData.weapon.system.rollformula } else { // ability/save/size => 0 diff --git a/styles/simple.css b/styles/simple.css index f4dbef7..a7348b3 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -1550,4 +1550,8 @@ form .notes { } a.content-link, a.inline-roll { color: #222; +} +.journal-page-header, +.journal-page-content { + color: #222; } \ No newline at end of file diff --git a/system.json b/system.json index 21e3b72..3ceab64 100644 --- a/system.json +++ b/system.json @@ -107,7 +107,7 @@ "styles": [ "styles/simple.css" ], - "version": "10.0.27", + "version": "10.0.29", "compatibility": { "minimum": "10", "verified": "10", @@ -115,7 +115,7 @@ }, "title": "Warhero RPG", "manifest": "https://www.uberwald.me/gitea/public/fvtt-warhero/raw/branch/master/system.json", - "download": "https://www.uberwald.me/gitea/uberwald/fvtt-warhero/archive/fvtt-warhero-10.0.27.zip", + "download": "https://www.uberwald.me/gitea/uberwald/fvtt-warhero/archive/fvtt-warhero-10.0.29.zip", "url": "https://www.uberwald.me/gitea/public/fvtt-warhero", "background": "images/ui/warhero_welcome_page.webp", "id": "fvtt-warhero" diff --git a/template.json b/template.json index 23e714f..f806f45 100644 --- a/template.json +++ b/template.json @@ -10,7 +10,7 @@ "biodata": { "class": "", "age": 0, - "size": 0, + "size": 3, "weight": "", "height": "", "hair": "", @@ -332,6 +332,7 @@ "equipped": false, "slotused": 1, "slotlocation": "backpack", + "providedslot": 0, "description": "" }, "power": { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 090ca98..c18966b 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -103,17 +103,17 @@ {{/if}} {{/each}} - {{#each competency.shields as |flag key|}} - {{#if flag}} + {{#each competency.shields as |cdata key|}} + {{#if cdata}}
  • - {{localize "WH.ui.shields"}} {{key}} + {{localize "WH.ui.shields"}} {{localize cdata.label}}
  • {{/if}} {{/each}} - {{#each competency.armors as |flag key|}} - {{#if flag}} + {{#each competency.armors as |cdata key|}} + {{#if cdata}}
  • - {{localize "WH.ui.armors"}} {{key}} + {{localize "WH.ui.armors"}} {{localize cdata.label}}
  • {{/if}} {{/each}} @@ -446,7 +446,7 @@
     
    - +
    {{#each slot.content as |item itemKey|}} @@ -486,20 +486,20 @@ @@ -508,8 +508,8 @@
    diff --git a/templates/item-class-sheet.html b/templates/item-class-sheet.html index e11dfd5..35993f7 100644 --- a/templates/item-class-sheet.html +++ b/templates/item-class-sheet.html @@ -22,7 +22,7 @@