Settings support for preconfiguring column groupings for combinable skills

Settings support for preconfiguring column groupings for combinable skills
This commit is contained in:
fredhicks
2021-05-22 17:03:27 -04:00
parent 6961c90f9c
commit aea07cadf4
3 changed files with 108 additions and 33 deletions
+78 -14
View File
@@ -34,9 +34,19 @@
<div data-i18n="custom-aspects-desc"></div>
</div>
<div>
<b><span data-i18n="custom-conditions"></span>:</b>
<input type="text" name="attr_custom-conditions" value="">
<div data-i18n="custom-conditions-desc"></div>
<b><span data-i18n="custom-skills"></span>:</b>
<input type="text" name="attr_custom-skills" value="">
<div data-i18n="custom-skills-desc"></div>
</div>
<div>
<b><span data-i18n="custom-combos-columns"></span>:</b>
<input type="text" name="attr_custom-combos" value="">
<div data-i18n="custom-combos-desc"></div>
</div>
<div>
<b><span data-i18n="custom-stress"></span>:</b>
<input type="text" name="attr_custom-stress" value="">
<div data-i18n="custom-stress-desc"></div>
</div>
<div>
<b><span data-i18n="custom-consequences"></span>:</b>
@@ -44,14 +54,9 @@
<div data-i18n="custom-consequences-desc"></div>
</div>
<div>
<b><span data-i18n="custom-skills"></span>:</b>
<input type="text" name="attr_custom-skills" value="">
<div data-i18n="custom-skills-desc"></div>
</div>
<div>
<b><span data-i18n="custom-stress"></span>:</b>
<input type="text" name="attr_custom-stress" value="">
<div data-i18n="custom-stress-desc"></div>
<b><span data-i18n="custom-conditions"></span>:</b>
<input type="text" name="attr_custom-conditions" value="">
<div data-i18n="custom-conditions-desc"></div>
</div>
</div>
</div>
@@ -2073,6 +2078,8 @@ var gamesets = {
consequences: [],
conditions: [],
skills: [],
combos: [[],[],[]],
combosnames: [],
settings: {}
},
ngen: {
@@ -3174,10 +3181,11 @@ var loadGame = function(key) {
if ( key === "custom" ) {
getAttrs(
[ "custom-aspects", "custom-consequences", "custom-skills", "custom-stress", "custom-conditions" ],
[ "custom-aspects", "custom-consequences", "custom-skills", "custom-stress", "custom-conditions", "custom-combos" ],
function(c) {
var aspects = c["custom-aspects"].trim();
var skills = c["custom-skills"].trim();
var combos = c["custom-combos"].trim();
var consequences = c["custom-consequences"].trim();
var conditions = c["custom-conditions"].trim();
var stresses = c["custom-stress"].trim();
@@ -3188,6 +3196,41 @@ var loadGame = function(key) {
set.skills = skills.toString().split(/\s*,\s*/);
set.settings["SkillStyle"] = "list"; // So it'll display something at all
}
if ( combos !== "" ) {
var tempsplit = [];
set.combos = combos.toString().split(/\s*;\s*/); // column groups are separated by semicolons
set.combosnames = ["","",""]; // ZOD
if ( typeof set.combos[0] !== "undefined" && set.combos[0] !== "" ) {
set.combos[0] = set.combos[0].toString().split(/\s*,\s*/); // split up the comma separated skills in the column, make it an array entry
}
if ( typeof set.combos[1] !== "undefined" && set.combos[1] !== "" ) {
set.combos[1] = set.combos[1].toString().split(/\s*,\s*/); // split up the comma separated skills in the column, make it an array entry
}
if ( typeof set.combos[2] !== "undefined" && set.combos[2] !== "" ) {
set.combos[2] = set.combos[2].toString().split(/\s*,\s*/); // split up the comma separated skills in the column, make it an array entry
}
tempsplit = set.combos[0][0].toString().split(/\s*:\s*/);
if(typeof tempsplit[1] !== "undefined" && tempsplit[1] !== "") {
log("got a column label: " + tempsplit[0]);
// Then we've got the column label in tempsplit[0] and the actual skill name in tempsplit[1]
set.combosnames[0] = tempsplit[0];
set.combos[0][0] = tempsplit[1];
}
tempsplit = set.combos[1][0].toString().split(/\s*:\s*/);
if(typeof tempsplit[1] !== "undefined" && tempsplit[1] !== "") {
log("got a column label: " + tempsplit[0]);
// Then we've got the column label in tempsplit[0] and the actual skill name in tempsplit[1]
set.combosnames[1] = tempsplit[0];
set.combos[1][0] = tempsplit[1];
}
tempsplit = set.combos[1][0].toString().split(/\s*:\s*/);
if(typeof tempsplit[1] !== "undefined" && tempsplit[1] !== "") {
log("got a column label: " + tempsplit[0]);
// Then we've got the column label in tempsplit[0] and the actual skill name in tempsplit[1]
set.combosnames[2] = tempsplit[0];
set.combos[2][0] = tempsplit[1];
}
}
if ( consequences !== "" ) {
var cons = consequences.toString().split(/\s*,\s*/);
set.consequences = [];
@@ -3677,6 +3720,14 @@ var addSkills = function(values) {
}
var attrs = { addskills: "" };
if ( typeof values.combosnames === "object" ) {
// ZOD combocol1, 2, 3
for(var i=0; i < values.combosnames.length; i++) {
var colnum = i+1;
attrs["combocol"+colnum] = values.combosnames[i];
}
}
getSectionIDs("skills", function(currentskills) {
var skillFilter = {};
@@ -3709,7 +3760,20 @@ var addSkills = function(values) {
var skillid = "repeating_skills_" + newid + "_skill";
attrs[skillid] = skillname;
attrs["repeating_skills_" + newid + "_rating"] = 0;
attrs["repeating_skills_" + newid + "_column"] = 1;
attrs["repeating_skills_" + newid + "_column"] = 1; // ZOD ZOD ZOD ZOD ZOD ZOD ZOD ZOD
if ( typeof values.combos === "object" ) {
for(var x=0;x < values.combos.length;x++) {
var stopnow = false;
for(var y=0;y < values.combos[x].length;y++) {
if ( skillname === values.combos[x][y] ) {
attrs["repeating_skills_" + newid + "_column"] = x+1;
stopnow = true; break;
}
}
if (stopnow) { break; }
}
}
// loadSkills() does this work too, but this makes sure that it won't have weird gaps if the rating attribute is encountered before the skill
skillFilter[skillname] = true;
skillNameByID[skillid] = skillname;
@@ -4660,7 +4724,7 @@ on("clicked:repeating_swaps:loadswap", function(e) {
// their at-rest state is empty anyway.
const attributes = [
"character_name", "uninitialized", "SheetOptions", "Show-Aspects", "Show-Combinable", "Show-Conditions", "Show-Consequences", "Show-Corruption", "Show-Diceprompts", "Show-Extras", "Show-FP", "Show-Logo", "Show-Modes", "Show-Notes", "Show-Packages", "Show-Powers", "Show-Refresh", "Show-Roles", "Show-RollableAspects", "Show-Skills", "Show-Skillswaps", "Show-Stress", "Show-Stunts", "Show-TempAspects", "EditAspects", "EditCombos", "EditConditions", "EditConsequences", "EditExtras", "EditModes", "EditNotes", "EditPackages", "EditPowers", "EditRoles", "EditSkills", "EditStress", "EditStunts", "EditSwaps", "EditTempAspects", "aspectlist", "combomulti", "combotally", "combotext", "combocol1", "combocol2", "combocol3", "corruption", "custom-aspects", "custom-conditions", "custom-consequences", "custom-skills", "custom-stress", "focused", "fp", "lastswapped", "pronouns", "refresh", "rolllist", "rolltally", "setgame", "skillcount", "SkillStyle", "specialized", "stuntcount", "theme"
"character_name", "uninitialized", "SheetOptions", "Show-Aspects", "Show-Combinable", "Show-Conditions", "Show-Consequences", "Show-Corruption", "Show-Diceprompts", "Show-Extras", "Show-FP", "Show-Logo", "Show-Modes", "Show-Notes", "Show-Packages", "Show-Powers", "Show-Refresh", "Show-Roles", "Show-RollableAspects", "Show-Skills", "Show-Skillswaps", "Show-Stress", "Show-Stunts", "Show-TempAspects", "EditAspects", "EditCombos", "EditConditions", "EditConsequences", "EditExtras", "EditModes", "EditNotes", "EditPackages", "EditPowers", "EditRoles", "EditSkills", "EditStress", "EditStunts", "EditSwaps", "EditTempAspects", "aspectlist", "combomulti", "combotally", "combotext", "combocol1", "combocol2", "combocol3", "corruption", "custom-aspects", "custom-combos", "custom-conditions", "custom-consequences", "custom-skills", "custom-stress", "focused", "fp", "lastswapped", "pronouns", "refresh", "rolllist", "rolltally", "setgame", "skillcount", "SkillStyle", "specialized", "stuntcount", "theme"
];
const fieldsets = {
+28 -19
View File
@@ -234,13 +234,31 @@
"descriptiontranslationkey": "custom-aspects-desc"
},
{
"attribute": "custom-conditions",
"displayname": "Custom Conditions",
"displaytranslationkey": "custom-conditions",
"attribute": "custom-skills",
"displayname": "Custom Skill List",
"displaytranslationkey": "custom-skills",
"type": "text",
"value": "",
"description": "Enter a list separated by commas, with each entry in this format (not including the quotes): \"Label:Length\", e.g., \"Indebted:5\". You may optionally include values for each box separated by spaces after the length, e.g., \"Doomed:1 6\". You must select the Custom Build option up top for this to be used.",
"descriptiontranslationkey": "custom-conditions-desc"
"description": "Enter a list separated by commas. You must select the Custom Build option up top for this to be used.",
"descriptiontranslationkey": "custom-skills-desc"
},
{
"attribute": "custom-combos",
"displayname": "Custom Combinable Skill Columns",
"displaytranslationkey": "custom-combos-columns",
"type": "text",
"value": "",
"description": "You must define the skills in the skill list, before categorizing them into columns here. Separate skills by commas and columns (up to 3) by semicolons: \"Skill, Skill; Skill, Skill\", e.g., \"Body, Mind; Air, Earth, Fire, Water\" for two columns skills. If each column has a label, put that at the start of each list followed by a colon, e.g., \"Self: Body, Mind; Element: Air, Earth, Fire, Water\", Make sure to enable Combinable Skills. You must select the Custom Build option up top for this to be used.",
"descriptiontranslationkey": "custom-combos-desc"
},
{
"attribute": "custom-stress",
"displayname": "Custom Stress Tracks",
"displaytranslationkey": "custom-stress",
"type": "text",
"value": "",
"description": "Enter a list separated by commas, with each entry in this format (not including the quotes): \"Label:Default Length\", e.g., \"Social:2\". You may optionally include values for each box (including ones beyond the default length) separated by spaces after the length, e.g., \"Social:2 1 2 3 4 5 6\". You must select the Custom Build option up top for this to be used.",
"descriptiontranslationkey": "custom-stress-desc"
},
{
"attribute": "custom-consequences",
@@ -252,22 +270,13 @@
"descriptiontranslationkey": "custom-consequences-desc"
},
{
"attribute": "custom-skills",
"displayname": "Custom Skill List",
"displaytranslationkey": "custom-skills",
"attribute": "custom-conditions",
"displayname": "Custom Conditions",
"displaytranslationkey": "custom-conditions",
"type": "text",
"value": "",
"description": "Enter a list separated by commas. You must select the Custom Build option up top for this to be used.",
"descriptiontranslationkey": "custom-skills-desc"
},
{
"attribute": "custom-stress",
"displayname": "Custom Stress Tracks",
"displaytranslationkey": "custom-stress",
"type": "text",
"value": "",
"description": "Enter a list separated by commas, with each entry in this format (not including the quotes): \"Label:Default Length\", e.g., \"Social:2\". You may optionally include values for each box (including ones beyond the default length) separated by spaces after the length, e.g., \"Social:2 1 2 3 4 5 6\". You must select the Custom Build option up top for this to be used.",
"descriptiontranslationkey": "custom-stress-desc"
"description": "Enter a list separated by commas, with each entry in this format (not including the quotes): \"Label:Length\", e.g., \"Indebted:5\". You may optionally include values for each box separated by spaces after the length, e.g., \"Doomed:1 6\". You must select the Custom Build option up top for this to be used.",
"descriptiontranslationkey": "custom-conditions-desc"
}
],
"legacy": true
+2
View File
@@ -31,6 +31,8 @@
"cost": "Cost",
"Crafts": "Crafts",
"custom-track": "Custom Track (?-?-?)",
"custom-combos-columns": "Custom Combinable Skill Columns",
"custom-combos-desc": "You must define the skills in the skill list, before categorizing them into columns here. Separate skills by commas and columns (up to 3) by semicolons: \"Skill, Skill; Skill, Skill\", e.g., \"Body, Mind; Air, Earth, Fire, Water\" for two columns skills. If each column has a label, put that at the start of each list followed by a colon, e.g., \"Self: Body, Mind; Element: Air, Earth, Fire, Water\", Make sure to enable Combinable Skills. You must select the Custom Build option up top for this to be used.",
"Deceive": "Deceive",
"del-skills": "Remove Skillset",
"desc": "Description",