Merge pull request #11576 from asr1/master

Cyberrats: Bugfixes and display number of equipped powers
This commit is contained in:
Nic Bradley
2023-03-09 09:38:32 -08:00
committed by GitHub
2 changed files with 31 additions and 7 deletions
+5
View File
@@ -802,6 +802,11 @@ input.sheer-disabler:checked ~ button.enab {
display: none !important;
}
.pull-right {
font-size: 1.3em;
margin-top: 5px;
}
hr.separaotr {
border-top: 3px solid #c9c9c9;
}
+26 -7
View File
@@ -164,6 +164,8 @@
<section class="powers">
<span class="spacer">
<h2 class="narrow">All Known Powers</h2>
<input type="hidden" name="attr_powersEquipped" value="0">
<span class="pull-right">You've equipped <span name="attr_powersEquipped"></span>/5 powers.</span>
</span>
<fieldset class="repeating_powers">
<label class="inline">Equipped?</label>
@@ -382,7 +384,7 @@
<button disabled="true" class="disab inline" type="roll" name="roll_item" value=""></button>
<button type="roll" name="roll_item" value="&{template:powers} {{title=Item}} {{name=@{character_name}}} {{description=@{itemtext}}} {{powerName=@{itemname}}}"></button>
<button type="roll" class="enab" name="roll_item" value="&{template:powers} {{title=Item}} {{name=@{character_name}}} {{description=@{itemtext}}} {{powerName=@{itemname}}}"></button>
<input class="item" spellcheck="false" type="text" name="attr_itemname" value="Name">
<label class="inline">Used?</label>
@@ -1151,7 +1153,7 @@
<div class="drop">
<label for="attr_injuredOps">Are Injured</label>
<input type="number" name="attr_injuredOps" value="0" min="0">
<input type="number" name="attr_injuredOps" novalidate value="0" min="0">
</div>
<div class="drop">
@@ -2218,7 +2220,8 @@ function getAssistantInfo(assistant) {
function buildDicePool(numDice) {
if(numDice == 0) {
console.log("Building dice pool for " + numDice);
if(numDice <= 0) {
numDice = 2;
const rolls = [...Array(numDice)].map(() => "[[d6]]").join(", ");
return `[[{${rolls}}kl1]]`; // Keep LOWEST not highest
@@ -2229,7 +2232,7 @@ function buildDicePool(numDice) {
}
function getResults(numDice) {
if(numDice === 0) {
if(numDice <= 0) {
numDice = 2;
}
return numDice <= 1
@@ -2364,7 +2367,7 @@ on("change:dicemod", function(eventInfo) {
"sly",
"cyber"
], function(values) {
console.log("Dicemod changed");
const diceMod = parseInt(eventInfo.newValue);
updateSmashFormulas(parseInt(values.smash) + diceMod);
updateSlyFormulas(parseInt(values.sly) + diceMod);
@@ -2393,6 +2396,7 @@ on("change:smash", function(eventInfo) {
});
function updateSlyFormulas(totalSlyDice) {
console.log("Total sly dice: " + totalSlyDice);
const roll_formula_sly = buildDicePool(totalSlyDice);
const roll_results_sly = getResults(totalSlyDice);
setAttrs({
@@ -2574,7 +2578,7 @@ on("change:repeating_powers:equipped", function(eventInfo) {
getAttrs(["powersEquipped"], (values) => {
setAttrs(
{
powersEquipped: values.powersEquipped + changeval
powersEquipped: parseInt(values.powersEquipped) + changeval
}
);
});
@@ -2645,6 +2649,7 @@ on("change:hivedecayroom1 change:hivedecayroom2 change:hivedecayroom3 change:hiv
});
on("sheet:opened", () => {
console.log("Load");
// Initialize our default values. Not necessary if we used translation.
getAttrs(["smash_fail", "cyber_fail", "sly_fail", "smash", "sly", "cyber", "dicemod", "sublockedroom6"], (values) => {
const sm = values.smash_fail;
@@ -2826,7 +2831,21 @@ on("clicked:reset", function() {
}
if(rows) setAttrs(rows);
});
console.log("Antwer");
// Reload all weapons
getSectionIDs("repeating_weapon", idarray => {
let rows = {};
for (let i = 0; i < idarray.length; i++) {
getAttrs(['repeating_weapon_' + idarray[i] + '_max_ammo'], function(values){
let maxVal = parseInt(values['repeating_weapon_' + idarray[i] + '_max_ammo']);
console.log(maxVal);
rows['repeating_weapon_' + idarray[i] + '_ammo'] = maxVal;
if(rows) setAttrs(rows);
})
}
});
console.log("Bruges");
const shouldResetPowers = values.resetpowers == 'true';
if(shouldResetPowers) {