label charred data in constructors

stocked
Daniel Asher Resnick 3 years ago
parent 962f5fff48
commit 458721c55b
  1. 48
      src/public/js/stocked.js

@ -1621,7 +1621,7 @@ var test_data = {
console.log(timelogger.log("post-data")); console.log(timelogger.log("post-data"));
function StockedSetting(name, settingData) { function StockedSetting(name, charredSettingData) {
this.isSubsetting = false; this.isSubsetting = false;
if(result = name.match(/(.*) setting/i)) { if(result = name.match(/(.*) setting/i)) {
this.name = result[1]; this.name = result[1];
@ -1632,24 +1632,24 @@ function StockedSetting(name, settingData) {
this.name = name; this.name = name;
} }
this.lifepaths = []; this.lifepaths = [];
for (let name in settingData) { for (let name in charredSettingData) {
this.lifepaths.push(new StockedLifePath(name, settingData[name])); this.lifepaths.push(new StockedLifePath(name, charredSettingData[name]));
} }
} }
StockedSetting.prototype.addLifepath = function() { StockedSetting.prototype.addLifepath = function() {
this.lifepaths.push(new StockedLifePath(this.newLifepathName, {})); this.lifepaths.push(new StockedLifePath(this.newLifepathName, {}));
} }
function StockedLifePath(name, pathData) { function StockedLifePath(name, charredPathData) {
if(pathData) { if(charredPathData) {
this.name = name; this.name = name;
this.time = pathData.time; this.time = charredPathData.time;
this.res = pathData.res; this.res = charredPathData.res;
this.requires = pathData.requires; this.requires = charredPathData.requires;
this.restrict = pathData.restrict; this.restrict = charredPathData.restrict;
this.stat = new StockedLifePathStats(pathData.stat); this.stat = new StockedLifePathStats(charredPathData.stat);
this.skills = new StockedLifePathSkills(pathData.skills); this.skills = new StockedLifePathSkills(charredPathData.skills);
this.traits = new StockedLifePathTraits(pathData.traits); this.traits = new StockedLifePathTraits(charredPathData.traits);
} else { } else {
this.stat = new StockedLifePathStats(); this.stat = new StockedLifePathStats();
this.skills = new StockedLifePathSkills(); this.skills = new StockedLifePathSkills();
@ -1657,18 +1657,18 @@ function StockedLifePath(name, pathData) {
} }
this.leads_dict = {}; this.leads_dict = {};
if(pathData.leads) { if(charredPathData.leads) {
for(let lead of pathData.leads) { this.leads_dict[lead] = true; } for(let lead of charredPathData.leads) { this.leads_dict[lead] = true; }
} }
this.leads = () => Object.keys(this.leads_dict).filter(l => this.leads_dict[l]); this.leads = () => Object.keys(this.leads_dict).filter(l => this.leads_dict[l]);
} }
function StockedLifePathStats(statData) { function StockedLifePathStats(charredStatData) {
this.P = 0; this.P = 0;
this.M = 0; this.M = 0;
this.PM = 0; this.PM = 0;
if(statData) { if(charredStatData) {
for (let stat of statData) { for (let stat of charredStatData) {
if(stat[1].toUpperCase() == 'P') { if(stat[1].toUpperCase() == 'P') {
this.P += stat[0]; this.P += stat[0];
} }
@ -1689,12 +1689,12 @@ StockedLifePathStats.prototype.toString = function() {
return strs.join(","); return strs.join(",");
}; };
function StockedLifePathSkills(skillData) { function StockedLifePathSkills(charredSkillData) {
this.lpPoints = 0; this.lpPoints = 0;
this.generalPoints = 0; this.generalPoints = 0;
this.lpSkills = []; this.lpSkills = [];
if (skillData) { if (charredSkillData) {
for (let skill of skillData) { for (let skill of charredSkillData) {
if(skill[1].toLowerCase() == "general") { if(skill[1].toLowerCase() == "general") {
this.generalPoints += skill[0]; this.generalPoints += skill[0];
} else { } else {
@ -1717,10 +1717,10 @@ StockedLifePathSkills.prototype.toString = function() {
return strs.join("; "); return strs.join("; ");
}; };
function StockedLifePathTraits(traitData) { function StockedLifePathTraits(charredTraitData) {
if(traitData) { if(charredTraitData) {
this.points = traitData[0]; this.points = charredTraitData[0];
this.lpTraits = traitData.slice(1); this.lpTraits = charredTraitData.slice(1);
} }
} }
StockedLifePathTraits.prototype.removeTrait = function(index) { StockedLifePathTraits.prototype.removeTrait = function(index) {

Loading…
Cancel
Save