diff --git a/script/events.js b/script/events.js index 7401ec6..b78d483 100644 --- a/script/events.js +++ b/script/events.js @@ -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 diff --git a/script/events/outside.js b/script/events/outside.js index 109eb49..83cbefb 100644 --- a/script/events/outside.js +++ b/script/events/outside.js @@ -5,7 +5,7 @@ Events.Outside = [ { /* Ruined traps */ title: 'A Ruined Trap', isAvailable: function() { - return Engine.activeModule == Outside && Outside.numBuilding('trap') > 0; + return Engine.activeModule == Outside && $SM.get('game.buildings["trap"]', true) > 0; }, scenes: { 'start': { @@ -14,8 +14,8 @@ Events.Outside = [ 'large prints lead away, into the forest.' ], onLoad: function() { - var numWrecked = Math.floor(Math.random() * Outside.numBuilding('trap')) + 1; - Outside.addBuilding('trap', -numWrecked); + var numWrecked = Math.floor(Math.random() * $SM.get('game.buildings["trap"]', true)) + 1; + $SM.add('game.buildings["trap"]', -numWrecked); Outside.updateVillage(); Outside.updateTrapButton(); }, @@ -66,7 +66,7 @@ Events.Outside = [ { /* Sickness */ title: 'Sickness', isAvailable: function() { - return Engine.activeModule == Outside && Outside.getPopulation() > 10 && Outside.getPopulation() < 50; + return Engine.activeModule == Outside && $SM.get('game.population', true) > 10 && $SM.get('game.population', true) < 50; }, scenes: { 'start': { @@ -120,7 +120,7 @@ Events.Outside = [ { /* Plague */ title: 'Plague', isAvailable: function() { - return Engine.activeModule == Outside && Outside.getPopulation() > 50; + return Engine.activeModule == Outside && $SM.get('game.population', true) > 50; }, scenes: { 'start': { @@ -180,7 +180,7 @@ Events.Outside = [ { /* Beast attack */ title: 'A Beast Attack', isAvailable: function() { - return Engine.activeModule == Outside && Outside.getPopulation() > 0; + return Engine.activeModule == Outside && $SM.get('game.population', true) > 0; }, scenes: { 'start': { @@ -211,7 +211,7 @@ Events.Outside = [ { /* Soldier attack */ title: 'A Military Raid', isAvailable: function() { - return Engine.activeModule == Outside && Outside.getPopulation() > 0 && $SM.get('game.cityCleared');; + return Engine.activeModule == Outside && $SM.get('game.population', true) > 0 && $SM.get('game.cityCleared');; }, scenes: { 'start': { diff --git a/script/events/room.js b/script/events/room.js index 70e5ea9..fcd4beb 100644 --- a/script/events/room.js +++ b/script/events/room.js @@ -536,7 +536,7 @@ Events.Room = [ 'some weird metal he picked up on his travels.' ], onLoad: function() { - $SM.add('stores[\'alien alloy\']', 1); + $SM.add('stores["alien alloy"]', 1); }, buttons: { 'bye': { @@ -552,7 +552,7 @@ Events.Room = [ 'some weird glowing boxes he picked up on his travels.' ], onLoad: function() { - $SM.add('stores[\'energy cell\']', 3); + $SM.add('stores["energy cell"]', 3); }, buttons: { 'bye': { diff --git a/script/outside.js b/script/outside.js index 6146243..5903c20 100644 --- a/script/outside.js +++ b/script/outside.js @@ -140,11 +140,9 @@ var Outside = { if(typeof $SM.get('features.location.outside') == 'undefined') { $SM.set('features.location.outside', true); - $SM.setM('game.outside', { - buildings: {}, - population: 0, - workers: {} - }); + if(!$SM.get('game.buildings')) $SM.set('game.buildings', {}); + if(!$SM.get('game.population')) $SM.set('game.population', 0); + if(!$SM.get('game.workers')) $SM.set('game.workers', {}); } this.updateVillage(); @@ -162,44 +160,12 @@ var Outside = { }).appendTo('div#outsidePanel'); }, - numBuilding: function(bName) { - return $SM.get('game.outside.buildings[\''+bName+'\']', true); - }, - - addBuilding: function(bName, num) { - var cur = $SM.get('game.outside.buildings[\''+bName+'\']'); - if(typeof cur != 'number') cur = 0; - cur += num; - if(cur < 0) cur = 0; - $SM.set('game.outside.buildings[\''+bName+'\']', cur); - this.updateVillage(); - Engine.saveGame(); - }, - - addBuildings: function(list) { - for(k in list) { - var num = $SM.get('game.outside.buildings[\''+k+'\']'); - if(typeof num != 'number') num = 0; - num += list[k]; - $SM.set('game.outside.buildings[\''+k+'\']', num); - } - this.updateVillage(); - Engine.saveGame(); - }, - getMaxPopulation: function() { - return Outside.numBuilding('hut') * 4; - }, - - getPopulation: function() { - if($SM.get('features.location.outside') && $SM.get('game.outside.population')) { - return $SM.get('game.outside.population'); - } - return 0; + return $SM.get('game.buildings["hut"]', true) * 4; }, increasePopulation: function() { - var space = Outside.getMaxPopulation() - $SM.get('game.outside.population'); + var space = Outside.getMaxPopulation() - $SM.get('game.population'); if(space > 0) { var num = Math.floor(Math.random()*(space/2) + space/2); if(num == 0) num = 1; @@ -215,36 +181,30 @@ var Outside = { Notifications.notify(null, "the town's booming. word does get around."); } Engine.log('population increased by ' + num); - $SM.add('game.outside.population', num); - Outside.updateVillage(); - Outside.updateWorkersView(); - Outside.updateVillageIncome(); + $SM.add('game.population', num); } Outside.schedulePopIncrease(); }, killVillagers: function(num) { - $SM.add('game.outside.population', num * -1); - if($SM.get('game.outside.population') < 0) { - $SM.set('game.outside.population', 0); + $SM.add('game.population', num * -1); + if($SM.get('game.population') < 0) { + $SM.set('game.population', 0); } var remaining = Outside.getNumGatherers(); if(remaining < 0) { var gap = -remaining; - for(var k in $SM.get('game.outside.workers')) { - var num = $SM.get('game.outside.workers[\''+k+'\']'); + for(var k in $SM.get('game.workers')) { + var num = $SM.get('game.workers["'+k+'"]'); if(num < gap) { gap -= num; - $SM.set('game.outside.workers[\''+k+'\']', 0); + $SM.set('game.workers["'+k+'"]', 0); } else { - $SM.add('game.outside.workers[\''+k+'\']', gap * -1); + $SM.add('game.workers["'+k+'"]', gap * -1); break; } } } - Outside.updateVillage(); - Outside.updateWorkersView(); - Outside.updateVillageIncome(); }, schedulePopIncrease: function() { @@ -258,7 +218,7 @@ var Outside = { // If our population is 0 and we don't already have a workers view, // there's nothing to do here. - if(!workers.length && $SM.get('game.outside.population') == 0) return; + if(!workers.length && $SM.get('game.population') == 0) return; var needsAppend = false; if(workers.length == 0) { @@ -266,13 +226,14 @@ var Outside = { workers = $('
').attr('id', 'workers').css('opacity', 0); } - var numGatherers = $SM.get('game.outside.population'); + var numGatherers = $SM.get('game.population'); var gatherer = $('div#workers_row_gatherer', workers); - for(var k in $SM.get('game.outside.workers')) { + for(var k in $SM.get('game.workers')) { + var workerCount = $SM.get('game.workers["'+k+'"]'); var row = $('div#workers_row_' + k.replace(' ', '-'), workers); if(row.length == 0) { - row = Outside.makeWorkerRow(k, $SM.get('game.outside.workers[\''+k+'\']')); + row = Outside.makeWorkerRow(k, workerCount); var curPrev = null; workers.children().each(function(i) { @@ -297,10 +258,10 @@ var Outside = { } } else { - $('div#' + row.attr('id') + ' > div.row_val > span', workers).text($SM.get('game.outside.workers[\''+k+'\']')); + $('div#' + row.attr('id') + ' > div.row_val > span', workers).text(workerCount); } - numGatherers -= $SM.get('game.outside.workers[\''+k+'\']'); - if($SM.get('game.outside.workers[\''+k+'\']') == 0) { + numGatherers -= workerCount; + if(workerCount == 0) { $('.dnBtn', row).addClass('disabled'); $('.dnManyBtn', row).addClass('disabled'); } else { @@ -331,9 +292,9 @@ var Outside = { }, getNumGatherers: function() { - var num = $SM.get('game.outside.population'); - for(var k in $SM.get('game.outside.workers')) { - num -= $SM.get('game.outside.workers[\''+k+'\']'); + var num = $SM.get('game.population'); + for(var k in $SM.get('game.workers')) { + num -= $SM.get('game.workers["'+k+'"]'); } return num; }, @@ -373,20 +334,16 @@ var Outside = { if(Outside.getNumGatherers() > 0) { var increaseAmt = Math.min(Outside.getNumGatherers(), btn.data); Engine.log('increasing ' + worker + ' by ' + increaseAmt); - $SM.add('game.outside.workers[\''+worker+'\']', increaseAmt); - Outside.updateVillageIncome(); - Outside.updateWorkersView(); + $SM.add('game.workers["'+worker+'"]', increaseAmt); } }, decreaseWorker: function(btn) { var worker = $(this).closest('.workerRow').children('.row_key').text(); - if($SM.get('game.outside.workers[\''+worker+'\']') > 0) { - var decreaseAmt = Math.min($SM.get('game.outside.workers[\''+worker+'\']') || 0, btn.data); + if($SM.get('game.workers["'+worker+'"]') > 0) { + var decreaseAmt = Math.min($SM.get('game.workers["'+worker+'"]') || 0, btn.data); Engine.log('decreasing ' + worker + ' by ' + decreaseAmt); - $SM.add('game.outside.workers[\''+worker+'\']', decreaseAmt * -1); - Outside.updateVillageIncome(); - Outside.updateWorkersView(); + $SM.add('game.workers["'+worker+'"]', decreaseAmt * -1); } }, @@ -430,9 +387,9 @@ var Outside = { population = $('
').attr('id', 'population').appendTo(village); } - for(var k in $SM.get('game.outside.buildings')) { + for(var k in $SM.get('game.buildings')) { if(k == 'trap') { - var numTraps = $SM.get('game.outside.buildings[\''+k+'\']'); + var numTraps = $SM.get('game.buildings["'+k+'"]'); var numBait = $SM.get('stores.bait', true); var traps = numTraps - numBait; traps = traps < 0 ? 0 : traps; @@ -442,14 +399,14 @@ var Outside = { if(Outside.checkWorker(k)) { Outside.updateWorkersView(); } - Outside.updateVillageRow(k, $SM.get('game.outside.buildings[\''+k+'\']'), village); + Outside.updateVillageRow(k, $SM.get('game.buildings["'+k+'"]'), village); } } - population.text('pop ' + $SM.get('game.outside.population') + '/' + this.getMaxPopulation()); + population.text('pop ' + $SM.get('game.population') + '/' + this.getMaxPopulation()); var hasPeeps; - if(Outside.numBuilding('hut') == 0) { + if($SM.get('game.buildings["hut"]', true) == 0) { hasPeeps = false; village.addClass('noHuts'); } else { @@ -490,10 +447,10 @@ var Outside = { if(typeof jobs == 'object') { for(var i = 0, len = jobs.length; i < len; i++) { var job = jobs[i]; - if(typeof $SM.get('game.outside.buildings[\''+name+'\']') == 'number' && - typeof $SM.get('game.outside.workers[\''+job+'\']') != 'number') { + if(typeof $SM.get('game.buildings["'+name+'"]') == 'number' && + typeof $SM.get('game.workers["'+job+'"]') != 'number') { Engine.log('adding ' + job + ' to the workers list') - $SM.set('game.outside.workers[\''+job+'\']', 0); + $SM.set('game.workers["'+job+'"]', 0); added = true; } } @@ -504,7 +461,7 @@ var Outside = { updateVillageIncome: function() { for(var worker in Outside._INCOME) { var income = Outside._INCOME[worker]; - var num = worker == 'gatherer' ? Outside.getNumGatherers() : $SM.get('game.outside.workers[\''+worker+'\']'); + var num = worker == 'gatherer' ? Outside.getNumGatherers() : $SM.get('game.workers["'+worker+'"]'); if(typeof num == 'number') { var stores = {}; if(num < 0) num = 0; @@ -533,7 +490,7 @@ var Outside = { updateTrapButton: function() { var btn = $('div#trapsButton'); - if(Outside.numBuilding('trap') > 0) { + if($SM.get('game.buildings["trap"]', true) > 0) { if(btn.length == 0) { new Button.Button({ id: 'trapsButton', @@ -553,7 +510,7 @@ var Outside = { }, setTitle: function() { - var numHuts = this.numBuilding('hut'); + var numHuts = $SM.get('game.buildings["hut"]', true); var title; if(numHuts == 0) { title = "A Silent Forest"; @@ -589,14 +546,14 @@ var Outside = { gatherWood: function() { Notifications.notify(Outside, "dry brush and dead branches litter the forest floor") - var gatherAmt = Outside.numBuilding('cart') > 0 ? 50 : 10; + var gatherAmt = $SM.get('game.buildings["cart"]', true) > 0 ? 50 : 10; $SM.add('stores.wood', gatherAmt); }, checkTraps: function() { var drops = {}; var msg = []; - var numTraps = Outside.numBuilding('trap'); + var numTraps = $SM.get('game.buildings["trap"]', true); var numBait = $SM.get('stores.bait', true); var numDrops = numTraps + (numBait < numTraps ? numBait : numTraps); for(var i = 0; i < numDrops; i++) { @@ -634,6 +591,11 @@ var Outside = { handleStateUpdates: function(e){ if(e.category == 'stores'){ Outside.updateVillage(); - } + } else if(e.stateName.indexOf('game.workers') == 0 + || e.stateName.indexOf('game.population') == 0){ + Outside.updateVillage(); + Outside.updateWorkersView(); + Outside.updateVillageIncome(); + }; } }; \ No newline at end of file diff --git a/script/path.js b/script/path.js index 22dde15..efbf081 100644 --- a/script/path.js +++ b/script/path.js @@ -104,7 +104,7 @@ var Path = { for(var k in $SM.get('character.perks')) { var id = 'perk_' + k.replace(' ', '-'); var r = $('#' + id); - if($SM.get('character.perks[\''+k+'\']') && r.length == 0) { + if($SM.get('character.perks["'+k+'"]') && r.length == 0) { r = $('
').attr('id', id).addClass('perkRow').appendTo(perks); $('
').addClass('row_key').text(k).appendTo(r); $('
').addClass('tooltip bottom right').text(Engine.Perks[k].desc).appendTo(r); @@ -130,11 +130,11 @@ var Path = { // Add the armour row var armour = "none"; - if($SM.get('stores[\'s armour\']', true) > 0) + if($SM.get('stores["s armour"]', true) > 0) armour = "steel"; - else if($SM.get('stores[\'i armour\']', true) > 0) + else if($SM.get('stores["i armour"]', true) > 0) armour = "iron"; - else if($SM.get('stores[\'l armour\']', true) > 0) + else if($SM.get('stores["l armour"]', true) > 0) armour = "leather"; var aRow = $('#armourRow'); if(aRow.length == 0) { @@ -175,10 +175,10 @@ var Path = { for(var k in carryable) { var store = carryable[k]; - var have = $SM.get('stores[\''+k+'\']'); + var have = $SM.get('stores["'+k+'"]'); var num = Path.outfit[k]; num = typeof num == 'number' ? num : 0; - var numAvailable = $SM.get('stores[\''+k+'\']', true); + var numAvailable = $SM.get('stores["'+k+'"]', true); var row = $('div#outfit_row_' + k.replace(' ', '-'), outfit); if((store.type == 'tool' || store.type == 'weapon') && have > 0) { total += num * Path.getWeight(k); @@ -247,7 +247,7 @@ var Path = { $('
').addClass('dnManyBtn').appendTo(val).click([10], Path.decreaseSupply); $('
').addClass('clear').appendTo(row); - var numAvailable = $SM.get('stores[\''+name+'\']', true); + var numAvailable = $SM.get('stores["'+name+'"]', true); var tt = $('
').addClass('tooltip bottom right').appendTo(row); $('
').addClass('row_key').text('weight').appendTo(tt); $('
').addClass('row_val').text(Path.getWeight(name)).appendTo(tt); @@ -262,9 +262,9 @@ var Path = { Engine.log('increasing ' + supply + ' by up to ' + btn.data); var cur = Path.outfit[supply]; cur = typeof cur == 'number' ? cur : 0; - if(Path.getFreeSpace() >= Path.getWeight(supply) && cur < $SM.get('stores[\''+supply+'\']', true)) { + if(Path.getFreeSpace() >= Path.getWeight(supply) && cur < $SM.get('stores["'+supply+'"]', true)) { var maxExtraByWeight = Math.floor(Path.getFreeSpace() / Path.getWeight(supply)); - var maxExtraByStore = $SM.get('stores[\''+supply+'\']', true) - cur; + var maxExtraByStore = $SM.get('stores["'+supply+'"]', true) - cur; var maxExtraByBtn = btn.data; Path.outfit[supply] = cur + Math.min(maxExtraByBtn, Math.min(maxExtraByWeight, maxExtraByStore)); Path.updateOutfitting(); @@ -296,7 +296,7 @@ var Path = { embark: function() { for(var k in Path.outfit) { - $SM.add('stores[\''+k+'\']', -Path.outfit[k]); + $SM.add('stores["'+k+'"]', -Path.outfit[k]); } World.onArrival(); $('#outerSlider').animate({left: '-700px'}, 300); diff --git a/script/room.js b/script/room.js index 2f0f874..778201a 100644 --- a/script/room.js +++ b/script/room.js @@ -22,7 +22,7 @@ var Room = { maxMsg: "more traps won't help now", type: 'building', cost: function() { - var n = Outside.numBuilding('trap'); + var n = $SM.get('game.buildings["trap"]', true); return { 'wood': 10 + (n*10) }; @@ -48,7 +48,7 @@ var Room = { maxMsg: 'no more room for huts.', type: 'building', cost: function() { - var n = Outside.numBuilding('hut'); + var n = $SM.get('game.buildings["hut"]', true); return { 'wood': 100 + (n*50) }; @@ -765,13 +765,13 @@ var Room = { var id = "row_" + k.replace(' ', '-'); var row = $('div#' + id, location); - var num = $SM.get('stores[\''+k+'\']'); + var num = $SM.get('stores["'+k+'"]'); if(typeof num != 'number' || isNaN(num)) { // No idea how counts get corrupted, but I have reason to believe that they occassionally do. // Build a little fence around it! num = 0; - $SM.set('stores[\''+k+'\']', 0); + $SM.set('stores["'+k+'"]', 0); } @@ -834,7 +834,7 @@ var Room = { var tt = $('
').addClass('tooltip bottom right'); var storeName = el.attr('id').substring(4).replace('-', ' '); for(var incomeSource in $SM.get('income')) { - var income = $SM.get('income[\''+incomeSource+'\']'); + var income = $SM.get('income["'+incomeSource+'"]'); for(var store in income.stores) { if(store == storeName && income.stores[store] != 0) { $('
').addClass('row_key').text(incomeSource).appendTo(tt); @@ -854,7 +854,7 @@ var Room = { buy: function(buyBtn) { var thing = $(buyBtn).attr('buildThing'); var good = Room.TradeGoods[thing]; - var numThings = $SM.get('stores[\''+thing+'\']', true); + var numThings = $SM.get('stores["'+thing+'"]', true); if(numThings < 0) numThings = 0; if(good.maximum <= numThings) { return; @@ -863,7 +863,7 @@ var Room = { var storeMod = {}; var cost = good.cost(); for(var k in cost) { - var have = $SM.get('stores[\''+k+'\']', true); + var have = $SM.get('stores["'+k+'"]', true); if(have < cost[k]) { Notifications.notify(Room, "not enough " + k); return false; @@ -875,7 +875,7 @@ var Room = { Notifications.notify(Room, good.buildMsg); - $SM.add('stores[\''+thing+'\']', 1); + $SM.add('stores["'+thing+'"]', 1); if(thing == 'compass') { Path.openPath(); @@ -896,10 +896,10 @@ var Room = { case 'weapon': case 'tool': case 'upgrade': - numThings = $SM.get('stores[\''+thing+'\']', true); + numThings = $SM.get('stores["'+thing+'"]', true); break; case 'building': - numThings = Outside.numBuilding(thing); + numThings = $SM.get('game.buildings["'+thing+'"]', true); break; } @@ -911,7 +911,7 @@ var Room = { var storeMod = {}; var cost = craftable.cost(); for(var k in cost) { - var have = $SM.get('stores[\''+k+'\']', true); + var have = $SM.get('stores["'+k+'"]', true); if(have < cost[k]) { Notifications.notify(Room, "not enough " + k); return false; @@ -928,10 +928,10 @@ var Room = { case 'weapon': case 'upgrade': case 'tool': - $SM.add('stores[\''+thing+'\']', 1); + $SM.add('stores["'+thing+'"]', 1); break; case 'building': - Outside.addBuilding(thing, 1); + $SM.add('game.buildings["'+thing+'"]', 1); break; } }, @@ -946,7 +946,7 @@ var Room = { } if($SM.get('game.builder.level') < 4) return false; var craftable = Room.Craftables[thing]; - if(Room.needsWorkshop(craftable.type) && Outside.numBuilding('workshop') == 0) return false; + if(Room.needsWorkshop(craftable.type) && $SM.get('game.buildings["workshop"]', true) == 0) return false; var cost = craftable.cost(); // Show buttons if we have at least 1/2 the wood, and all other components have been seen. @@ -954,7 +954,7 @@ var Room = { return false; } for(var c in cost) { - if(!$SM.get('stores[\''+c+'\']')) { + if(!$SM.get('stores["'+c+'"]')) { return false; } } @@ -967,8 +967,8 @@ var Room = { buyUnlocked: function(thing) { if(Room.buttons[thing]) { return true; - } else if(Outside.numBuilding('trading post') > 0) { - if(thing == 'compass' || $SM.get('stores[\''+thing+'\']')) { + } else if($SM.get('game.buildings["trading post"]', true) > 0) { + if(thing == 'compass' || $SM.get('stores["'+thing+'"]')) { // Allow the purchase of stuff once you've seen it return true; } @@ -986,14 +986,14 @@ var Room = { var craftSection = $('#craftBtns'); var cNeedsAppend = false; - if(craftSection.length == 0 && Outside.numBuilding('workshop') > 0) { + if(craftSection.length == 0 && $SM.get('game.buildings["workshop"]', true) > 0) { craftSection = $('
').attr('id', 'craftBtns').css('opacity', 0); cNeedsAppend = true; } var buySection = $('#buyBtns'); var bNeedsAppend = false; - if(buySection.length == 0 && Outside.numBuilding('trading post') > 0) { + if(buySection.length == 0 && $SM.get('game.buildings["trading post"]', true) > 0) { buySection = $('
').attr('id', 'buyBtns').css('opacity', 0); bNeedsAppend = true; } @@ -1083,6 +1083,8 @@ var Room = { Room.updateBuildButtons(); } else if(e.category == 'income'){ Room.updateIncomeView(); - }; + } else if(e.stateName.indexOf('game.buildings') == 0){ + Room.updateBuildButtons(); + } } }; \ No newline at end of file diff --git a/script/ship.js b/script/ship.js index 00b1a4e..53639ed 100644 --- a/script/ship.js +++ b/script/ship.js @@ -103,11 +103,11 @@ var Ship = { }, reinforceHull: function() { - if($SM.get('stores[\'alien alloy\']', true) < Ship.ALLOY_PER_HULL) { + if($SM.get('stores["alien alloy"]', true) < Ship.ALLOY_PER_HULL) { Notifications.notify(Ship, "not enough alien alloy"); return false; } - $SM.add('stores[\'alien alloy\']', -Ship.ALLOY_PER_HULL); + $SM.add('stores["alien alloy"]', -Ship.ALLOY_PER_HULL); $SM.add('game.spaceShip.hull', 1); if($SM.get('game.spaceShip.hull') > 0) { Button.setDisabled($('#liftoffButton', Ship.panel), false); @@ -116,11 +116,11 @@ var Ship = { }, upgradeEngine: function() { - if($SM.get('stores[\'alien alloy\']', true) < Ship.ALLOY_PER_THRUSTER) { + if($SM.get('stores["alien alloy"]', true) < Ship.ALLOY_PER_THRUSTER) { Notifications.notify(Ship, "not enough alien alloy"); return false; } - $SM.add('stores[\'alien alloy\']', -Ship.ALLOY_PER_THRUSTER); + $SM.add('stores["alien alloy"]', -Ship.ALLOY_PER_THRUSTER); $SM.add('game.spaceShip.thrusters', 1) $('#engineRow .row_val', Ship.panel).text($SM.get('game.spaceShip.thrusters')); }, diff --git a/script/state_manager.js b/script/state_manager.js index 5057b87..bcd3d1d 100644 --- a/script/state_manager.js +++ b/script/state_manager.js @@ -47,7 +47,7 @@ var StateManager = { //create all parents and then set state createState: function(stateName, value) { - var words = stateName.split(/[.\[\]']+/); + var words = stateName.split(/[.\[\]'"]+/); var obj = State; var w = null; for(var i=0, len=words.length-1;i 0 && World.getDistance() >= 8) { + if(!$SM.get('stores["i armour"]', true) > 0 && World.getDistance() >= 8) { World.danger = true; return true; } - if(!$SM.get('stores[\'s armour\']', true) > 0 && World.getDistance() >= 18) { + if(!$SM.get('stores["s armour"]', true) > 0 && World.getDistance() >= 18) { World.danger = true; return true; } @@ -417,7 +417,7 @@ var World = { World.danger = false; return true; } - if(World.getDistance < 18 && $SM.get('stores[\'i armour\']', true) > 0) { + if(World.getDistance < 18 && $SM.get('stores["i armour"]', true) > 0) { World.danger = false; return true; } @@ -827,16 +827,16 @@ var World = { goHome: function() { // Home safe! Commit the changes. $SM.setM('game.world', World.state); - if(World.state.sulphurmine && Outside.numBuilding('sulphur mine') == 0) { - Outside.addBuilding('sulphur mine', 1); + if(World.state.sulphurmine && $SM.get('game.buildings["sulphur mine"]', true) == 0) { + $SM.add('game.buildings["sulphur mine"]', 1); Engine.event('progress', 'sulphur mine'); } - if(World.state.ironmine && Outside.numBuilding('iron mine') == 0) { - Outside.addBuilding('iron mine', 1); + if(World.state.ironmine && $SM.get('game.buildings["iron mine"]', true) == 0) { + $SM.add('game.buildings["iron mine"]', 1); Engine.event('progress', 'iron mine'); } - if(World.state.coalmine && Outside.numBuilding('coal mine') == 0) { - Outside.addBuilding('coal mine', 1); + if(World.state.coalmine && $SM.get('game.buildings["coal mine"]', true) == 0) { + $SM.add('game.buildings["coal mine"]', 1); Engine.event('progress', 'coal mine'); } if(World.state.ship && !$SM.get('features.location.spaceShip')) { @@ -852,7 +852,7 @@ var World = { } for(var k in Path.outfit) { - $SM.add('stores[\''+k+'\']', Path.outfit[k]); + $SM.add('stores["'+k+'"]', Path.outfit[k]); if(World.leaveItAtHome(k)) { Path.outfit[k] = 0; } @@ -869,11 +869,11 @@ var World = { }, getMaxHealth: function() { - if($SM.get('stores[\'s armour\']', true) > 0) { + if($SM.get('stores["s armour"]', true) > 0) { return World.BASE_HEALTH + 35; - } else if($SM.get('stores[\'i armour\']', true) > 0) { + } else if($SM.get('stores["i armour"]', true) > 0) { return World.BASE_HEALTH + 15; - } else if($SM.get('stores[\'l armour\']', true) > 0) { + } else if($SM.get('stores["l armour"]', true) > 0) { return World.BASE_HEALTH + 5; } return World.BASE_HEALTH; @@ -887,7 +887,7 @@ var World = { }, getMaxWater: function() { - if($SM.get('stores[\'water tank\']', true) > 0) { + if($SM.get('stores["water tank"]', true) > 0) { return World.BASE_WATER + 50; } else if($SM.get('stores.cask', true) > 0) { return World.BASE_WATER + 20;