[Shadowrun5thA] add extended rolls

This commit is contained in:
Stexinator
2021-11-11 18:31:18 +01:00
parent 69e9fe6d3a
commit 8a32aee31d
2 changed files with 186 additions and 6 deletions
+178 -2
View File
@@ -38,7 +38,7 @@
</div>
<div class="content1">
<div class="content1Main">
<div class="statblock">
<h2>Attributes</h2>
<div class="statcol statcol1">
@@ -267,6 +267,7 @@ Can lift overhead (Strength + Nethits) x 5kg}}"></button>
<div class="rolllabel"><label> </label></div>
<div class="rolllabel"><label>Standard Roll</label></div>
<div class="rolllabel"><label>Edge Roll</label></div>
<div class="rolllabel"><label>Extended Roll</label></div>
</div>
<div class="rollrow">
<div class="rolllabel"><label>Without Wounds</label></div>
@@ -276,6 +277,9 @@ Can lift overhead (Strength + Nethits) x 5kg}}"></button>
<div class="rolllabel">
<button type="action" class="standardroll" name="act_roll" title="Roll with a given Dicepool + Edge and exploding sixes without Woundpenalty" value="@{gmroll}&{template:shadowrun}{{name=@{character_name}}}{{val1=Dice-Pool}}{{val1_num=[[?{Dice-Pool|6}]]}}{{val2=Edge}}{{val2_num=[[@{edg_total}]]}}{{result=[[(?{Dice-Pool}+@{edg_total})d6!cs>5>5sd]]}}{{description=?{Description}}}"></button>
</div>
<div class="rolllabel">
<button type="action" class="standardroll" name="act_extendedroll" title="Roll with a given Dicepool without Woundpenalty" value="@{gmroll}&{template:extendedRoll}{{name=@{character_name}}}{{roll_name=?{Description}}}{{dice_num=[[?{Dice-Pool|6}]]}}{{limit_num=[[?{Limit|6}]]}}{{result=[[(?{Dice-Pool})d6cs>5>5sdkh[[?{Limit}]]]]}}"></button>
</div>
</div>
<div class="rollrow">
<div class="rolllabel"><label>With Wounds and sustained spells</label></div>
@@ -285,6 +289,9 @@ Can lift overhead (Strength + Nethits) x 5kg}}"></button>
<div class="rolllabel">
<button type="action" class="standardroll" name="act_roll" title="Roll with a given Dicepool + Edge and exploding sixes with Woundpenalty" value="@{gmroll}&{template:shadowrun}{{name=@{character_name}}}{{val1=Dice-Pool}}{{val1_num=[[?{Dice-Pool|6}]]}}{{val2=Edge}}{{val2_num=[[@{edg_total}]]}}{{wounds_num=[[@{wound_total}]]}}{{sustainedspells=[[@{sustainedspells}*2]]}}{{result=[[(?{Dice-Pool}+@{edg_total}-[[@{wound_total}]]-[[@{sustainedspells}*2]])d6!cs>5>5sd]]}}{{description=?{Description}}}"></button>
</div>
<div class="rolllabel">
<button type="action" class="standardroll" name="act_extendedroll" title="Roll with a given Dicepool with Woundpenalty" value="@{gmroll}&{template:extendedRoll}{{name=@{character_name}}}{{roll_name=?{Description}}}{{dice_num=[[?{Dice-Pool|6}]]}}{{limit_num=[[?{Limit|6}]]}}{{wounds_num=[[@{wound_total}]]}}{{sustainedspells=[[@{sustainedspells}*2]]}}{{result=[[(?{Dice-Pool}-[[@{wound_total}]]-[[@{sustainedspells}*2]])d6cs>5>5sdkh[[?{Limit}]]]]}}"></button>
</div>
</div>
</div>
<div class="limits">
@@ -10399,6 +10406,7 @@ Click again to switch to Manual and Remote">
<!-- Buttons used for reaction rolls-->
<div class="hidden-section" style="display:none">
<button type="action" name="act_rollextended"></button>
<button type="action" name="act_reactdodge"></button>
<button type="action" name="act_reactsoak"></button>
</div>
@@ -13235,7 +13243,7 @@ on('change:repeating_armors remove:repeating_armors', function(){
///////////////////////////
on('clicked:roll', async (event) => {
await startRoll(event.htmlAttributes.value + "{{glitch=[[0]]}}", (results) => {
await startRoll("{{glitch=[[0]]}}" + event.htmlAttributes.value, (results) => {
var glitchComputed = 0;
var amount = results.results.result.dice.filter(x => x == 1).length;
@@ -13290,7 +13298,9 @@ on('clicked:repeating_knowledge:roll clicked:repeating_alchemy:roll clicked:repe
});
});
/////////////////////////////////
// Things with Hits => drain //
/////////////////////////////////
on('clicked:repeating_rituals:roll clicked:rollSummoning',
async (event) => {
@@ -13329,7 +13339,76 @@ on('clicked:repeating_rituals:roll clicked:rollSummoning',
});
});
/////////////////////
// Extended Rolls //
/////////////////////
on('clicked:extendedroll', async (event) => {
let results = await startRoll( "{{passthrough=[[0]]}}{{glitch=[[0]]}} {{sumhits=[[0]]}}" + event.htmlAttributes.value);
var glitchComputed = 0;
var amount = results.results.result.dice.filter(x => x == 1).length;
if(amount > results.results.result.dice.length/2) {
glitchComputed = 1;
if(results.results.result.dice.filter(x => x >= 6).length == 0) {
glitchComputed = 2;
}
}
// Storing all the passthrough data required for the next roll in an Object helps for larger rolls
let rollData = {
dice: results.results.dice_num.result,
limit: results.results.limit_num.result,
totalhits: results.results.result.result,
wounds: results.results.wounds_num != null ? results.results.wounds_num.result : 0,
sustainedspells: results.results.sustainedspells != null ? results.results.sustainedspells.result : 0,
}
finishRoll(
results.rollId,
{
glitch: glitchComputed,
passthrough: rollEscape.escape(rollData),
sumhits: results.results.result.result,
}
);
});
on('clicked:rollextended', async (ev) => {
await rollExtended(ev);
});
const rollExtended = async (ev) => {
// The data we passed into the button will be stored in the originalRollId key
let previousRoll = rollEscape.unescape(ev.originalRollId);
let attrs = await asw.getAttrs(['character_name', 'gmroll', 'edgeroll','edg_total','edgn','standardroll']);
let rollBase = `${attrs.gmroll}&{template:extendedRoll}{{passthrough=[[0]]}}{{glitch=[[0]]}}{{sumhits=[[0]]}}{{tries=[[0]]}}{{name=${attrs.character_name}}}{{roll_name=again}}{{limit_num=${previousRoll.limit}}}{{edge=${attrs.edgeroll}}}{{edge_num=[[${attrs.edg_total}]]}}{{wounds_num=[[${previousRoll.wounds}]]}}{{sustainedspells=[[${previousRoll.sustainedspells}]]}}{{dice_num=[[${previousRoll.dice}-1]]}}{{result=[[(${previousRoll.dice}-1-[[${previousRoll.wounds}]]-[[${previousRoll.sustainedspells}]]+[[${attrs.edgn}*${attrs.edg_total}]])${attrs.standardroll}${attrs.edgeroll}kh${previousRoll.limit}]]}}`;
let results = await startRoll(rollBase);
let sumHits = previousRoll.totalhits + results.results.result.result;
let rollData = {
dice: results.results.dice_num.result,
limit: previousRoll.limit,
totalhits: sumHits,
wounds: previousRoll.wounds,
sustainedspells: previousRoll.sustainedspells,
}
finishRoll(results.rollId, {
sumhits: sumHits,
passthrough: rollEscape.escape(rollData),
});
}
//////////////////////////////
// Dogable weapon attacks //
//////////////////////////////
on('clicked:rollWeapon', async (event) => {
let rollPart = event.htmlAttributes.value;
@@ -13720,6 +13799,103 @@ const asw = (() => {
</rolltemplate>
<rolltemplate class="sheet-rolltemplate-extendedRoll">
<table>
<tr>
<th>
{{#name}}{{name}} rolls{{#roll_name}} {{roll_name}}{{/roll_name}}{{/name}}
</th>
</tr>
{{#subheader}}
<tr><td><div class="sheet-rolltemplate-spacer"> </div></td></tr>
<tr><td><div class="sheet-rolltemplate-sectionheading">{{subheader}}</div></td></tr>
{{/subheader}}
<tr><td><div class="sheet-rolltemplate-spacer"> </div></td></tr>
<tr><td><div class="sheet-rolltemplate-sectionheading">Dicepool</div></td></tr>
<tr>
<td>> Dice Pool({{dice_num}})</td>
</tr>
{{#tries}}
{{#^rollTotal() tries 0}}
<tr>
<td>> Tries({{tries}})</td>
</tr>
{{/^rollTotal() tries 0}}
{{/tries}}
{{#sustainedspells}}
{{#^rollTotal() sustainedspells 0}}
<tr>
<td>> Sustained spells({{sustainedspells}})</td>
</tr>
{{/^rollTotal() sustainedspells 0}}
{{/sustainedspells}}
{{#wounds_num}}
{{#^rollTotal() wounds_num 0}}
<tr>
<td>> Woundpenalty({{wounds_num}})</td>
</tr>
{{/^rollTotal() wounds_num 0}}
{{/wounds_num}}
{{#edge}}
<tr><td><div class="sheet-rolltemplate-spacer"> </div></td></tr>
<tr><td><div class="sheet-rolltemplate-sectionheading">Edge</div></td></tr>
<tr>
<td><div class="sheet-rolltemplate-limit">> Edge({{edge_num}})</div></td>
</tr>
{{/edge}}
{{^edge}}
<tr><td><div class="sheet-rolltemplate-spacer"> </div></td></tr>
<tr><td><div class="sheet-rolltemplate-sectionheading">Limit</div></td></tr>
<tr>
<td><div class="sheet-rolltemplate-limit">> Limit({{limit_num}})</div></td>
</tr>
{{/edge}}
{{#result}}
<tr><td><div class="sheet-rolltemplate-spacer"> </div></td></tr>
<tr><td><div class="sheet-rolltemplate-sectionheading">Result</div></td></tr>
{{#rollGreater() result 1}}
<tr class="sheet-rolltemplate-results-success">
<td class="result">{{result}} Successes</td>
</tr>
{{/rollGreater() result 1}}
{{#rollTotal() result 1}}
<tr class="sheet-rolltemplate-results-success">
<td class="result">{{result}} Success</td>
</tr>
{{/rollTotal() result 1}}
{{#rollTotal() result 0}}
<tr class="sheet-rolltemplate-results-fail">
<td class="result">{{result}} Successes</td>
</tr>
{{/rollTotal() result 0}}
{{#rollBetween() computed::glitch 1 1}}
<tr><td><div class="sheet-rolltemplate-spacer"> </div></td></tr>
<tr class="sheet-rolltemplate-results-fail">
<td class="result">Glitch!</td>
</tr>
{{/rollBetween() computed::glitch 1 1}}
{{#rollBetween() computed::glitch 2 2}}
<tr><td><div class="sheet-rolltemplate-spacer"> </div></td></tr>
<tr class="sheet-rolltemplate-results-fail">
<td class="result">Critical Glitch!</td>
</tr>
{{/rollBetween() computed::glitch 2 2}}
{{/result}}
<tr class="sheet-rolltemplate-after">
<td>Sum hits({{computed::sumhits}})</td>
</tr>
</table>
{{#^rollTotal() computed::passthrough 0}}
<div class="sheet-rolltemplate-button">
[Next Roll](~{{name}}|rollextended||{{computed::passthrough}})
</div>
{{/^rollTotal() computed::passthrough 0}}
</rolltemplate>
<rolltemplate class="sheet-rolltemplate-hitsToDrain">
<table>
<tr>