mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-31 01:31:53 +08:00
refactor Outside to use $SM + Room bugfix, \' to "
Refactoring of Outside.js to take better advantage of $SM and simplify
the code.
Includes a small bug fix to Room update handler
Also changed instances of escaped single quote (\') to double (") for
readability and simplicity.
====state changes====
//these were changed for the opposite reason the Room states were. These
seem like states that other locations and events may very well want to
interact with and possibly alter themselves
game.outside.buildings >> game.buildings
game.outside.population >> game.population
game.outside.workders >> game.workers
====functions removed====
Outside.numBuilding // just a $SM.get, no shortcut really needed since
Outside.numBuilding is a pretty long name
Outside.getPopulation // same here
Outside.addBuilding // just an add
Outside.addBuildings // just addM, but wasn't even actually used
====functions refactored====
Outside.killVillagers //moved updates to handler
Outside.updateWorkersView //added local to reduce gets
Outside.increasePopulation //updates moved to handler
Outside.increaseWorker // updates moved to handler
Outside.decreaseWorkder // updates moved to handler
This commit is contained in:
+2
-2
@@ -649,7 +649,7 @@ var Events = {
|
||||
} else if(b.cost) {
|
||||
var disabled = false;
|
||||
for(var store in b.cost) {
|
||||
var num = Engine.activeModule == World ? Path.outfit[store] : $SM.get('stores[\''+store+'\']', true);
|
||||
var num = Engine.activeModule == World ? Path.outfit[store] : $SM.get('stores["'+store+'"]', true);
|
||||
if(typeof num != 'number') num = 0;
|
||||
if(num < b.cost[store]) {
|
||||
// Too expensive
|
||||
@@ -668,7 +668,7 @@ var Events = {
|
||||
var costMod = {};
|
||||
if(info.cost) {
|
||||
for(var store in info.cost) {
|
||||
var num = Engine.activeModule == World ? Path.outfit[store] : $SM.get('stores[\''+store+'\']', true);
|
||||
var num = Engine.activeModule == World ? Path.outfit[store] : $SM.get('stores["'+store+'"]', true);
|
||||
if(typeof num != 'number') num = 0;
|
||||
if(num < info.cost[store]) {
|
||||
// Too expensive
|
||||
|
||||
Reference in New Issue
Block a user