From c6c072c115b7388e191dfb4a0714cbd92a979e96 Mon Sep 17 00:00:00 2001 From: Batziy <55130783+Batziy@users.noreply.github.com> Date: Mon, 26 Sep 2022 16:38:40 +0200 Subject: [PATCH 1/3] Weapon Roll Moved the weapon roll HTML code to a HTML file instead of building it in JS --- module/sheets/WitcherActorSheet.js | 107 ++++------------------------ templates/sheets/weapon-attack.html | 106 +++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 95 deletions(-) diff --git a/module/sheets/WitcherActorSheet.js b/module/sheets/WitcherActorSheet.js index 8eae615c..bae7c74b 100644 --- a/module/sheets/WitcherActorSheet.js +++ b/module/sheets/WitcherActorSheet.js @@ -2096,65 +2096,6 @@ export default class WitcherActorSheet extends ActorSheet { speaker: {alias: this.actor.name}, flavor: `

${game.i18n.localize("WITCHER.Dialog.attack")}: ${item.name}

`, } - - const locationOptions = ` - - - - - - - - - - `; - - const AttackModifierOptions = ` -
-
-
-
-
-
-
-
-
-
-
-
-
-
- `; - const rangeOptions = ` - - - - - - - `; - const StrikeOptions = ` - - - - - `; - let DamageOptions = ''; - if (item.system.type.slashing){ - DamageOptions += `` - } - if (item.system.type.piercing){ - DamageOptions += `` - } - if (item.system.type.bludgeoning){ - DamageOptions += `` - } - if (item.system.type.elemental){ - DamageOptions += ``; - } - if (!item.system.type.slashing && !item.system.type.piercing && !item.system.type.bludgeoning && !item.system.type.elemental) { - DamageOptions += ``; - } let attackSkill = ""; @@ -2185,52 +2126,28 @@ export default class WitcherActorSheet extends ActorSheet { break; } - let content = `

${item.name} ${game.i18n.localize("WITCHER.Dialog.attackUse")}: ${attackSkill}

-
-
-
- -
` - if (item.system.range) { - content += ` ${item.system.range}
` - } - - content += `
-
-
-
${AttackModifierOptions}
-

${item.name} ${game.i18n.localize("WITCHER.Dialog.attackDamage")}: ${displayDmgFormula}

-
`; - - if (this.actor.type =="character" && isMeleeAttack){ - content += `
` - } - + let ammunitions = `` + let noAmmo = 0 + let ammunitionOption = `` if (item.system.usingAmmo){ - let ammunitions = this.actor.items.filter(function(item) {return item.type=="weapon" && item.system.isAmmo}); + ammunitions= this.actor.items.filter(function(item) {return item.type=="weapon" && item.system.isAmmo}); let quantity = ammunitions.sum("quantity") - content += `

${game.i18n.localize("WITCHER.Dialog.chooseAmmunition")}

` if (quantity <= 0) { - content += `
${game.i18n.localize("WITCHER.Dialog.NoAmmunation")}` + noAmmo = 1; } - else { - let ammunationOption = `` - ammunitions.forEach(element => { - ammunationOption += ``; + else { + ammunitions.forEach(element => { + ammunitionOption += ``; }); - content += `

` } } - + + let data = {item, attackSkill, displayDmgFormula, noAmmo, ammunitionOption, ammunitions} + const dialogTemplate = await renderTemplate("systems/TheWitcherTRPG/templates/sheets/weapon-attack.html", data) new Dialog({ title: `${game.i18n.localize("WITCHER.Dialog.attackWith")}: ${item.name}`, - content, + content: dialogTemplate, buttons: { Roll: { label: `${game.i18n.localize("WITCHER.Dialog.ButtonRoll")}`, diff --git a/templates/sheets/weapon-attack.html b/templates/sheets/weapon-attack.html index e69de29b..b0933c24 100644 --- a/templates/sheets/weapon-attack.html +++ b/templates/sheets/weapon-attack.html @@ -0,0 +1,106 @@ +
+

{{localize "WITCHER.Dialog.attackUse"}} {{attackSkill}}

+
+
+
+ + +
+ {{#if item.system.range}} + + +
+ {{item.system.range}} + {{/if}} + +
+ +
+ +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

{{item.name}} {{localize "WITCHER.Dialog.attackDamage"}}: {{displayDmgFormula}}

+
+ {{#if (and (eq this.actor.type "character")(isMeleeAttack))}} +
+ {{/if}} + {{#if item.system.usingAmmo}} + {{#if (eq noAmmo 1)}} +
{{localize "WITCHER.Dialog.NoAmmunation"}} + {{else}} + + {{/if}} + {{/if}} + \ No newline at end of file From a1720a748620f2915a4afa9c146115a9798f367a Mon Sep 17 00:00:00 2001 From: Batziy <55130783+Batziy@users.noreply.github.com> Date: Wed, 28 Sep 2022 12:38:41 +0200 Subject: [PATCH 2/3] Updated weapon roll window Updated the weapon roll window and fixed a bugg that prevented you from using weapon/spell roll macros. --- module/sheets/WitcherActorSheet.js | 9 +- scripts/TheWitcherTRPG.js | 4 +- styles/tab-inventory.css | 4 - styles/weapon-roll.css | 19 ++ styles/witcher-styles.css | 1 + templates/sheets/weapon-attack.html | 351 ++++++++++++++++++++-------- 6 files changed, 277 insertions(+), 111 deletions(-) create mode 100644 styles/weapon-roll.css diff --git a/module/sheets/WitcherActorSheet.js b/module/sheets/WitcherActorSheet.js index bae7c74b..9d20c39e 100644 --- a/module/sheets/WitcherActorSheet.js +++ b/module/sheets/WitcherActorSheet.js @@ -2142,7 +2142,9 @@ export default class WitcherActorSheet extends ActorSheet { } } - let data = {item, attackSkill, displayDmgFormula, noAmmo, ammunitionOption, ammunitions} + let Mymelebonus=this.actor.system.attackStats.meleeBonus + let data = {item, attackSkill, displayDmgFormula, isMeleeAttack, noAmmo, ammunitionOption, ammunitions, Mymelebonus} + const myDialogOptions ={width: 500} const dialogTemplate = await renderTemplate("systems/TheWitcherTRPG/templates/sheets/weapon-attack.html", data) new Dialog({ @@ -2171,7 +2173,6 @@ export default class WitcherActorSheet extends ActorSheet { let isRicochet = html.find("[name=isRicochet]").prop("checked"); let isBlinded = html.find("[name=isBlinded]").prop("checked"); let isSilhouetted = html.find("[name=isSilhouetted]").prop("checked"); - let isAiming = html.find("[name=isAiming]").prop("checked"); let customAim = html.find("[name=customAim]")[0].value; let range = item.system.range ? html.find("[name=range]")[0].value: null; @@ -2217,7 +2218,7 @@ export default class WitcherActorSheet extends ActorSheet { if (isRicochet) { attFormula += "-5"; } if (isBlinded) { attFormula += "-3"; } if (isSilhouetted) { attFormula += "+2"; } - if (isAiming) { attFormula += `+${customAim}`} + if (customAim>0) { attFormula += `+${customAim}`} let modifiers; @@ -2434,7 +2435,7 @@ export default class WitcherActorSheet extends ActorSheet { } } } - }).render(true) + },myDialogOptions).render(true) } diff --git a/scripts/TheWitcherTRPG.js b/scripts/TheWitcherTRPG.js index 424f7f0a..d3002e2a 100644 --- a/scripts/TheWitcherTRPG.js +++ b/scripts/TheWitcherTRPG.js @@ -184,7 +184,7 @@ async function createBoilerplateMacro(data, slot) { return ui.notifications.warn("You can only create macro buttons with the original character"); } const command = -`let actor = game.actors.get('${foundActor.id}'); +`actor = game.actors.get('${foundActor.id}'); actor.rollItem("${weapon._id}")`; let macro = game.macros.find(m => (m.name === weapon.name) && (m.command === command)); if (!macro) { @@ -213,7 +213,7 @@ actor.rollItem("${weapon._id}")`; return ui.notifications.warn("You can only create macro buttons with the original character"); } const command = -`let actor = game.actors.get('${foundActor.id}'); +`actor = game.actors.get('${foundActor.id}'); actor.rollSpell("${spell._id}")`; let macro = game.macros.find(m => (m.name === spell.name) && (m.command === command)); if (!macro) { diff --git a/styles/tab-inventory.css b/styles/tab-inventory.css index 8566ee0a..b362a596 100644 --- a/styles/tab-inventory.css +++ b/styles/tab-inventory.css @@ -20,10 +20,6 @@ flex-direction: column; } -#attackModifiers { - display: none; -} - .wrapper { position: relative; } diff --git a/styles/weapon-roll.css b/styles/weapon-roll.css new file mode 100644 index 00000000..71fba5b6 --- /dev/null +++ b/styles/weapon-roll.css @@ -0,0 +1,19 @@ +.wepon_roll_sheet input { + text-align: center !important; + margin: 0px 5px; + width: 30px; + float: right; +} + +.wepon_roll_sheet td { + height: 35px; +} + +.wepon_roll_sheet select { + margin: 0px 5px; + float: right; +} + +.wepon_roll_sheet label { + vertical-align: middle; +} \ No newline at end of file diff --git a/styles/witcher-styles.css b/styles/witcher-styles.css index 5d8d7868..4e475eeb 100644 --- a/styles/witcher-styles.css +++ b/styles/witcher-styles.css @@ -12,6 +12,7 @@ @import "./crit-wounds-table.css"; @import "./item-sheets.css"; @import "./substances.css"; +@import "./weapon-roll.css"; @font-face { font-family:'Thewitcher'; diff --git a/templates/sheets/weapon-attack.html b/templates/sheets/weapon-attack.html index b0933c24..1e32189a 100644 --- a/templates/sheets/weapon-attack.html +++ b/templates/sheets/weapon-attack.html @@ -1,106 +1,255 @@ -
+

{{localize "WITCHER.Dialog.attackUse"}} {{attackSkill}}

-
-
- - -
- {{#if item.system.range}} - - -
- {{item.system.range}} - {{/if}} - -
-
+

{{localize "WITCHER.Dialog.attackModifierse"}}

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+
+

{{item.name}} {{localize "WITCHER.Dialog.attackDamage"}}: {{displayDmgFormula}}

+
+ + + + + +
+ + + +
+ + + {{#if isMeleeAttack}} + + + {{/if}} + {{#if item.system.usingAmmo}} + {{#if (eq noAmmo 1)}} + + {{else}} + + + {{/if}} + {{/if}} + +
+ + + {{Mymelebonus}} + + + + + +
+
+{{log "!!!!! DOCUMENT DATA !!!!!"}} +{{log this}} \ No newline at end of file From 136805ce76fa0d80b0b9a7fa16484b6ac972e303 Mon Sep 17 00:00:00 2001 From: Batziy <55130783+Batziy@users.noreply.github.com> Date: Wed, 5 Oct 2022 09:32:20 +0200 Subject: [PATCH 3/3] Fixed --- module/sheets/WitcherActorSheet.js | 8 ++++---- templates/sheets/weapon-attack.html | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/module/sheets/WitcherActorSheet.js b/module/sheets/WitcherActorSheet.js index 72d98c19..b16f30c6 100644 --- a/module/sheets/WitcherActorSheet.js +++ b/module/sheets/WitcherActorSheet.js @@ -2130,7 +2130,7 @@ export default class WitcherActorSheet extends ActorSheet { let noAmmo = 0 let ammunitionOption = `` if (item.system.usingAmmo){ - ammunitions= this.actor.items.filter(function(item) {return item.type=="weapon" && item.system.isAmmo}); + ammunitions = this.actor.items.filter(function(item) {return item.type=="weapon" && item.system.isAmmo}); let quantity = ammunitions.sum("quantity") if (quantity <= 0) { noAmmo = 1; @@ -2142,7 +2142,7 @@ export default class WitcherActorSheet extends ActorSheet { } } - let Mymelebonus=this.actor.system.attackStats.meleeBonus + let Mymelebonus = this.actor.system.attackStats.meleeBonus let data = {item, attackSkill, displayDmgFormula, isMeleeAttack, noAmmo, ammunitionOption, ammunitions, Mymelebonus} const myDialogOptions ={width: 500} const dialogTemplate = await renderTemplate("systems/TheWitcherTRPG/templates/sheets/weapon-attack.html", data) @@ -2218,7 +2218,7 @@ export default class WitcherActorSheet extends ActorSheet { if (isRicochet) { attFormula += "-5"; } if (isBlinded) { attFormula += "-3"; } if (isSilhouetted) { attFormula += "+2"; } - if (customAim>0) { attFormula += `+${customAim}`} + if (customAim > 0) { attFormula += `+${customAim}`} let modifiers; @@ -2435,7 +2435,7 @@ export default class WitcherActorSheet extends ActorSheet { } } } - },myDialogOptions).render(true) + }, myDialogOptions).render(true) } diff --git a/templates/sheets/weapon-attack.html b/templates/sheets/weapon-attack.html index 1e32189a..13047725 100644 --- a/templates/sheets/weapon-attack.html +++ b/templates/sheets/weapon-attack.html @@ -90,7 +90,7 @@

{{localize "WITCHER.Dialog.attackUse"}} {{attackSkill}}

{{/if}}
-

{{localize "WITCHER.Dialog.attackModifierse"}}

+

{{localize "WITCHER.Dialog.attackModifiers"}}

@@ -103,7 +103,7 @@

{{localize "WITCHER.Dialog.attackModifierse"}}

- + @@ -111,7 +111,7 @@

{{localize "WITCHER.Dialog.attackModifierse"}}

- + @@ -119,7 +119,7 @@

{{localize "WITCHER.Dialog.attackModifierse"}}

- + @@ -127,7 +127,7 @@

{{localize "WITCHER.Dialog.attackModifierse"}}

- + @@ -153,7 +153,7 @@

{{localize "WITCHER.Dialog.attackModifierse"}}

{{else}}
- + @@ -161,7 +161,7 @@

{{localize "WITCHER.Dialog.attackModifierse"}}

- + @@ -169,7 +169,7 @@

{{localize "WITCHER.Dialog.attackModifierse"}}

- + @@ -177,7 +177,7 @@

{{localize "WITCHER.Dialog.attackModifierse"}}

- + @@ -185,7 +185,7 @@

{{localize "WITCHER.Dialog.attackModifierse"}}

- + @@ -193,7 +193,7 @@

{{localize "WITCHER.Dialog.attackModifierse"}}

- + @@ -201,7 +201,7 @@

{{localize "WITCHER.Dialog.attackModifierse"}}

- + @@ -238,7 +238,7 @@

{{item.name}} {{localize "WITCHER.Dialog.attackDamage"}}: {{displayDmgFormul

- +