diff --git a/lang/en.json b/lang/en.json index 864696a..00b8d8f 100644 --- a/lang/en.json +++ b/lang/en.json @@ -37,9 +37,11 @@ "WH.ui.weapons": "Weapons", "WH.ui.armors": "Armors", "WH.ui.shields": "Shields", + "WH.ui.weapon": "Weapon", "WH.ui.Strength": "Strength", "WH.ui.Instinct": "Instinct", + "WH.ui.Dexterity": "Dexterity", "WH.ui.Mind": "Mind", "WH.ui.Type": "Type", "WH.ui.HitPoints": "Hit Points", @@ -48,6 +50,7 @@ "WH.ui.Mana": "Mana", "WH.ui.Initiative": "Initiative", "WH.ui.Movement": "Movement", + "WH.ui.power": "Power", "WH.ui.Qty": "Qty", "WH.ui.maxslots": "Max slots", diff --git a/modules/warhero-actor-sheet.js b/modules/warhero-actor-sheet.js index 48bf361..b5a0832 100644 --- a/modules/warhero-actor-sheet.js +++ b/modules/warhero-actor-sheet.js @@ -137,12 +137,21 @@ export class WarheroActorSheet extends ActorSheet { this.actor.rollFromType(rollType, statKey) }); html.find('.roll-weapon').click((event) => { - const li = $(event.currentTarget).parents(".item"); - const skillId = li.data("item-id") - this.actor.rollWeapon(skillId) + const li = $(event.currentTarget).parents(".item") + const weaponId = li.data("item-id") + this.actor.rollWeapon(weaponId) }); - - + html.find('.power-roll').click((event) => { + const li = $(event.currentTarget).parents(".item") + const powerId = li.data("item-id") + this.actor.rollPower(powerId) + }); + html.find('.roll-damage').click((event) => { + const li = $(event.currentTarget).parents(".item") + const weaponId = li.data("item-id") + this.actor.rollDamage(weaponId) + }); + html.find('.lock-unlock-sheet').click((event) => { this.options.editScore = !this.options.editScore; this.render(true); diff --git a/modules/warhero-actor.js b/modules/warhero-actor.js index f01d47d..8fb4c96 100644 --- a/modules/warhero-actor.js +++ b/modules/warhero-actor.js @@ -183,8 +183,22 @@ export class WarheroActor extends Actor { return comp; } /* -------------------------------------------- */ + prepareWeapon(weapon) { + let formula = weapon.system.damage + if (weapon.system.weapontype == "long") { + formula += "+" + this.system.statistics.str.value + } + if (weapon.system.weapontype == "twohanded") { + formula += "+" + Math.floor(this.system.statistics.str.value*1.5) + } + weapon.damageFormula = formula + } + /* -------------------------------------------- */ getWeapons() { let comp = duplicate(this.items.filter(item => item.type == 'weapon') || []); + for (let weapon of comp) { + this.prepareWeapon(weapon) + } WarheroUtility.sortArrayObjectsByName(comp) return comp; } @@ -521,6 +535,15 @@ export class WarheroActor extends Actor { return this.items.find(cond => cond.type == "condition" && cond.system.targetadvantage) } + /* -------------------------------------------- */ + 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}) + return true + } /* -------------------------------------------- */ getCommonRollData() { let rollData = WarheroUtility.getBasicRollData() @@ -547,31 +570,41 @@ export class WarheroActor extends Actor { let weapon = this.items.get(weaponId) if (weapon) { weapon = duplicate(weapon) - let skill = this.items.find(item => item.name.toLowerCase() == weapon.system.skill.toLowerCase()) - if (skill) { - skill = duplicate(skill) - WarheroUtility.updateSkill(skill) - let abilityKey = skill.system.ability - let rollData = this.getCommonRollData(abilityKey) - rollData.mode = "weapon" - rollData.skill = skill - rollData.weapon = weapon - rollData.img = weapon.img - if (!rollData.forceDisadvantage) { // This is an attack, check if disadvantaged - rollData.forceDisadvantage = this.isAttackDisadvantage() - } - /*if (rollData.weapon.system.isranged && rollData.tokensDistance > WarheroUtility.getWeaponMaxRange(rollData.weapon) ) { - ui.notifications.warn(`Your target is out of range of your weapon (max: ${WarheroUtility.getWeaponMaxRange(rollData.weapon)} - current : ${rollData.tokensDistance})` ) - return - }*/ - this.startRoll(rollData) - } else { - ui.notifications.warn("Unable to find the relevant skill for weapon " + weapon.name) - } + let rollData = this.getCommonRollData() + rollData.mode = "weapon" + rollData.stat = duplicate(this.system.statistics.dex) + rollData.weapon = weapon + rollData.img = weapon.img + this.startRoll(rollData) } } - - + /* -------------------------------------------- */ + rollDamage(weaponId) { + let weapon = this.items.get(weaponId) + if (weapon) { + weapon = duplicate(weapon) + this.prepareWeapon(weapon) + let rollData = this.getCommonRollData() + rollData.mode = "damage" + rollData.weapon = weapon + rollData.img = weapon.img + this.startRoll(rollData) + } + } + /* -------------------------------------------- */ + rollPower(powerId) { + let power = this.items.get(powerId) + if (power) { + power = duplicate(power) + let rollData = this.getCommonRollData() + rollData.mode = "power" + rollData.power = power + rollData.img = power.img + rollData.hasBM = false + this.startRoll(rollData) + } + } + /* -------------------------------------------- */ async startRoll(rollData) { this.syncRoll(rollData) diff --git a/modules/warhero-roll-dialog.js b/modules/warhero-roll-dialog.js index 047b092..da94df4 100644 --- a/modules/warhero-roll-dialog.js +++ b/modules/warhero-roll-dialog.js @@ -58,23 +58,8 @@ export class WarheroRollDialog extends Dialog { } $(function () { onLoad(); }); - html.find('#advantage').change((event) => { - this.rollData.advantage = event.currentTarget.value - }) - html.find('#disadvantage').change((event) => { - this.rollData.disadvantage = 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('#powerLevel').change((event) => { + this.rollData.powerLevel = event.currentTarget.value }) html.find('#bonusMalus').change((event) => { this.rollData.bonusMalus = Number(event.currentTarget.value) diff --git a/modules/warhero-utility.js b/modules/warhero-utility.js index ccfc988..b1a117f 100644 --- a/modules/warhero-utility.js +++ b/modules/warhero-utility.js @@ -540,6 +540,30 @@ export class WarheroUtility { let actor = game.actors.get(rollData.actorId) + if ( rollData.mode == "power") { + let manaCost = Array.from(rollData.powerLevel)[0] + if( actor.spentMana(manaCost)) { + let powerKey = "level"+rollData.powerLevel + rollData.powerText = rollData.power.system[powerKey] + let msg = await this.createChatWithRollMode(rollData.alias, { + content: await renderTemplate(`systems/fvtt-warhero/templates/chat-generic-result.html`, rollData) + }) + msg.setFlag("world", "rolldata", rollData) + } + return + } + if ( rollData.mode == "damage") { + let myRoll = new Roll(rollData.weapon.damageFormula + "+" + rollData.bonusMalus).roll({ async: false }) + await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")) + rollData.roll = myRoll + + let msg = await this.createChatWithRollMode(rollData.alias, { + content: await renderTemplate(`systems/fvtt-warhero/templates/chat-generic-result.html`, rollData) + }) + msg.setFlag("world", "rolldata", rollData) + return + } + // ability/save/size => 0 let diceFormula = "1d20" if ( rollData.stat) { @@ -667,7 +691,9 @@ export class WarheroUtility { rollId: randomID(16), rollMode: game.settings.get("core", "rollMode"), advantage: "none", - bonusMalus: 0 + bonusMalus: 0, + powerLevel: "1", + hasBM: true } WarheroUtility.updateWithTarget(rollData) return rollData diff --git a/system.json b/system.json index 0633185..8ef098a 100644 --- a/system.json +++ b/system.json @@ -100,7 +100,7 @@ "styles": [ "styles/simple.css" ], - "version": "10.0.6", + "version": "10.0.7", "compatibility": { "minimum": "10", "verified": "10", @@ -108,7 +108,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.6.zip", + "download": "https://www.uberwald.me/gitea/uberwald/fvtt-warhero/archive/fvtt-warhero-10.0.7.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 f98f5da..a5827db 100644 --- a/template.json +++ b/template.json @@ -28,9 +28,9 @@ "style": "dropdown", "value": 0 }, - "ist": { - "label": "WH.ui.Instinct", - "abbrev": "ist", + "dex": { + "label": "WH.ui.Dexterity", + "abbrev": "dex", "style": "dropdown", "value": 0 }, diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 97cff68..63973a2 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -82,7 +82,7 @@

- + @@ -93,11 +93,11 @@
  • - {{weapon.name}} + {{weapon.name}} - {{weapon.system.weapontype}} + {{weapon.system.weapontype}} - {{perk.system.damage}} + {{weapon.damageFormula}}
     
    @@ -125,7 +125,7 @@
  • - {{shield.name}} + {{shield.name}} {{shield.system.shieldtype}} @@ -157,7 +157,7 @@
  • - {{armor.name}} + {{armor.name}} {{armor.system.armortype}} @@ -193,7 +193,7 @@ - {{power.name}} + {{power.name}}
     
    diff --git a/templates/chat-generic-result.html b/templates/chat-generic-result.html index a757545..c000843 100644 --- a/templates/chat-generic-result.html +++ b/templates/chat-generic-result.html @@ -13,19 +13,26 @@
    {{/if}} -
    -
    +
    +
      + {{#if stat}} +
    • {{localize stat.label}} : {{stat.value}}
    • + {{/if}} + {{#if weapon}} +
    • {{localize "WH.ui.weapon"}} : {{weapon.name}}
    • + {{/if}} + {{#if hasBM}} +
    • Bonus/Malus : {{bonusMalus}}
    • + {{/if}} + + {{#if power}} +
    • {{localize "WH.ui.power"}} : {{power.name}}
    • +
    • {{{powerText}}}
    • + {{else}} +
    • Result : {{roll.total}}
    • + {{/if}} -
      -
        - {{#if stat}} -
      • {{localize stat.label}} : {{stat.value}}
      • - {{/if}} -
      • Bonus/Malus : {{bonusMalus}}
      • - -
      • Result : {{roll.total}}
      • - -
      -
      +
    +
    diff --git a/templates/partial-actor-stat-block.html b/templates/partial-actor-stat-block.html index b7eddc9..9ec65e6 100644 --- a/templates/partial-actor-stat-block.html +++ b/templates/partial-actor-stat-block.html @@ -2,7 +2,7 @@

    {{#if roll}} - {{localize stat.label}} + {{localize stat.label}} {{else}} {{localize stat.label}} {{/if}} diff --git a/templates/roll-dialog-generic.html b/templates/roll-dialog-generic.html index 8afd755..301c1dd 100644 --- a/templates/roll-dialog-generic.html +++ b/templates/roll-dialog-generic.html @@ -17,8 +17,14 @@ {{#if weapon}}
    - Weapon : - {{weapon.name}} + Weapon : + {{weapon.name}} + {{#if (eq mode "damage")}} +
    + Damage : + {{weapon.damageFormula}} +
    + {{/if}}
    {{/if}} @@ -33,6 +39,26 @@ {{/if}} + {{#if power}} +
    + Power : + {{power.name}} +
    +
    + Power Level : + +
    + {{/if}} + + {{#if hasBM}}
    Bonus/Malus :
    - + {{/if}} + + \ No newline at end of file