From 8be6fc3e68ba114d00fcda42e55337af4c43d600 Mon Sep 17 00:00:00 2001 From: Stexinator Date: Mon, 31 Oct 2022 22:45:02 +0100 Subject: [PATCH] [Shadowrun5thA] add edge reroll via click on successes --- Shadowrun5th/Shadowrun5th.css | 12 ++- Shadowrun5th/Shadowrun5th.html | 152 ++++++++++++++++++++++++++++++--- 2 files changed, 149 insertions(+), 15 deletions(-) diff --git a/Shadowrun5th/Shadowrun5th.css b/Shadowrun5th/Shadowrun5th.css index 52a3e9eba8..91ecd25582 100644 --- a/Shadowrun5th/Shadowrun5th.css +++ b/Shadowrun5th/Shadowrun5th.css @@ -1791,6 +1791,7 @@ div.collapsible { .sheet-rolltemplate-reactsoak table, .sheet-rolltemplate-hitsToDrain table, .sheet-rolltemplate-extendedRoll table, +.sheet-rolltemplate-reroll table, .sheet-rolltemplate-shadowrun-forcedglitch table, .sheet-rolltemplate-shadowrun table{ background-color:#111111; @@ -1806,6 +1807,7 @@ div.collapsible { .sheet-rolltemplate-reactsoak img, .sheet-rolltemplate-hitsToDrain img, .sheet-rolltemplate-extendedRoll img, +.sheet-rolltemplate-reroll img, .sheet-rolltemplate-shadowrun-forcedglitch img, .sheet-rolltemplate-shadowrun img{ float:left; @@ -1817,6 +1819,7 @@ div.collapsible { .sheet-rolltemplate-reactsoak table th, .sheet-rolltemplate-hitsToDrain table th, .sheet-rolltemplate-extendedRoll table th, +.sheet-rolltemplate-reroll table th, .sheet-rolltemplate-shadowrun-forcedglitch table th, .sheet-rolltemplate-shadowrun table th{ background-color:#444444; @@ -1830,6 +1833,7 @@ div.collapsible { .sheet-rolltemplate-reactsoak table .inlinerollresult, .sheet-rolltemplate-hitsToDrain table .inlinerollresult, .sheet-rolltemplate-extendedRoll table .inlinerollresult, +.sheet-rolltemplate-reroll table .inlinerollresult, .sheet-rolltemplate-shadowrun-forcedglitch table .inlinerollresult, .sheet-rolltemplate-shadowrun table .inlinerollresult{ border:none !important; @@ -1841,6 +1845,7 @@ div.collapsible { text-align:center; margin:5em 0em 5em 0em; color:#99eeee; + border: none } .sheet-rolltemplate-results-fail{ @@ -1883,7 +1888,6 @@ div.collapsible { } - .sheet-rolltemplate-button a[href^="~"]{ width: 30%; margin-top: -10px; @@ -1894,3 +1898,9 @@ div.collapsible { color: #eebb99; background-color: black; } + +.sheet-rolltemplate-results-success a[href^="~"]{ + color:inherit; + border: none; + background: inherit; +} \ No newline at end of file diff --git a/Shadowrun5th/Shadowrun5th.html b/Shadowrun5th/Shadowrun5th.html index b8dcd5fd12..749946248c 100644 --- a/Shadowrun5th/Shadowrun5th.html +++ b/Shadowrun5th/Shadowrun5th.html @@ -13377,6 +13377,7 @@ Click again to switch to Manual and Remote"> + @@ -14109,7 +14110,6 @@ async function migrateComplexforms() { attributes["complexformsMigration102022"] = true; - console.log(attributes); await asw.setAttrs(attributes); } @@ -15582,9 +15582,6 @@ async function importSingleRepeatingWeapon(weapon, ammunition, attributes) { //make clips unique var clips = [...new Map(weapon.clips.clip.slice().reverse().map(v => [v.name, v])).values()].reverse() - console.log(weapon.name); - console.log(clips); - for(var j=0; j < clips.length && amountImported < 4; j++){ var newrowid=generateRowID(); @@ -16687,7 +16684,7 @@ on('change:repeating_armors remove:repeating_armors', function(){ /////////////////////////// on('clicked:roll', async (event) => { - await startRoll( event.htmlAttributes.value + "{{glitch=[[0]]}}", (results) => { + await startRoll( event.htmlAttributes.value + "{{glitch=[[0]]}}{{reroll=[[0]]}}", (results) => { var glitchComputed = 0; var amount = results.results.result.dice.filter(x => x == 1).length; @@ -16700,11 +16697,17 @@ on('clicked:roll', async (event) => { } } + var reroll = { + dice: results.results.result.dice.length, + successes: results.results.result.result, + limit: results.results.limit_num.result + results.results.limit_mod.result + } + finishRoll( results.rollId, { glitch: glitchComputed, - + reroll: rollEscape.escape(reroll) } ); }); @@ -16719,7 +16722,7 @@ on('clicked:repeating_knowledge:roll clicked:repeating_alchemy:roll clicked:repe let rollPart = event.htmlAttributes.value.replaceAll('prefix-', `${prefix}`); - await startRoll(rollPart + "{{glitch=[[0]]}}", (results) => { + await startRoll(rollPart + "{{glitch=[[0]]}}{{reroll=[[0]]}}", (results) => { var glitchComputed = 0; var amount = results.results.result.dice.filter(x => x == 1).length; @@ -16732,11 +16735,17 @@ on('clicked:repeating_knowledge:roll clicked:repeating_alchemy:roll clicked:repe } } + var reroll = { + dice: results.results.result.dice.length, + successes: results.results.result.result, + limit: results.results.limit_num.result + results.results.limit_mod.result + } + finishRoll( results.rollId, { glitch: glitchComputed, - + reroll: rollEscape.escape(reroll) } ); }); @@ -16849,6 +16858,35 @@ const rollExtended = async (ev) => { }); } +/////////////////// +// Edge Reroll // +/////////////////// + +on('clicked:reroll', async (ev) => { + await reroll(ev); +}); + +const reroll = async (ev) => { + // The data we passed into the button will be stored in the originalRollId key + let roll = rollEscape.unescape(ev.originalRollId); + + let attrs = await asw.getAttrs(['gmroll','character_name']); + + let rollBase = `${attrs.gmroll}&{template:reroll}{{name=${attrs.character_name}}}{{roll_name=again}}{{dice=[[${roll.dice}]]}}{{prior=[[${roll.successes}]]}}{{limit=Limit}}{{limit_num=[[${roll.limit}]]}}{{result=[[ {[[[[${roll.dice}-${roll.successes}]]d6>5sd+${roll.successes}]], [[{${roll.limit}+0d0}]]}kl1 ]] }}{{passthrough=[[0]]}}`; + let reroll = await startRoll(rollBase); + + let passthrough = 0; + if( roll.attack != undefined) { + let attack = roll.attack; + attack.attackHits = reroll.results.result.result; + passthrough = rollEscape.escape(attack); + } + + finishRoll(reroll.rollId, { + passthrough: passthrough, + }); +} + ////////////////////////////// // Dogable weapon attacks // @@ -16913,7 +16951,7 @@ on('clicked:repeating_ammotype1:roll clicked:repeating_ammotype2:roll clicked:re const rollDogableAttack = async (rollPart, dmgType) => { - let attackRoll = await startRoll( rollPart + " {{passthrough=[[0]]}}{{glitch=[[0]]}} "); + let attackRoll = await startRoll( rollPart + " {{passthrough=[[0]]}}{{glitch=[[0]]}}{{reroll=[[0]]}}"); var glitchComputed = 0; var amount = attackRoll.results.result.dice.filter(x => x == 1).length; @@ -16942,12 +16980,19 @@ const rollDogableAttack = async (rollPart, dmgType) => { attackDmgType: attackDmgType, } + var reroll = { + dice: attackRoll.results.result.dice.length, + successes: attackRoll.results.result.result, + limit: attackRoll.results.limit_num.result, + attack: rollData + } + finishRoll( attackRoll.rollId, { glitch: glitchComputed, passthrough: rollEscape.escape(rollData), - + reroll: rollEscape.escape(reroll) } ); } @@ -17008,7 +17053,6 @@ const rollReactSoak = async (ev) => { if(dmgType.includes('P') && attrs.armor_total > 0) { dmgType = dmgRoll.attackDamage > (attrs.armor_total + armorPenetration + soakRoll.results.mod.result) ? dmgRoll.attackDmgType : 'S'; - console.log("resulting dmgType: "+dmgType+ " dmg: "+dmgRoll.attackDamage+" armorResult: "+ (attrs.armor_total + armorPenetration + soakRoll.results.mod.result)); } finishRoll(soakRoll.rollId, { @@ -17228,17 +17272,17 @@ const asw = (() => { {{#rollGreater() result 1}} - {{result}} Successes + {{result}} [Successes](~{{name}}|reroll||{{computed::reroll}}) {{/rollGreater() result 1}} {{#rollTotal() result 1}} - {{result}} Success + {{result}} [Success](~{{name}}|reroll||{{computed::reroll}}) {{/rollTotal() result 1}} {{#rollTotal() result 0}} - {{result}} Successes + {{result}} [Successes](~{{name}}|reroll||{{computed::reroll}}) {{/rollTotal() result 0}} {{#rollBetween() computed::glitch 1 1}} @@ -17333,6 +17377,86 @@ const asw = (() => { + + + + + + + + + + + + {{#dice}} + + + + {{/dice}} + {{#prior}} + + + + {{/prior}} + {{#limit}} + + + + + + + + + + {{/limit}} + {{#result}} + + + + + + + {{#rollGreater() result 1}} + + + + {{/rollGreater() result 1}} + {{#rollTotal() result 1}} + + + + {{/rollTotal() result 1}} + {{#rollTotal() result 0}} + + + + {{/rollTotal() result 0}} + {{/result}} +
+ {{#name}}{{name}} rolls{{#roll_name}} {{roll_name}}{{/roll_name}}{{/name}}
+
+
+
Dicepool
+
> Dice({{dice}})
> Prior successes({{prior}})
+
+
+
Limit
+
+
> {{limit}}({{limit_num}})
+
+
+
+
Result
+
{{result}} Successes
{{result}} Success
{{result}} Successes
+ {{#rollGreater() result 0}} + {{#^rollTotal() computed::passthrough 0}} +
+ [Dodge](~selected|reactdodge||{{computed::passthrough}}) +
+ {{/^rollTotal() computed::passthrough 0}} + {{/rollGreater() result 0}} +
+