I'm currently creating a game where I want to store information about a Business, I do this through a multi-dimensional associative array so I have a list of the businesses and within the list key-value pairs of information.The array looks like this
Business.list = {
0.406411267183554: //First Business
{
capital : 5
cash : 3
income: 3
expenses : 6
},
0.398198718278354: //Second Business
{
capital : 6
cash : 7
income: 3
expenses : 7
}...
};
Now I want to go one step deeper so that it now includes information about Upgrades. So within each Business, there will be information about all the upgrades that they have. These upgrades would be shown on the third level. I'm currently stumped on how I would programme this in Javascript. The way that I generate a business is by using Javascript Object Prototype.
function Business(name, sector, capital, employees, type, id, efficiency) {
var self = {
name:name,
sector:sector,
capital:capital,
employees:employees,
type:type,
id:id,
efficiency:efficiency,
};
And then placing it into the list
Business.list[id] = self;
selfvariable is not accessible outside ofBusinessfunction. Also, there's globalself, which refers towindow.