I have a stat object with two properties.
One for its name and one for its value.
How would I store all this information in text form so I can get an output like this
"stat name: stat value"
for 14 stats
I understand I can use a for loop and I am but how can I set the this.stat.value to a string and concatenate it with this.stat.name?
this.stat = [];
this.stat.length = 14;
this.stat[0] = {name:"Level",value:1};
this.stat[1] = {name:"Exp",value:0};
this.stat[2] = {name:"MP",value:100};
this.stat[3] = {name:"HP",value:100};
this.stat[4] = {name:"Atk",value:10};
this.stat[5] = {name:"Def",value:10};
this.stat[6] = {name:"Strength",value:5};
this.stat[7] = {name:"Valor",value:5};
this.stat[8] = {name:"Wisdom",value:5};
this.stat[9] = {name:"Dexterity",value:5};
this.stat[10] ={name:"Intelligence",value:5};
this.stat[11] ={name:"Evasion",value:5};
this.stat[12] ={name:"Lucidity",value:5};
this.stat[13] ={name:"Recovery",value:5};
this.stat[14] ={name:"Charm",value:5};
How would I alter the stats once during start up depending on the class for each party member.
I hope I am using exponent in the right way. I want to change only a specific few values per character class
and give them a random value that averages to 10. This will later be used again for leveling up.
this.set_stat = function()
{
//random number that is avarage of target
function Exponential(target){return Math.floor(-target * Math.log(1 - Math.random()));}
//Set Classes
if(this.char_class == "Dream_Guardian")this.stat[7,9,11,12,15].value = Exponential(10);
else if(this.char_class == "Cyborg_Fighter")this.stat[6,7,8,10,13 ].value = Exponential(10);
else if(this.char_class == "Psycho_Mancer" )this.stat[10,12,11,9,8].value = Exponential(10);
else if(this.char_class == "Star_Serpant" )this.stat[6,9,10,12,14].value = Exponential(10);
}
I think I'm getting the hand of variable methods though. I learned of array.join() today but it did not really help/work maybe I'm using it all wrong. Any hints?
EDIT: Oh and realized yesterday that prototype is used for setting properties and methods when OUTSIDE the object...right?
Sorry for bugging you man.