Merge pull request #8430 from uriele/master

[Delta Green by ArcDream] Bug fix and new feature
This commit is contained in:
Miguel Peres
2021-03-08 10:46:43 -03:00
committed by GitHub
7 changed files with 346 additions and 30 deletions
+67
View File
@@ -763,6 +763,73 @@ div.sheet-npc div.sheet-section-body div.sheet-notes div.sheet-section {
/* PC SHEET
============================= */
/* SUMMARY UPDATE */
div.sheet-datahide {
display: none;
}
div[data-groupname=repeating_summary].repcontrol {
display: none;
}
div.sheet-summary {
position: absolute;
bottom: 40px;
right: 10px;
display: none;
z-index: 1000;
background: white;
border: 0.01em solid black;
width: 30%;
min-height: 20%;
overflow-y: scroll;
}
.sheet-section-summary {
grid-column-gap: 0.2em;
grid-row-gap: 0.2em;
grid-template-columns: 4fr 1fr 1fr 1fr;
display: grid;
justify-items: start;
}
div.sheet-updateinfo {
position: relative;
}
div.sheet-updateinfo input[type=checkbox] {
opacity: 0;
width: 16px;
height: 16px;
position: relative;
top: 5px;
left: 6px;
margin: -10px;
cursor: pointer;
z-index: 1;
}
div.sheet-updateinfo input[type=checkbox] + span::before {
margin-right: 4px;
line-height: 14px;
text-align: center;
display: inline-block;
vertical-align: middle;
content: "?";
font-weight: bold;
color: black;
width: 14px;
height: 14px;
font-size: 12px;
}
div.sheet-updateinfo input[type=checkbox]:checked ~ div.sheet-summary {
display: grid;
}
div.sheet-updateinfo input[type=checkbox]:checked + span::before {
content: "?";
font-weight: bold;
color: gray;
}
/* MAIN SHEET */
div.sheet-pc {
grid-column-gap: 0.2em;
grid-row-gap: 0.2em;
File diff suppressed because one or more lines are too long
+104 -13
View File
@@ -11,6 +11,49 @@
<input class="display_string" name="attr_toggles" type="hidden" value=""/>
<!--TABS & LOGO-->
<!-- =============================-->
<div class="datahide">
<input data-i18n-value="accounting" name="attr_accounting_name" value="accounting"/>
<input data-i18n-value="alertness" name="attr_alertness_name" value="alertness"/>
<input data-i18n-value="anthropology" name="attr_anthropology_name" value="anthropology"/>
<input data-i18n-value="archeology" name="attr_archeology_name" value="archeology"/>
<input data-i18n-value="art" name="attr_art_name" value="art"/>
<input data-i18n-value="artillery" name="attr_artillery_name" value="artillery"/>
<input data-i18n-value="athletics" name="attr_athletics_name" value="athletics"/>
<input data-i18n-value="bureaucracy" name="attr_bureaucracy_name" value="bureaucracy"/>
<input data-i18n-value="computer science" name="attr_computer_science_name" value="computer science"/>
<input data-i18n-value="craft" name="attr_craft_name" value="craft"/>
<input data-i18n-value="criminology" name="attr_criminology_name" value="criminology"/>
<input data-i18n-value="demolitions" name="attr_demolitions_name" value="demolitions"/>
<input data-i18n-value="disguise" name="attr_disguise_name" value="disguise"/>
<input data-i18n-value="dodge" name="attr_dodge_name" value="dodge"/>
<input data-i18n-value="drive" name="attr_drive_name" value="drive"/>
<input data-i18n-value="firearms" name="attr_firearms_name" value="firearms"/>
<input data-i18n-value="first aid" name="attr_first_aid_name" value="first aid"/>
<input data-i18n-value="forensics" name="attr_forensics_name" value="forensics"/>
<input data-i18n-value="heavy machinery" name="attr_heavy_machinery_name" value="heavy machinery"/>
<input data-i18n-value="heavy weapons" name="attr_heavy_weapons_name" value="heavy weapons"/>
<input data-i18n-value="history" name="attr_history_name" value="history"/>
<input data-i18n-value="humint" name="attr_humint_name" value="humint"/>
<input data-i18n-value="law" name="attr_law_name" value="law"/>
<input data-i18n-value="medicine" name="attr_medicine_name" value="medicine"/>
<input data-i18n-value="melee weapons" name="attr_melee_weapons_name" value="melee weapons"/>
<input data-i18n-value="military science" name="attr_military_science_name" value="military science"/>
<input data-i18n-value="navigate" name="attr_navigate_name" value="navigate"/>
<input data-i18n-value="occult" name="attr_occult_name" value="occult"/>
<input data-i18n-value="persuade" name="attr_persuade_name" value="persuade"/>
<input data-i18n-value="pharmacy" name="attr_pharmacy_name" value="pharmacy"/>
<input data-i18n-value="pilot" name="attr_pilot_name" value="pilot"/>
<input data-i18n-value="psychotherapy" name="attr_psychotherapy_name" value="psychotherapy"/>
<input data-i18n-value="ride" name="attr_ride_name" value="ride"/>
<input data-i18n-value="science" name="attr_science_name" value="science"/>
<input data-i18n-value="search" name="attr_search_name" value="search"/>
<input data-i18n-value="sigint" name="attr_sigint_name" value="sigint"/>
<input data-i18n-value="stealth" name="attr_stealth_name" value="stealth"/>
<input data-i18n-value="surgery" name="attr_surgery_name" value="surgery"/>
<input data-i18n-value="survival" name="attr_survival_name" value="survival"/>
<input data-i18n-value="swim" name="attr_swim_name" value="swim"/>
<input data-i18n-value="unarmed combat" name="attr_unarmed_combat_name" value="unarmed combat"/>
</div>
<div class="tabs grid">
<!-- Buttons to toggle on GM whisper--><span data-i18n-title="GM Whisper">GM Whisper</span>
<label class="switch" data-i18-titlen="whisper rolls to gm" title="whisper rolls to gm">
@@ -195,7 +238,7 @@
<button class="dicefontd10" name="weapon" type="roll" title="weapon roll" value="@{gm_toggle} &amp;{template:rolls} {{name=@{name}}} {{header=@{weapons}}} {{subheader=@{skill_percent}}} {{modifier=[[?{Modifier|,0|+20%,20|+40%,40|-20%,-20|-40%,-40|custom (%),?{custom (%)}}]]}} {{rating=[[@{skill_percent}+?{Modifier|,0|+20%,20|+40%,40|-20%,-20|-40%,-40|custom (%),?{custom (%)}}]]}} {{dice=[[1d100]]}} {{hasdamage=[[@{hasdamage}]]}} {{damage=^{damage} [@{damage}](~repeating_weapons_damage)}} {{damage_critical=^{damage (×2)} [@{damage}](~repeating_weapons_damage_critical)}} {{haslethality=[[@{haslethality}]]}} {{lethality=^{lethality} [@{lethality_percent}%](~repeating_weapons_lethality)}} {{lethality_critical=^{lethality (×2)} [@{lethality_percent}%](~repeating_weapons_lethality_critical)}} {{AP=[[@{armor_piercing}+0]]}}">k</button>
<button class="none" name="roll_damage" type="roll" value="@{gm_toggle} &amp;{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[@{damage}]]}} {{AP=[[@{armor_piercing}+0]]}}"></button>
<button class="none" name="roll_lethality" type="roll" value="@{gm_toggle} &amp;{template:lethality} {{header=@{weapons}}} {{subheader=@{lethality_percent}}}{{lethality_rating=[[@{lethality_percent}]]}} {{lethality=[[1d100]]}} {{AP=[[@{armor_piercing}+0]]}}"></button>
<button class="none" name="roll_damage_critical" type="roll" value="@{gm_toggle} &amp;{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[@{damage}*2]]}} {{AP=[[@{armor_piercing}+0]]}}"></button>
<button class="none" name="roll_damage_critical" type="roll" value="@{gm_toggle} &amp;{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[(@{damage})*2]]}} {{AP=[[@{armor_piercing}+0]]}}"></button>
<button class="none" name="roll_lethality_critical" type="roll" value="@{gm_toggle} &amp;{template:lethality_critical} {{header=@{weapons}}} {{subheader=@{lethality_percent}}} {{lethality_rating=[[@{lethality_percent}*2]]}} {{lethality=[[1d100]]}} {{AP=[[@{armor_piercing}+0]]}}"></button>
</div>
</fieldset>
@@ -1057,10 +1100,16 @@
</fieldset>
</div>
</div>
<div class="section-directions center"> <span data-i18n="Check a box when you attempt to use a skill and fail. After the session, add 1d4 to each checked skill and erase all checks.">Check a box when you attempt to use a skill and fail. After the session, add 1d4 to each checked skill and erase all checks.</span>
<div class="section-directions center updateinfo"> <span data-i18n="Check a box when you attempt to use a skill and fail. After the session, add 1d4 to each checked skill and erase all checks.">Check a box when you attempt to use a skill and fail. After the session, add 1d4 to each checked skill and erase all checks.</span>
<button name="act_levelup" type="action">
<h3 class="aligned-center" data-i18n="Update" data-i18n-title="Update"></h3>
</button>
<input type="checkbox"/><span></span>
<div class="summary">
<fieldset class="repeating_summary">
<div class="section-summary"><span name="attr_skillname"></span><span style="color:red;" name="attr_oldval"></span><span class="slash">→</span><span style="color:green;" name="attr_newval"></span></div>
</fieldset>
</div>
</div>
</div>
</div>
@@ -1151,7 +1200,7 @@
<button class="dicefontd10" name="weapon" type="roll" title="weapon roll" value="@{gm_toggle} &amp;{template:rolls} {{header=@{weapons}}} {{subheader=@{skill_percent}}} {{modifier=[[?{Modifier|,0|+20%,20|+40%,40|-20%,-20|-40%,-40|custom (%),?{custom (%)}}]]}} {{rating=[[@{skill_percent}+?{Modifier|,0|+20%,20|+40%,40|-20%,-20|-40%,-40|custom (%),?{custom (%)}}]]}} {{dice=[[1d100]]}} {{hasdamage=[[@{hasdamage}]]}} {{damage=^{damage} [@{damage}](~repeating_weapons_damage)}} {{damage_critical=^{damage (×2)} [@{damage}](~repeating_weapons_damage_critical)}} {{haslethality=[[@{haslethality}]]}} {{lethality=^{lethality} [@{lethality_percent}%](~repeating_weapons_lethality)}} {{lethality_critical=^{lethality (×2)} [@{lethality_percent}%](~repeating_weapons_lethality_critical)}} {{AP=[[@{armor_piercing}+0]]}}">k</button>
<button class="none" name="roll_damage" type="roll" value="@{gm_toggle} &amp;{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[@{damage}]]}} {{AP=[[@{armor_piercing}+0]]}}"></button>
<button class="none" name="roll_lethality" type="roll" value="@{gm_toggle} &amp;{template:lethality} {{header=@{weapons}}} {{subheader=@{lethality_percent}}}{{lethality_rating=[[@{lethality_percent}]]}} {{lethality=[[1d100]]}} {{AP=[[@{armor_piercing}+0]]}}"></button>
<button class="none" name="roll_damage_critical" type="roll" value="@{gm_toggle} &amp;{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[@{damage}*2]]}} {{AP=[[@{armor_piercing}+0]]}}"></button>
<button class="none" name="roll_damage_critical" type="roll" value="@{gm_toggle} &amp;{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[(@{damage})*2]]}} {{AP=[[@{armor_piercing}+0]]}}"></button>
<button class="none" name="roll_lethality_critical" type="roll" value="@{gm_toggle} &amp;{template:lethality_critical} {{header=@{weapons}}} {{subheader=@{lethality_percent}}} {{lethality_rating=[[@{lethality_percent}*2]]}} {{lethality=[[1d100]]}} {{AP=[[@{armor_piercing}+0]]}}"></button>
</div>
</fieldset>
@@ -3643,6 +3692,7 @@ on('sheet:opened change:repeating_skills remove:repeating_skills', () => {
});
});
// levelup character
on("clicked:levelup", () =>{
let update={};
@@ -3650,32 +3700,61 @@ on("clicked:levelup", () =>{
let len=copyarray.length; // length of the original copyarray
let getarray=[]; // used only to update the values
let summary={}; // information in the log for the users
let var_rnd=0; // random variable of 1d4-1
//console.dir(copyarray);
let var_rnd=0; // random variable of 1d4
let block_to_insert ;
let container_block ;
let newrowid;
let newrowattrs = {};
let oldval=0;
let newval=0;
let name;
//console.dir(copyarray);
//getSectionIDs('repeating_skills', (idarray) => {
// for (i=0;i<idarray.length;i++){
// copyarray.push(`repeating_skills_${idarray[i]}`) ;
// }
//});
copyarray=copyarray.concat(addskills); // concatenate skill array with repeating skill array
//console.dir(copyarray);
copyarray.forEach((sk,idx)=>{
console.dir(copyarray);
getSectionIDs("repeating_summary", function(idarray) {
for(var i=0; i < idarray.length; i++) {
removeRepeatingRow("repeating_summary_" + idarray[i]);
}
});
copyarray.forEach((sk,idx)=>{
//console.log(idx);
if (idx<len){ // if the idx<len it means I an in the skill array part
getAttrs([`${sk}`,`${sk}_fail`],(val)=>{
getAttrs([`${sk}`,`${sk}_name`,`${sk}_fail`],(val)=>{
getarray.push(`${sk}`);
//console.log(val[`${sk}_fail`]);
// console.log(`${sk}`);
if (val[`${sk}_fail`]=='on'){ //if the checkbox is checked
var_rnd=Math.ceil(Math.random() * 4); // generate a random number for each checked value (less number generated)
var_rnd=Math.ceil(Math.random() * 4); // generate a random number for each checked value (less number generated)
//console.log(`${idx}`);
oldval=(parseInt(val[`${sk}`])||0);
newval=oldval+var_rnd;
name=val[`${sk}_name`];
summary[`${sk}`]=var_rnd; // how much the skill has changed 0-3
update[`${sk}`]=(parseInt(val[`${sk}`])||0)+var_rnd; // new value of the skill
update[`${sk}`]=newval; // new value of the skill
update[`${sk}_fail`]='off'; // uncheck checkbox
//block_to_insert = document.createElement( 'div' );
//block_to_insert.innerHTML = 'This demo DIV block was inserted into the page using JavaScript.' ;
//container_block = document.getElementById( 'summary' );
//container_block.appendChild( block_to_insert );
newrowid = generateRowID();
newrowattrs['repeating_summary_' + newrowid + '_skillname'] = name;
newrowattrs['repeating_summary_' + newrowid + '_oldval'] = oldval;
newrowattrs['repeating_summary_' + newrowid + '_newval'] = newval;
}
});
} else { // if the idx>=len it means I an in the repeating skill array part
getAttrs([`${sk}_rank`,`${sk}_fail`],(val)=>{
getAttrs([`${sk}_name`,`${sk}_rank`,`${sk}_fail`],(val)=>{
getarray.push(`${sk}_rank`);
//console.log(val[`${sk}_fail`]);
// console.log(`${sk}`);
@@ -3683,17 +3762,29 @@ on("clicked:levelup", () =>{
var_rnd=Math.ceil(Math.random() * 4); // generate a random number for each checked value (less number generated)
//console.log(`${idx}`);
summary[`${idx-len}_rank`]=var_rnd; // since the repeating skill don't have a name, they are identified by number 0-N
update[`${sk}_rank`]=(parseInt(val[`${sk}_rank`])||0)+var_rnd;
//
oldval=(parseInt(val[`${sk}_rank`])||0);
newval=oldval+var_rnd;
name=val[`${sk}_name`];
//
update[`${sk}_rank`]=(parseInt(val[`${sk}_rank`])||0)+var_rnd;
update[`${sk}_fail`]='off';
newrowid = generateRowID();
newrowattrs['repeating_summary_' + newrowid + '_skillname'] = name;
newrowattrs['repeating_summary_' + newrowid + '_oldval'] = oldval;
newrowattrs['repeating_summary_' + newrowid + '_newval'] = newval;
}
});
}
});
//console.log(getarray);
console.log(newrowattrs); // summary in console for the user
//setAttrs(newrowattrs);
console.log(summary); // summary in console for the user
getAttrs(getarray,()=>{ // update fields
setAttributes(update,false);
setAttributes(newrowattrs,false);
});
//console.dir(update);
});
</script>
</script>
+46 -1
View File
@@ -15,6 +15,51 @@ input.display_string(name='attr_toggles' type='hidden' value='')
//TABS & LOGO
// =============================
.datahide
input(data-i18n-value='accounting' name='attr_accounting_name' value='accounting')
input(data-i18n-value='alertness' name='attr_alertness_name' value='alertness')
input(data-i18n-value='anthropology' name='attr_anthropology_name' value='anthropology')
input(data-i18n-value='archeology' name='attr_archeology_name' value='archeology')
input(data-i18n-value='art' name='attr_art_name' value='art')
input(data-i18n-value='artillery' name='attr_artillery_name' value='artillery')
input(data-i18n-value='athletics' name='attr_athletics_name' value='athletics')
input(data-i18n-value='bureaucracy' name='attr_bureaucracy_name' value='bureaucracy')
input(data-i18n-value='computer science' name='attr_computer_science_name' value='computer science')
input(data-i18n-value='craft' name='attr_craft_name' value='craft')
input(data-i18n-value='criminology' name='attr_criminology_name' value='criminology')
input(data-i18n-value='demolitions' name='attr_demolitions_name' value='demolitions')
input(data-i18n-value='disguise' name='attr_disguise_name' value='disguise')
input(data-i18n-value='dodge' name='attr_dodge_name' value='dodge')
input(data-i18n-value='drive' name='attr_drive_name' value='drive')
input(data-i18n-value='firearms' name='attr_firearms_name' value='firearms')
input(data-i18n-value='first aid' name='attr_first_aid_name' value='first aid')
input(data-i18n-value='forensics' name='attr_forensics_name' value='forensics')
input(data-i18n-value='heavy machinery' name='attr_heavy_machinery_name' value='heavy machinery')
input(data-i18n-value='heavy weapons' name='attr_heavy_weapons_name' value='heavy weapons')
input(data-i18n-value='history' name='attr_history_name' value='history')
input(data-i18n-value='humint' name='attr_humint_name' value='humint')
input(data-i18n-value='law' name='attr_law_name' value='law')
input(data-i18n-value='medicine' name='attr_medicine_name' value='medicine')
input(data-i18n-value='melee weapons' name='attr_melee_weapons_name' value='melee weapons')
input(data-i18n-value='military science' name='attr_military_science_name' value='military science')
input(data-i18n-value='navigate' name='attr_navigate_name' value='navigate')
input(data-i18n-value='occult' name='attr_occult_name' value='occult')
input(data-i18n-value='persuade' name='attr_persuade_name' value='persuade')
input(data-i18n-value='pharmacy' name='attr_pharmacy_name' value='pharmacy')
input(data-i18n-value='pilot' name='attr_pilot_name' value='pilot')
input(data-i18n-value='psychotherapy' name='attr_psychotherapy_name' value='psychotherapy')
input(data-i18n-value='ride' name='attr_ride_name' value='ride')
input(data-i18n-value='science' name='attr_science_name' value='science')
input(data-i18n-value='search' name='attr_search_name' value='search')
input(data-i18n-value='sigint' name='attr_sigint_name' value='sigint')
input(data-i18n-value='stealth' name='attr_stealth_name' value='stealth')
input(data-i18n-value='surgery' name='attr_surgery_name' value='surgery')
input(data-i18n-value='survival' name='attr_survival_name' value='survival')
input(data-i18n-value='swim' name='attr_swim_name' value='swim')
input(data-i18n-value='unarmed combat' name='attr_unarmed_combat_name' value='unarmed combat')
.tabs.grid
// Buttons to toggle on GM whisper
span(data-i18n-title='GM Whisper') GM Whisper
@@ -165,7 +210,7 @@ include src/pug/_objects.pug
button.dicefontd10(name='weapon' type='roll' title='weapon roll' value=attackRollValue) k
button.none(name='roll_damage' type='roll' value='@{gm_toggle} &{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[@{damage}]]}} {{AP=[[@{armor_piercing}+0]]}}')
button.none(name='roll_lethality' type='roll' value='@{gm_toggle} &{template:lethality} {{header=@{weapons}}} {{subheader=@{lethality_percent}}}{{lethality_rating=[[@{lethality_percent}]]}} {{lethality=[[1d100]]}} {{AP=[[@{armor_piercing}+0]]}}')
button.none(name='roll_damage_critical' type='roll' value='@{gm_toggle} &{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[@{damage}*2]]}} {{AP=[[@{armor_piercing}+0]]}}')
button.none(name='roll_damage_critical' type='roll' value='@{gm_toggle} &{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[(@{damage})*2]]}} {{AP=[[@{armor_piercing}+0]]}}')
button.none(name='roll_lethality_critical' type='roll' value='@{gm_toggle} &{template:lethality_critical} {{header=@{weapons}}} {{subheader=@{lethality_percent}}} {{lethality_rating=[[@{lethality_percent}*2]]}} {{lethality=[[1d100]]}} {{AP=[[@{armor_piercing}+0]]}}')
h1(data-i18n='other notes') other notes
+11 -3
View File
@@ -161,11 +161,19 @@
.vert-line
label(data-i18n-title='skill rank' title='skill rank')
input(data-i18n-placeholder='0' name='attr_rank' title='@{repeating_skills_${x}_rank}' placeholder='0' type='number' value='')
.section-directions.center
.section-directions.center.updateinfo
span(data-i18n='Check a box when you attempt to use a skill and fail. After the session, add 1d4 to each checked skill and erase all checks.') Check a box when you attempt to use a skill and fail. After the session, add 1d4 to each checked skill and erase all checks.
button(name='act_levelup' type='action')
h3.aligned-center(data-i18n='Update' data-i18n-title='Update')= Update
input(type='checkbox')
span
.summary
fieldset.repeating_summary
.section-summary
span( name='attr_skillname')
span(style='color:red;' name='attr_oldval')
span.slash →
span(style='color:green;' name='attr_newval')
//INJURIES
.grid.header-body.injuries.border
.section-header
@@ -221,7 +229,7 @@
button.dicefontd10(name='weapon' type='roll' title='weapon roll' value=weaponRollValue) k
button.none(name='roll_damage' type='roll' value='@{gm_toggle} &{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[@{damage}]]}} {{AP=[[@{armor_piercing}+0]]}}')
button.none(name='roll_lethality' type='roll' value='@{gm_toggle} &{template:lethality} {{header=@{weapons}}} {{subheader=@{lethality_percent}}}{{lethality_rating=[[@{lethality_percent}]]}} {{lethality=[[1d100]]}} {{AP=[[@{armor_piercing}+0]]}}')
button.none(name='roll_damage_critical' type='roll' value='@{gm_toggle} &{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[@{damage}*2]]}} {{AP=[[@{armor_piercing}+0]]}}')
button.none(name='roll_damage_critical' type='roll' value='@{gm_toggle} &{template:damage} {{header=@{weapons}}} {{subheader=@{damage}}} {{damage=[[(@{damage})*2]]}} {{AP=[[@{armor_piercing}+0]]}}')
button.none(name='roll_lethality_critical' type='roll' value='@{gm_toggle} &{template:lethality_critical} {{header=@{weapons}}} {{subheader=@{lethality_percent}}} {{lethality_rating=[[@{lethality_percent}*2]]}} {{lethality=[[1d100]]}} {{AP=[[@{armor_piercing}+0]]}}')
//REMARKS
+52 -12
View File
@@ -304,6 +304,7 @@ on('sheet:opened change:repeating_skills remove:repeating_skills', () => {
});
});
// levelup character
on("clicked:levelup", () =>{
let update={};
@@ -311,51 +312,90 @@ on("clicked:levelup", () =>{
let len=copyarray.length; // length of the original copyarray
let getarray=[]; // used only to update the values
let summary={}; // information in the log for the users
let var_rnd=0; // random variable of 1d4-1
//console.dir(copyarray);
let var_rnd=0; // random variable of 1d4
let block_to_insert ;
let container_block ;
let newrowid;
let newrowattrs = {};
let oldval=0;
let newval=0;
let name;
//console.dir(copyarray);
//getSectionIDs('repeating_skills', (idarray) => {
// for (i=0;i<idarray.length;i++){
// copyarray.push(`repeating_skills_${idarray[i]}`) ;
// }
//});
copyarray=copyarray.concat(addskills); // concatenate skill array with repeating skill array
//console.dir(copyarray);
copyarray.forEach((sk,idx)=>{
console.dir(copyarray);
getSectionIDs("repeating_summary", function(idarray) {
for(var i=0; i < idarray.length; i++) {
removeRepeatingRow("repeating_summary_" + idarray[i]);
}
});
copyarray.forEach((sk,idx)=>{
//console.log(idx);
if (idx<len){ // if the idx<len it means I an in the skill array part
getAttrs([`${sk}`,`${sk}_fail`],(val)=>{
getAttrs([`${sk}`,`${sk}_name`,`${sk}_fail`],(val)=>{
getarray.push(`${sk}`);
//console.log(val[`${sk}_fail`]);
// console.log(`${sk}`);
if (val[`${sk}_fail`]=='on'){ //if the checkbox is checked
//var_rnd=Math.floor(Math.random() * 4); // generate a random number for each checked value (less number generated)
var_rnd=Math.ceil(Math.random() * 4); // generate a random number for each checked value (less number generated)
var_rnd=Math.ceil(Math.random() * 4); // generate a random number for each checked value (less number generated)
//console.log(`${idx}`);
oldval=(parseInt(val[`${sk}`])||0);
newval=oldval+var_rnd;
name=val[`${sk}_name`];
summary[`${sk}`]=var_rnd; // how much the skill has changed 0-3
update[`${sk}`]=(parseInt(val[`${sk}`])||0)+var_rnd; // new value of the skill
update[`${sk}`]=newval; // new value of the skill
update[`${sk}_fail`]='off'; // uncheck checkbox
//block_to_insert = document.createElement( 'div' );
//block_to_insert.innerHTML = 'This demo DIV block was inserted into the page using JavaScript.' ;
//container_block = document.getElementById( 'summary' );
//container_block.appendChild( block_to_insert );
newrowid = generateRowID();
newrowattrs['repeating_summary_' + newrowid + '_skillname'] = name;
newrowattrs['repeating_summary_' + newrowid + '_oldval'] = oldval;
newrowattrs['repeating_summary_' + newrowid + '_newval'] = newval;
}
});
} else { // if the idx>=len it means I an in the repeating skill array part
getAttrs([`${sk}_rank`,`${sk}_fail`],(val)=>{
getAttrs([`${sk}_name`,`${sk}_rank`,`${sk}_fail`],(val)=>{
getarray.push(`${sk}_rank`);
//console.log(val[`${sk}_fail`]);
// console.log(`${sk}`);
if (val[`${sk}_fail`]=='on'){
//var_rnd=Math.floor(Math.random() * 4); // generate a random number for each checked value (less number generated)
var_rnd=Math.ceil(Math.random() * 4); // generate a random number for each checked value (less number generated)
//console.log(`${idx}`);
summary[`${idx-len}_rank`]=var_rnd; // since the repeating skill don't have a name, they are identified by number 0-N
update[`${sk}_rank`]=(parseInt(val[`${sk}_rank`])||0)+var_rnd;
//
oldval=(parseInt(val[`${sk}_rank`])||0);
newval=oldval+var_rnd;
name=val[`${sk}_name`];
//
update[`${sk}_rank`]=(parseInt(val[`${sk}_rank`])||0)+var_rnd;
update[`${sk}_fail`]='off';
newrowid = generateRowID();
newrowattrs['repeating_summary_' + newrowid + '_skillname'] = name;
newrowattrs['repeating_summary_' + newrowid + '_oldval'] = oldval;
newrowattrs['repeating_summary_' + newrowid + '_newval'] = newval;
}
});
}
});
//console.log(getarray);
console.log(newrowattrs); // summary in console for the user
//setAttrs(newrowattrs);
console.log(summary); // summary in console for the user
getAttrs(getarray,()=>{ // update fields
setAttributes(update,false);
setAttributes(newrowattrs,false);
});
//console.dir(update);
});
});
+65
View File
@@ -1,3 +1,68 @@
/* SUMMARY UPDATE */
div.sheet-datahide{display:none;}
div[data-groupname='repeating_summary'].repcontrol{
display: none;
}
div.sheet-summary{
position:absolute;
bottom:40px;
right: 10px;
display:none;
z-index: 1000;
background: white;
border: 0.01em solid black;
width:30%;
min-height:20%;
overflow-y:scroll;
}
.sheet-section-summary{
grid-column-gap: 0.2em;
grid-row-gap: 0.2em;
grid-template-columns: 4fr 1fr 1fr 1fr;
display:grid;
justify-items: start;
}
div.sheet-updateinfo{
position: relative;
input[type='checkbox']{
opacity: 0;
width: 16px;
height: 16px;
position: relative;
top: 5px;
left: 6px;
margin: -10px;
cursor: pointer;
z-index: 1;
&+ span::before{
margin-right: 4px;
line-height: 14px;
text-align: center;
display: inline-block;
vertical-align: middle;
content: "?";
font-weight: bold;
color:black;
width: 14px;
height: 14px;
font-size: 12px;
}
&:checked ~ div.sheet-summary{
display:grid;
}
&:checked + span::before{
content: "?";
font-weight: bold;
color: gray;
}
}
}
/* MAIN SHEET */
div.sheet-pc {
grid-column-gap: 0.2em;
grid-row-gap: 0.2em;