add $SM.setget, refactor Room to better use $SM

game.room.builder >> game.builder.level

setget is mainly for use in local copies of states, useful for keeping
code cleaner and less redundant while maintaining set/get of states by
the $SM

====functions refactored====
Room.unlockForext //remove update calls
Room.buy //remove update calls
Room.build //remove update calls
Room.cooFire //added locals to reduce gets
Room.adjustTemp //added locals to reduce gets
Room.updateBuilderState //added local to reduce gets
Room.craftUnlocked //Room unlock is always going to be true, don't need
to check parents to avoid errors anymore
Room.buyUnlocked //Room unlock is always going to be true, don't need to
check parents to avoid errors anymore
This commit is contained in:
LucidCrux
2013-07-25 20:31:30 -06:00
parent f4520bce91
commit 2e3f8abd3f
3 changed files with 57 additions and 43 deletions
+8 -1
View File
@@ -147,7 +147,7 @@ var StateManager = {
//return state, undefined or 0
get: function(stateName, requestZero) {
var whichState = null;
var fullPath = $SM.buildPath(stateName, name);
var fullPath = $SM.buildPath(stateName);
//catch errors if parent of state doesn't exist
try{
@@ -161,6 +161,13 @@ var StateManager = {
else return whichState;
},
//mainly for local copy use, add(M) can fail so we can't shortcut them
//since set does not fail, we know state exists and can simply return the object
setget: function(stateName, value, noEvent){
$SM.set(stateName, value, noEvent);
return eval('('+$SM.buildPath(stateName)+')');
},
remove: function(stateName, noEvent) {
var whichState = $SM.buildPath(whichState);
try{