Primary flags, Armor overhaul

- Added Primary stars for weapons & armor
- Refactored the repeating armor section
This commit is contained in:
clevett
2018-10-28 19:02:41 -05:00
parent c864deb07d
commit 2a7bbdc63a
2 changed files with 89 additions and 21 deletions
@@ -412,6 +412,14 @@
.sheet-core-combat h3 {
margin-right: 0px;}
.sheet-flag-primary + div {display: none;}
.sheet-flag-primary[value="primary"] + div {
display: inline;
margin-right: -5%;}
.sheet-flag-primary + div > span {font-family: "pictos";}
/***** PRIMARY ARMOR *****/
.sheet-cc-arm button[type="roll"] {
padding: 2px 3px;
+81 -21
View File
@@ -906,7 +906,10 @@
</div>
</div>
<div class="display">
<div class="display-row" title="Roll attack"><button type="roll" value="@{gm_toggle} &{template:sRun}{{header=@{weapon}}}{{base=Agility}}{{dice=[[((@{skill}+@{dicepool})+@{agility}+@{wound_toggle}+@{modifier_toggle}+@{edge_toggle})d6>5@{explode_toggle}]]}}{{desc=@{mode}, ACC @{acc}, DV @{damage}, AP @{ap}}}{{mod=[[@{modifier_toggle}]]}}{{wound=[[@{wound_toggle}]]}}{{edge=[[@{edge_toggle}]]}}"><span name="attr_weapon"></span></button></div>
<div class="display-row" title="Roll attack">
<input class="flag-primary" type="hidden" name="attr_primary" value="" /><div title="Primary"><span>S</span></div>
<button type="roll" value="@{gm_toggle} &{template:sRun}{{header=@{weapon}}}{{base=Agility}}{{dice=[[((@{skill}+@{dicepool})+@{agility}+@{wound_toggle}+@{modifier_toggle}+@{edge_toggle})d6>5@{explode_toggle}]]}}{{desc=@{mode}, ACC @{acc}, DV @{damage}, AP @{ap}}}{{mod=[[@{modifier_toggle}]]}}{{wound=[[@{wound_toggle}]]}}{{edge=[[@{edge_toggle}]]}}"><span name="attr_weapon"></span></button>
</div>
<div class="display-row" title="Damage"><span name="attr_damage"></span></div>
<div class="display-row" title="Accuracy"><span name="attr_acc"></span></div>
<div class="display-row" title="Armor Penetration"><span name="attr_ap"></span></div>
@@ -968,7 +971,10 @@
</div>
</div>
<div class="display">
<div class="display-row" title="Roll attack"><button type="roll" value="@{gm_toggle} &{template:sRun}{{header=@{weapon}}}{{base=Agility}}{{dice=[[((@{skill} +@{dicepool})+@{agility}+@{wound_toggle}+@{modifier_toggle}+@{edge_toggle})d6>5@{explode_toggle}]]}}{{desc=ACC @{acc}, DV @{damage}, AP @{ap}, Reach @{reach}}}{{mod=[[@{modifier_toggle}]]}}{{wound=[[@{wound_toggle}]]}}{{edge=[[@{edge_toggle}]]}}"><span name="attr_weapon"></span></button></div>
<div class="display-row" title="Roll attack">
<input class="flag-primary" type="hidden" name="attr_primary" value="" /><div title="Primary"><span>S</span></div>
<button type="roll" value="@{gm_toggle} &{template:sRun}{{header=@{weapon}}}{{base=Agility}}{{dice=[[((@{skill} +@{dicepool})+@{agility}+@{wound_toggle}+@{modifier_toggle}+@{edge_toggle})d6>5@{explode_toggle}]]}}{{desc=ACC @{acc}, DV @{damage}, AP @{ap}, Reach @{reach}}}{{mod=[[@{modifier_toggle}]]}}{{wound=[[@{wound_toggle}]]}}{{edge=[[@{edge_toggle}]]}}"><span name="attr_weapon"></span></button>
</div>
<div class="display-row" title="Reach"><span name="attr_reach"></span></div>
<div class="display-row" title="Damage"><span name="attr_damage"></span></div>
<div class="display-row" title="Accuracy"><span name="attr_acc"></span></div>
@@ -1003,7 +1009,7 @@
<input type="number" name="attr_radiation_modifier" min="0" value="0" placeholder="0" title="Radiation modifier" />
<div class="settings-row">
<label data-i18n="primary">Primary</label><input type="checkbox" class="skill-select" name="attr_primary" value="primary" title="Add to Core tab as primary armor" />
<label data-i18n="modifierdice">modifier dice</label><input type="number" name="attr_dicepool_modifier" title="Additional dicepool bonus" />
<label data-i18n="modifierdice">modifier dice</label><input type="number" name="attr_dicepool_modifier" min="0" value="0" title="Additional dicepool bonus" />
</div>
<div class="settings-row">
<label data-i18n="notes">Notes</label>
@@ -1012,7 +1018,10 @@
</div>
</div>
<div class="display">
<div class="display-row" title="Soak roll"><button type="roll" value="@{gm_toggle} &{template:sRun}{{header=Soak}}{{base=Body ♦ Armor}}{{dice=[[(@{body}+@{rating}+@{dicepool_modifier}+@{modifier_toggle}+@{edge_toggle})d6>5@{explode_toggle}]]}}{{mod=[[@{modifier_toggle}]]}}{{edge=[[@{edge_toggle}]]}}"><span name="attr_name"></span></button></div>
<div class="display-row" title="Soak roll">
<input class="flag-primary" type="hidden" name="attr_primary" value="" /><div title="Primary"><span>S</span></div>
<button type="roll" value="@{gm_toggle} &{template:sRun}{{header=Soak}}{{base=Body ♦ Armor}}{{dice=[[(@{body}+@{rating}+@{dicepool_modifier}+@{modifier_toggle}+@{edge_toggle})d6>5@{explode_toggle}]]}}{{mod=[[@{modifier_toggle}]]}}{{edge=[[@{edge_toggle}]]}}"><span name="attr_name"></span></button>
</div>
<div class="display-row hoverswitch" title="Armor roll">
<button type="roll" value="@{gm_toggle} &{template:sRun}{{header=@{armor}}}{{base= Armor}}{{dice=[[(@{rating}+@{modifier_toggle}+@{edge_toggle})d6>5@{explode_toggle}]]}}{{mod=[[@{modifier_toggle}]]}}{{edge=[[@{edge_toggle}]]}}">
<span class="default" name="attr_rating"></span><!--<span class="hover" name="attr_soak"></span>--></button>
@@ -3214,7 +3223,7 @@
//SOAK POOLS
var update_soak = function () {
getAttrs(["body", "armor_rating", "soak_modifier", "soak_temp"], function(v){
getAttrs(["body", "armor_rating", "soak_modifier", "soak_temp"], function(v) {
const bod = parseInt(v.body) || 0;
const arm = parseInt(v.armor_rating) || 0;
const mod = parseInt(v.soak_modifier) || 0;
@@ -3225,25 +3234,76 @@
});
};
//Set Primary Armor when the star is selected
on("change:repeating_armor", function() {
getAttrs(["repeating_armor_name", "repeating_armor_rating", "repeating_armor_acid_modifier", "repeating_armor_electrical_modifier", "repeating_armor_cold_modifier", "repeating_armor_fire_modifier", "repeating_armor_radiation_modifier", "repeating_armor_primary", "repeating_armor_dicepool_modifier"], function(v) {
let update = {};
//This function checks changes to repeating_armor and updates the Primary Armor if needed
on("change:repeating_armor", function(eventInfo) {
const source = eventInfo.sourceAttribute;
const newV = eventInfo.newValue;
const arm = ["repeating_armor"];
if (v.repeating_armor_primary === "primary") {
update["armor_name"] = v.repeating_armor_name;
if (v.repeating_armor_rating) {update["armor_rating"] = v.repeating_armor_rating};
if (v.repeating_armor_dicepool_modifier) {update["soak_modifier"] = v.repeating_armor_dicepool_modifier};
if (v.repeating_armor_acid_modifier) {update["acid_modifier"] = v.repeating_armor_acid_modifier};
if (v.repeating_armor_cold_modifier) {update["cold_modifier"] = v.repeating_armor_cold_modifier};
if (v.repeating_armor_electrical_modifier) {update["electrical_modifier"] = v.repeating_armor_electrical_modifier};
if (v.repeating_armor_fire_modifier) {update["fire_modifier"] = v.repeating_armor_fire_modifier};
if (v.repeating_armor_radiation_modifier) {update["radiation_modifier"] = v.repeating_armor_radiation_modifier};
//Check if the event was related to the primary flag
if (source.includes('primary')) {
//Check if the primary flag is set to primary
if (newV === 'primary') {
//Get attributes from the repeating_armor
getAttrs([`${arm}_name`, `${arm}_rating`, `${arm}_acid_modifier`, `${arm}_electrical_modifier`, `${arm}_cold_modifier`,`${arm}_fire_modifier`, `${arm}_radiation_modifier`, `${arm}_dicepool_modifier`], function(v) {
let update = {};
//Update the hidden static Primary Armor attributes with the repeating_armor attributes
update["armor_name"] = v[`${arm}_name`];
if (v[`${arm}_rating`]) {update["armor_rating"] = v[`${arm}_rating`]};
if (v[`${arm}_dicepool_modifier`]) {update["soak_modifier"] = v[`${arm}_dicepool_modifier`]};
if (v[`${arm}_acid_modifier`]) {update["acid_modifier"] = v[`${arm}_acid_modifier`]};
if (v[`${arm}_cold_modifier`]) {update["cold_modifier"] = v[`${arm}_cold_modifier`]};
if (v[`${arm}_electrical_modifier`]) {update["electrical_modifier"] = v[`${arm}_electrical_modifier`]};
if (v[`${arm}_fire_modifier`]) {update["fire_modifier"] = v[`${arm}_fire_modifier`]};
if (v[`${arm}_radiation_modifier`]) {update["radiation_modifier"] = v[`${arm}_radiation_modifier`]};
setAttrs(update);
});
//Set the other repeating_armor primary flags to 0 aka unchecked
getSectionIDs(`${arm}`, function(ids) {
let IDs = [];
let update = {};
for(var i=0; i < ids.length; i++) {
IDs.push(`${arm}_` + ids[i] + "_primary");
};
IDs.forEach(id => {
if (id != source) {
update[`${id}`] = 0;
};
});
setAttrs(update);
});
};
//Check if the event was for a relevant Primary Armor attribute
} else if (source.includes('name') || source.includes('rating') || source.includes('dicepool') || source.includes('acid') || source.includes('cold') || source.includes('electrical') || source.includes('fire') || source.includes('radiation')) {
//Get the primary flag attribute for this armor. Also get the repeating_armor attribute we'll need for an update, doing it now is more efficient.
getAttrs([`${arm}_primary`, `${source}`], function(v) {
//Check if this armor is the designated Primary Armor.
if (v[`${arm}_primary`] === 'primary') {
let update = {};
//Apply the repeating_armor attribute to its static counterpart
switch (true) {
case /name/.test(source): update["armor_name"] = v[`${source}`]; break;
case /rating/.test(source): update["armor_rating"] = v[`${source}`]; break;
case /dicepool/.test(source): update["soak_modifier"] = v[`${source}`]; break;
case /acid/.test(source): update["acid_modifier"] = v[`${source}`]; break;
case /cold/.test(source): update["cold_modifier"] = v[`${source}`]; break;
case /electrical/.test(source): update["electrical_modifier"] = v[`${source}`]; break;
case /fire/.test(source): update["fire_modifier"] = v[`${source}`]; break;
case /radiation/.test(source): update["radiation_modifier"] = v[`${source}`]; break;
default: console.log(`Source ${source} was invalid`);}
setAttrs(update);
};
setAttrs(update);
});
});
} else {
console.log("CHANGE NOT RELEVENT Primary Armor");
};
});
var update_liftCarry = function () {
getAttrs(["body", "strength", "lift_carry_modifier"], function(v) {