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

Loading…
Cancel
Save