Replace saves row and 3 and 4 stat check dice with one set of dice for each and radio buttons for the number of dice.
This commit is contained in:
+110
-77
@@ -33,8 +33,8 @@
|
||||
<!-- ST -->
|
||||
<div class=sheet-flex-centered>
|
||||
<span>
|
||||
<span title="Base Strength">
|
||||
<span class=sheet-stat-label>ST</span>
|
||||
<span title="Base Strength">
|
||||
<span class=sheet-stat-label >ST</span>
|
||||
<input class=sheet-tiny-input type=text name="attr_ST_max" value="8"/>
|
||||
</span>
|
||||
<span class=sheet-stat-plus>+</span>
|
||||
@@ -43,15 +43,14 @@
|
||||
<span class=sheet-computed-value title="Final Strength. Base plus Adjustments, not counting Wounds or Fatigue." name="attr_ST"/>
|
||||
</span>
|
||||
<span>
|
||||
<button class=sheet-dice-button type="action" title="3d6 Strength Check" name="act_st_check3">3</button>
|
||||
<button class=sheet-dice-button type="action" title="4d6 Strength Check" name="act_st_check4">4</button>
|
||||
<button class=sheet-dice-button type="action" title="Strength Check" name="act_st_check"></button>
|
||||
</span>
|
||||
</div>
|
||||
<!-- DX -->
|
||||
<div class=sheet-flex-centered>
|
||||
<span>
|
||||
<span title="Base Dexterity">
|
||||
<span class=sheet-stat-label>DX</span>
|
||||
<span class=sheet-stat-label >DX</span>
|
||||
<input class=sheet-tiny-input type=text name="attr_DX_max" value="8"/>
|
||||
</span>
|
||||
<span class=sheet-stat-plus>+</span>
|
||||
@@ -60,8 +59,7 @@
|
||||
<span class=sheet-computed-value title="Final Dexterity. Base plus Adjustments minus Armor Penalties." name="attr_DX"/>
|
||||
</span>
|
||||
<span>
|
||||
<button class=sheet-dice-button type="action" title="3d6 Dexterity Check" name="act_dx_check3">3</button>
|
||||
<button class=sheet-dice-button type="action" title="4d6 Strength Check" name="act_dx_check4">4</button>
|
||||
<button class=sheet-dice-button type="action" title="Dexterity Check" name="act_dx_check"></button>
|
||||
</span>
|
||||
</div>
|
||||
<!-- IQ -->
|
||||
@@ -77,26 +75,31 @@
|
||||
<span class=sheet-computed-value title="Final IQ. Base plus Adjustments." name="attr_IQ"/>
|
||||
</span>
|
||||
<span>
|
||||
<button class=sheet-dice-button type="action" title="3d6 IQ Check" name="act_iq_check3">3</button>
|
||||
<button class=sheet-dice-button type="action" title="4d6 IQ Check" name="act_iq_check4">4</button>
|
||||
<button class=sheet-dice-button type="action" title="IQ Check" name="act_iq_check"></button>
|
||||
</span>
|
||||
</div>
|
||||
<!-- SAVES -->
|
||||
<div class=sheet-flex-centered>
|
||||
<span title="Blank saves, provided for the criticals. Success on roll ≤ the stat.">
|
||||
<span class=sheet-stat-label>Saves</span>
|
||||
</span>
|
||||
<span>
|
||||
<button class=sheet-dice-button type="action" title="2d6 Save" name="act_save2">2</button>
|
||||
<button class=sheet-dice-button type="action" title="2d6 Save" name="act_save3">3</button >
|
||||
<button class=sheet-dice-button type="action" title="2d6 Save" name="act_save4">4</button>
|
||||
<button class=sheet-dice-button type="action" title="5d6 Save" name="act_save5">5</button>
|
||||
<button class=sheet-dice-button type="action" title="6d6 Save" name="act_save6">6</button>
|
||||
<button class=sheet-dice-button type="action" title="7d6 Save" name="act_save7">7</button>
|
||||
<button class=sheet-dice-button type="action" title="8d6 Save" name="act_save8">8</button>
|
||||
<input type=checkbox name=attr_save2d class=sheet-caption-checkbox hidden>
|
||||
<button class=sheet-caption-button title="Roll 2d6 for next Stat or Health Check." type="action" name="act_save2d">2d</button>
|
||||
<input type=checkbox name=attr_save3d class=sheet-caption-checkbox value='on' hidden>
|
||||
<button class=sheet-caption-button title="Roll 3d6 for next Stat or Health Check." type="action" name="act_save3d">3d</button>
|
||||
<input type=checkbox name=attr_save4d class=sheet-caption-checkbox hidden>
|
||||
<button class=sheet-caption-button title="Roll 4d6 for next Stat or Health Check." type="action" name="act_save4d">4d</button>
|
||||
<input type=checkbox name=attr_save5d class=sheet-caption-checkbox hidden>
|
||||
<button class=sheet-caption-button title="Roll 5d6 for next Stat or Health Check." type="action" name="act_save5d">5d</button>
|
||||
<input type=checkbox name=attr_save6d class=sheet-caption-checkbox value='on'hidden>
|
||||
<button class=sheet-caption-button title="Roll 6d6 for next Stat or Health Check." type="action" name="act_save6d">6d</button>
|
||||
<input type=checkbox name=attr_save7d class=sheet-caption-checkbox hidden>
|
||||
<button class=sheet-caption-button title="Roll 7d6 for next Stat or Health Check." type="action" name="act_save7d">7d</button>
|
||||
<input type=checkbox name=attr_save8d class=sheet-caption-checkbox hidden>
|
||||
<button class=sheet-caption-button title="Roll 8d6 for next Stat or Health Check." type="action" name="act_save8d">8d</button>
|
||||
</span>
|
||||
<span title="Blank check, provided for the criticals. Success on roll ≤ the number.">
|
||||
<button class=sheet-dice-button type="action" title="Blank stat check" name="act_blank_check"></button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- MA -->
|
||||
<div class=sheet-flex-centered>
|
||||
<span>
|
||||
@@ -152,8 +155,7 @@
|
||||
<span class=sheet-computed-value name="attr_health"/>
|
||||
</span>
|
||||
<span>
|
||||
<button class=sheet-dice-button type="action" title="3d6 Health Check" name="act_health_check3">3</button>
|
||||
<button class=sheet-dice-button type="action" title="4d6 Health Check" name="act_health_check4">4</button>
|
||||
<button class=sheet-dice-button type="action" title="Health Check" name="act_health_check"></button>
|
||||
</span>
|
||||
</div>
|
||||
<!-- Wounds -->
|
||||
@@ -926,7 +928,7 @@
|
||||
const diceArrayToString = function(rolls) {
|
||||
let diceString = '';
|
||||
if (rolls) {
|
||||
for (i = 0; i < rolls.length; ++i) {
|
||||
for (let i = 0; i < rolls.length; ++i) {
|
||||
let roll = rolls[i];
|
||||
if (roll == 1) diceString += 'a';
|
||||
else if (roll == 2) diceString += 'b';
|
||||
@@ -1030,17 +1032,9 @@
|
||||
|
||||
let selected = id ? (id + '_' + attrName).toLowerCase() : attrName;
|
||||
|
||||
console.log('toggling', selected)
|
||||
|
||||
getAttrs([selected], function(values) {
|
||||
let oldValue = values[selected];
|
||||
|
||||
console.log('old value is', oldValue)
|
||||
|
||||
let newValue = (oldValue == 'on' ? 0 : 'on');
|
||||
|
||||
console.log('new value is', oldValue)
|
||||
|
||||
let valueMap = {};
|
||||
// toggle this one, turn off the rest.
|
||||
valueMap[selected] = newValue;
|
||||
@@ -1218,52 +1212,42 @@
|
||||
});
|
||||
}
|
||||
|
||||
on('clicked:st_check3', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=strength}} {{stat=[[@{st}[STR]]]}} {{roll1=[[3d6]]}}");
|
||||
});
|
||||
on('clicked:st_check4', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=strength}} {{stat=[[@{st}[STR]]]}} {{roll1=[[4d6]]}}");
|
||||
});
|
||||
on('clicked:dx_check3', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=dexterity}} {{stat=[[@{dx}[DEX]]]}} {{roll1=[[3d6]]}}");
|
||||
});
|
||||
on('clicked:dx_check4', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=dexterity}} {{stat=[[@{dx}[DEX]]]}} {{roll1=[[4d6]]}}");
|
||||
});
|
||||
on('clicked:iq_check3', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=an}} {{stat_name=IQ}} {{stat=[[@{iq}[IQ]]]}} {{roll1=[[3d6]]}}");
|
||||
});
|
||||
on('clicked:iq_check4', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=an}} {{stat_name=IQ}} {{stat=[[@{iq}[IQ]]]}} {{roll1=[[4d6]]}}");
|
||||
});
|
||||
on('clicked:health_check3', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=health}} {{stat=[[@{health}[HEALTH]]]}} {{roll1=[[3d6]]}}");
|
||||
});
|
||||
on('clicked:health_check4', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=health}} {{stat=[[@{health}[HEALTH]]]}} {{roll1=[[4d6]]}}");
|
||||
});
|
||||
on('clicked:save2', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=}} {{stat=...}} {{roll1=[[2d6]]}}");
|
||||
});
|
||||
on('clicked:save3', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=}} {{stat=...}} {{roll1=[[3d6]]}}");
|
||||
});
|
||||
on('clicked:save4', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=}} {{stat=...}} {{roll1=[[4d6]]}}");
|
||||
});
|
||||
on('clicked:save5', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=}} {{stat=...}} {{roll1=[[5d6]]}}");
|
||||
});
|
||||
on('clicked:save6', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=}} {{stat=...}} {{roll1=[[6d6]]}}");
|
||||
});
|
||||
on('clicked:save7', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=}} {{stat=...}} {{roll1=[[7d6]]}}");
|
||||
});
|
||||
on('clicked:save8', (info) => {
|
||||
doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=}} {{stat=...}} {{roll1=[[8d6]]}}");
|
||||
});
|
||||
// attr is actual attribute st
|
||||
// name is the friendly name like strength
|
||||
// label is to show in the template, so like STR
|
||||
// a is whether to save a <name> roll or an <name> roll.
|
||||
const doStatRoll = function(attr, name, label, an = 'a') {
|
||||
getAttrs(saveDiceAttrs(), function(values) {
|
||||
let dice = getSaveDiceValue(values)
|
||||
s = "&{template:stat-check} {{stat_a=" + an + "}} {{stat_name=" + name + "}} {{stat=[[@{" + attr + "}[" + label + "]]]}} {{roll1=[[" + dice + "d6]]}}";
|
||||
doSaveRoll(s);
|
||||
// since we've baked dice into the string we are save.
|
||||
// We do this because that's the most common value.
|
||||
setSaveDice(3);
|
||||
});
|
||||
}
|
||||
|
||||
on('clicked:st_check', (info) => {
|
||||
doStatRoll('st', 'strength', 'STR');
|
||||
});
|
||||
on('clicked:dx_check', (info) => {
|
||||
doStatRoll('dx', 'dexterity', 'DEX');
|
||||
});
|
||||
on('clicked:iq_check', (info) => {
|
||||
doStatRoll('iq', 'IQ', 'IQ', 'an');
|
||||
});
|
||||
on('clicked:blank_check', (info) => {
|
||||
getAttrs(saveDiceAttrs(), function(values) {
|
||||
let dice = getSaveDiceValue(values)
|
||||
s = "&{template:stat-check} {{stat_a=a}} {{stat_name=}} {{stat=...}} {{roll1=[[" + dice + "d6]]}}";
|
||||
doSaveRoll(s);
|
||||
setSaveDice(3);
|
||||
});
|
||||
});
|
||||
on('clicked:health_check', (info) => {
|
||||
doStatRoll('health', 'health', 'HEALTH');
|
||||
// doSaveRoll("&{template:stat-check} {{stat_a=a}} {{stat_name=health}} {{stat=[[@{health}[HEALTH]]]}} {{roll1=[[3d6]]}}");
|
||||
});
|
||||
|
||||
on('clicked:initiative', (info) => {
|
||||
let initiativeAdjName = 'initiative_adj';
|
||||
@@ -1582,7 +1566,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Toggleable attack buttons.
|
||||
// Radio/Toggle attack buttons.
|
||||
on(' clicked:attack5d', (info) => {
|
||||
toggleCheckbox('', 'defending2');
|
||||
clearCheckbox('defending');
|
||||
@@ -1592,6 +1576,55 @@
|
||||
clearCheckbox('defending2');
|
||||
});
|
||||
|
||||
// Returns the save dice attribute name
|
||||
// give the dice.
|
||||
const saveDiceAttr = function(dice) {
|
||||
return 'save' + dice + 'd';
|
||||
}
|
||||
|
||||
// returns an array of save dice attrs.
|
||||
const saveDiceAttrs = function() {
|
||||
let attrs = []
|
||||
for (let i = 2; i < 9; ++i) {
|
||||
attrs.push(saveDiceAttr(i));
|
||||
}
|
||||
return attrs;
|
||||
}
|
||||
|
||||
// Given a value map, returns the number of dice.
|
||||
const getSaveDiceValue = function(values) {
|
||||
for (let i = 2; i < 9; ++i) {
|
||||
if (values[saveDiceAttr(i)] != 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// default.
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Tell it how many dice to use, it sets the radio
|
||||
// button.
|
||||
const setSaveDice = function(dice) {
|
||||
// Seems like you have to set attrs from a get attrs.
|
||||
getAttrs(saveDiceAttrs(), function(values) {
|
||||
for (let i = 2; i < 9; ++i) {
|
||||
values[saveDiceAttr(i)] = (i == dice) ? 'on' : 0;
|
||||
}
|
||||
setAttrs(values);
|
||||
});
|
||||
}
|
||||
|
||||
// Radio save buttons.
|
||||
on('clicked:save2d'
|
||||
+ ' clicked:save3d'
|
||||
+ ' clicked:save4d'
|
||||
+ ' clicked:save5d'
|
||||
+ ' clicked:save6d'
|
||||
+ ' clicked:save7d'
|
||||
+' clicked:save8d', (info) => {
|
||||
|
||||
setSaveDice(parseInt(info.triggerName.substring(12)) || 3);
|
||||
});
|
||||
|
||||
// Weapons Select/Expand/Describe/NC
|
||||
on('clicked:repeating_weapons', (info) => {
|
||||
|
||||
Reference in New Issue
Block a user