lots of bugfixes

- bugfix Engine.startThieves call changed to $SM call
- bugfix $SM.remove not deleting state
- bugfix workaround for empty string when creating states
     For some reason splitting "state.sub.sub2["sub3"]" will result in
     empty strings whereas "state.sub.sub2[\'sub3\']" didn't. Maybe a
     javascript regex quirk?

     Had to add a loop to remove '' from the split string array.
- modified collectIncome so that only one update event fires for the 
  whole function, no event if no income was added.
- modified updateBuildButtons so that buttons would show up if the
  building had already been built.
     changed check to be wood != undefined

     Also changed room to display store values of 0 instead of removing 
     the row. It was distracting to have the values shift up and down 
     when tightly managing a resource. If you haven't seen a resource 
     yet, it still doesn't show up.
This commit is contained in:
LucidCrux
2013-07-27 17:21:30 -06:00
parent 36011b5b15
commit 6561e88f9f
3 changed files with 28 additions and 10 deletions
+11 -5
View File
@@ -777,7 +777,7 @@ var Room = {
// thieves?
if(typeof $SM.get('game.thieves') == 'undefined' && num > 5000 && $SM.get('features.location.world')) {
Engine.startThieves();
$SM.startThieves();
}
if(row.length == 0 && num > 0) {
@@ -799,10 +799,8 @@ var Room = {
row.insertAfter(location.find('#row_' + curPrev.replace(' ', '-')));
}
newRow = true;
} else if(num> 0){
} else if(num>= 0){
$('div#' + row.attr('id') + ' > div.row_val', location).text(Math.floor(num));
} else if(num == 0) {
row.remove();
}
}
@@ -949,6 +947,11 @@ var Room = {
if(Room.needsWorkshop(craftable.type) && $SM.get('game.buildings["workshop"]', true) == 0) return false;
var cost = craftable.cost();
//show button if one has already been built
if($SM.get('game.buildings["'+thing+'"]') > 0){
Room.buttons[thing] = true;
return true;
}
// Show buttons if we have at least 1/2 the wood, and all other components have been seen.
if($SM.get('stores.wood', true) < cost['wood'] * 0.5) {
return false;
@@ -960,7 +963,10 @@ var Room = {
}
Room.buttons[thing] = true;
Notifications.notify(Room, craftable.availableMsg);
//don't notify if it has already been built before
if(!$SM.get('game.buildings["'+thing+'"]')){
Notifications.notify(Room, craftable.availableMsg);
}
return true;
},