fixed some bugs about incorrectly transferred ini values after taking action / starting new round
This commit is contained in:
parent
c82a3e41d8
commit
c26dd7be94
@ -31,7 +31,6 @@ input:invalid {
|
|||||||
width: 20px;
|
width: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dropdown Content (Hidden by Default) */
|
|
||||||
.damage-monitor {
|
.damage-monitor {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -54,14 +53,13 @@ input:invalid {
|
|||||||
height: 24px;
|
height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.damage-monitor button {
|
.damage-monitor button {
|
||||||
font-size: smaller;
|
font-size: smaller;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
width: 30px;
|
width: 30px;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.damage-monitor button.active {
|
.damage-monitor button.active {
|
||||||
filter: brightness(91%);
|
filter: brightness(91%);
|
||||||
}
|
}
|
||||||
|
|||||||
19
js/sr2ini.js
19
js/sr2ini.js
@ -21,7 +21,7 @@ const damageMonitorHTML = ['<table class="bg-light damage-monitor text-center al
|
|||||||
|
|
||||||
const maxIniClass = "table-primary";
|
const maxIniClass = "table-primary";
|
||||||
const zeroIniClass = "table-secondary";
|
const zeroIniClass = "table-secondary";
|
||||||
|
const regularClass = "table-success";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* helper functions
|
* helper functions
|
||||||
@ -64,7 +64,7 @@ console.log("Reaction values are: ", tmpA, tmpB);
|
|||||||
function sortTable() {
|
function sortTable() {
|
||||||
|
|
||||||
// remove previous classes from rows, disable act buttons
|
// remove previous classes from rows, disable act buttons
|
||||||
$(".combatantRow").removeClass(maxIniClass + " " + zeroIniClass).find(".act-button").prop("disabled", true).attr("aria-disabled", "true");
|
$(".combatantRow").removeClass(maxIniClass + " " + zeroIniClass + " " + regularClass).find(".act-button").prop("disabled", true).attr("aria-disabled", "true");
|
||||||
|
|
||||||
// get ini value for every combatant; set to 0 if K.O./dead
|
// get ini value for every combatant; set to 0 if K.O./dead
|
||||||
let iniValues = $.map( $(".combatantRow"), function(tr, i) {
|
let iniValues = $.map( $(".combatantRow"), function(tr, i) {
|
||||||
@ -83,15 +83,19 @@ console.log(iniValues);
|
|||||||
// K.O./dead -> don't add anything
|
// K.O./dead -> don't add anything
|
||||||
if ( $(this).hasClass("out-of-commission") ) {
|
if ( $(this).hasClass("out-of-commission") ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ini = zero
|
// ini = zero
|
||||||
if ( parseInt($(this).find(".combatantIni").text()) == 0 ) {
|
if ( parseInt($(this).find(".combatantIni").text()) == 0 ) {
|
||||||
$(this).addClass(zeroIniClass);
|
$(this).addClass(zeroIniClass);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
// ini = max and non-zero
|
// ini = max and non-zero
|
||||||
else if ( parseInt($(this).find(".combatantIni").text()) == iniMax && iniMax > 0 ) {
|
if ( parseInt($(this).find(".combatantIni").text()) == iniMax && iniMax > 0 ) {
|
||||||
$(this).addClass(maxIniClass).find(".act-button").prop("disabled", false).removeAttr("aria-disabled");
|
$(this).addClass(maxIniClass).find(".act-button").prop("disabled", false).removeAttr("aria-disabled");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
// everything else
|
||||||
|
$(this).addClass(regularClass);
|
||||||
})
|
})
|
||||||
|
|
||||||
// sort rows and append them in new order
|
// sort rows and append them in new order
|
||||||
@ -141,8 +145,9 @@ function handleActButtonClick (e) {
|
|||||||
ini = Math.max(parseInt(ini) - 10, 0);
|
ini = Math.max(parseInt(ini) - 10, 0);
|
||||||
|
|
||||||
// set new ini value
|
// set new ini value
|
||||||
|
// can't use text() here because that would delete wound badges
|
||||||
$tr.attr("data-true-ini", ini);
|
$tr.attr("data-true-ini", ini);
|
||||||
$tr.find(".combatantIni").text(getEffectiveIni($tr));
|
$tr.find(".combatantIni").contents()[0].data = getEffectiveIni($tr);
|
||||||
|
|
||||||
// resort table
|
// resort table
|
||||||
sortTable();
|
sortTable();
|
||||||
@ -447,6 +452,7 @@ function editCombatant (e) {
|
|||||||
$tr.find(".combatantRea").text(rea);
|
$tr.find(".combatantRea").text(rea);
|
||||||
$tr.attr("data-true-ini", ini);
|
$tr.attr("data-true-ini", ini);
|
||||||
$tr.find(".combatantIni").text(getEffectiveIni($tr));
|
$tr.find(".combatantIni").text(getEffectiveIni($tr));
|
||||||
|
//TODO: add badges
|
||||||
|
|
||||||
// sort table
|
// sort table
|
||||||
sortTable();
|
sortTable();
|
||||||
@ -491,8 +497,7 @@ function startNewRound (e) {
|
|||||||
} else {
|
} else {
|
||||||
$(this).attr("data-true-ini", rollForInitiative(dice, $(this).find(".combatantRea").text()));
|
$(this).attr("data-true-ini", rollForInitiative(dice, $(this).find(".combatantRea").text()));
|
||||||
}
|
}
|
||||||
$(this).find(".combatantIni").text(getEffectiveIni($(this)));
|
$(this).find(".combatantIni").contents()[0].data = getEffectiveIni($(this));
|
||||||
let effectiveIni = $(this).find(".combatantIni").text();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// resort table
|
// resort table
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user