I'm currently working on making a creature breeding game calculator/roller, and I've got a strange problem that i cant seem to figure out.
I'm not quite sure how to explain it, but ultimately what's wrong is that the 'gene abbreviations' I'm pulling from the dad's genetic info is not coming up in the baby's array. The math im using should make it so that the gene passes at 99%, meaning it should definitely be in the array but it's not actually coming up? I tried a bunch of different methods that i looked up and from here as well but nothing seems to be sticking.
I'm checking this in console.log and the array shows up as empty, but if you expand it in the console you can see it has values inside it! i'm not sure what i'm doing wrong and it's stopping me from continuing on with the rest of the code that i have planned. since the gene abbreviations arent actually in the array, the array isn't pushing anything to the childrens' genetic info. (i may be wrong about that though since im not actually coder by any means, but i'll cross that next bridge when i get to it haha)
the roller itself is at [http://seabirdtestroller.neocities.com] so you can try it out and see how it works. You will need to input the exact text that i placeholder'd in the input fields, since right now those are the only gene abbreviations i'm testing with and they're only being read from the dad's side currently
here is the entirety of the genohell.js file for quick reference, but it pulls info from the rollermath.js file as well (from the roller site):
function makeGeno(){
var geneArray = [];
$babyGenes = geneArray;
console.log("Dad: " + $DadGenes);
//console.log("Mom: " + $MomGenes);
console.log($babyGenes);
var allGenes = {
"free" : [
{ "rec" : "nA",
"dom" : "AA",
"phen" : "Ash"
},
{ "rec" : "nPn",
"dom" : "PnPn",
"phen" : "Pangare"
},
{ "rec" : "nPt",
"dom" : "PtPt",
"phen" : "Points"
},
{ "rec" : "nS",
"dom" : "SS",
"phen" : "Soot"
},
{ "rec" : "nSa",
"dom" : "SaSa",
"phen" : "Sable"
},
{ "rec" : "nSc",
"dom" : "ScSc",
"phen" : "Scruff"
},
{ "rec" : "nSk",
"dom" : "SkSk",
"phen" : "Skull"
}
]
}
/*-------------------------------- CALC HELL -------------------------------------------*/
if($DadGenes.includes("nA")){
$passrate = Math.floor((Math.random() * 100) + 1);
if($passrate <= 99){
geneArray.push("nA");
}
}
if($DadGenes.includes("nPn")){
$passrate = Math.floor((Math.random() * 100) + 1);
if($passrate <= 99){
geneArray.push("nPn");
}
}
}
things ive tried but didnt seem to work for me:
- JSON.stringify();
- .toString();
- .join()
- .slice(0);
- .concat();
any ideas for fixing the babyGenes array in the console so that the values actually come up would be greatly appreciated, thanks!! :)