CalebJohn / into-the-great-abyss

A prototype for a space exploration/management game.
GNU General Public License v3.0
2 stars 3 forks source link

Remove Hard coding of resources #62

Closed CalebJohn closed 7 years ago

CalebJohn commented 7 years ago

This is especially referencing getResources and getGatherers of BaseObject.js.

The alternative should be storing resources names in one globally accessible location, we can also add some type of enum to make accessing this list more friendly.

e.g.

var resourceNames = ["Wood", "Stone"];
var rsrcs = {Wood: 0, Stone:1};
clayjohn commented 7 years ago

Is this so we can loop over the elements of resourceNames instead of specifying them one-by-one in the function getResources and the like?

clayjohn commented 7 years ago

Okay so for the implementation I'm going to store anything indexed by resource types into arrays which follow the order set out in the global variable resourceNames