mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-31 01:31:53 +08:00
Low-risk fixes suggested by JSHint.
This commit is contained in:
committed by
Blake Grotewold
parent
2efa9f1667
commit
67b3c7fb7e
+4
-5
@@ -120,11 +120,11 @@
|
|||||||
.addClass('customSelect')
|
.addClass('customSelect')
|
||||||
.addClass('menuBtn')
|
.addClass('menuBtn')
|
||||||
.appendTo(menu);
|
.appendTo(menu);
|
||||||
var options = $('<span>')
|
var selectOptions = $('<span>')
|
||||||
.addClass('customSelectOptions')
|
.addClass('customSelectOptions')
|
||||||
.appendTo(customSelect);
|
.appendTo(customSelect);
|
||||||
var optionsList = $('<ul>')
|
var optionsList = $('<ul>')
|
||||||
.appendTo(options);
|
.appendTo(selectOptions);
|
||||||
$('<li>')
|
$('<li>')
|
||||||
.text("language.")
|
.text("language.")
|
||||||
.appendTo(optionsList);
|
.appendTo(optionsList);
|
||||||
@@ -339,7 +339,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Engine.autoSelect('#description textarea')
|
Engine.autoSelect('#description textarea');
|
||||||
},
|
},
|
||||||
|
|
||||||
import64: function(string64) {
|
import64: function(string64) {
|
||||||
@@ -462,7 +462,6 @@
|
|||||||
var darkCss = Engine.findStylesheet('darkenLights');
|
var darkCss = Engine.findStylesheet('darkenLights');
|
||||||
if (darkCss == null) {
|
if (darkCss == null) {
|
||||||
$('head').append('<link rel="stylesheet" href="css/dark.css" type="text/css" title="darkenLights" />');
|
$('head').append('<link rel="stylesheet" href="css/dark.css" type="text/css" title="darkenLights" />');
|
||||||
Engine.turnLightsOff;
|
|
||||||
$('.lightsOff').text(_('lights on.'));
|
$('.lightsOff').text(_('lights on.'));
|
||||||
} else if (darkCss.disabled) {
|
} else if (darkCss.disabled) {
|
||||||
darkCss.disabled = false;
|
darkCss.disabled = false;
|
||||||
@@ -496,7 +495,7 @@
|
|||||||
var diff = Math.abs(panelIndex - currentIndex);
|
var diff = Math.abs(panelIndex - currentIndex);
|
||||||
slider.animate({left: -(panelIndex * 700) + 'px'}, 300 * diff);
|
slider.animate({left: -(panelIndex * 700) + 'px'}, 300 * diff);
|
||||||
|
|
||||||
if($SM.get('stores.wood') != undefined) {
|
if($SM.get('stores.wood') !== undefined) {
|
||||||
// FIXME Why does this work if there's an animation queue...?
|
// FIXME Why does this work if there's an animation queue...?
|
||||||
stores.animate({right: -(panelIndex * 700) + 'px'}, 300 * diff);
|
stores.animate({right: -(panelIndex * 700) + 'px'}, 300 * diff);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-14
@@ -19,7 +19,7 @@ var Events = {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Build the Event Pool
|
// Build the Event Pool
|
||||||
Events.EventPool = new Array().concat(
|
Events.EventPool = [].concat(
|
||||||
Events.Global,
|
Events.Global,
|
||||||
Events.Room,
|
Events.Room,
|
||||||
Events.Outside
|
Events.Outside
|
||||||
@@ -35,9 +35,7 @@ var Events = {
|
|||||||
|
|
||||||
options: {}, // Nothing for now
|
options: {}, // Nothing for now
|
||||||
|
|
||||||
activeEvent: null,
|
|
||||||
activeScene: null,
|
activeScene: null,
|
||||||
eventPanel: null,
|
|
||||||
|
|
||||||
loadScene: function(name) {
|
loadScene: function(name) {
|
||||||
Engine.log('loading scene: ' + name);
|
Engine.log('loading scene: ' + name);
|
||||||
@@ -88,7 +86,7 @@ var Events = {
|
|||||||
for(var k in World.Weapons) {
|
for(var k in World.Weapons) {
|
||||||
var weapon = World.Weapons[k];
|
var weapon = World.Weapons[k];
|
||||||
if(typeof Path.outfit[k] == 'number' && Path.outfit[k] > 0) {
|
if(typeof Path.outfit[k] == 'number' && Path.outfit[k] > 0) {
|
||||||
if(typeof weapon.damage != 'number' || weapon.damage == 0) {
|
if(typeof weapon.damage != 'number' || weapon.damage === 0) {
|
||||||
// Weapons that deal no damage don't count
|
// Weapons that deal no damage don't count
|
||||||
numWeapons--;
|
numWeapons--;
|
||||||
} else if(weapon.cost){
|
} else if(weapon.cost){
|
||||||
@@ -104,13 +102,13 @@ var Events = {
|
|||||||
Events.createAttackButton(k).appendTo(btns);
|
Events.createAttackButton(k).appendTo(btns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(numWeapons == 0) {
|
if(numWeapons === 0) {
|
||||||
// No weapons? You can punch stuff!
|
// No weapons? You can punch stuff!
|
||||||
Events.createAttackButton('fists').prependTo(btns);
|
Events.createAttackButton('fists').prependTo(btns);
|
||||||
}
|
}
|
||||||
|
|
||||||
Events.createEatMeatButton().appendTo(btns);
|
Events.createEatMeatButton().appendTo(btns);
|
||||||
if((Path.outfit['medicine'] || 0) != 0) {
|
if((Path.outfit['medicine'] || 0) !== 0) {
|
||||||
Events.createUseMedsButton().appendTo(btns);
|
Events.createUseMedsButton().appendTo(btns);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +129,7 @@ var Events = {
|
|||||||
cost: { 'cured meat': 1 }
|
cost: { 'cured meat': 1 }
|
||||||
});
|
});
|
||||||
|
|
||||||
if(Path.outfit['cured meat'] == 0) {
|
if(Path.outfit['cured meat'] === 0) {
|
||||||
Button.setDisabled(btn, true);
|
Button.setDisabled(btn, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +149,7 @@ var Events = {
|
|||||||
cost: { 'medicine': 1 }
|
cost: { 'medicine': 1 }
|
||||||
});
|
});
|
||||||
|
|
||||||
if((Path.outfit['medicine'] || 0) == 0) {
|
if((Path.outfit['medicine'] || 0) === 0) {
|
||||||
Button.setDisabled(btn, true);
|
Button.setDisabled(btn, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +201,7 @@ var Events = {
|
|||||||
if(Path.outfit['cured meat'] > 0) {
|
if(Path.outfit['cured meat'] > 0) {
|
||||||
Path.outfit['cured meat']--;
|
Path.outfit['cured meat']--;
|
||||||
World.updateSupplies();
|
World.updateSupplies();
|
||||||
if(Path.outfit['cured meat'] == 0) {
|
if(Path.outfit['cured meat'] === 0) {
|
||||||
Button.setDisabled($('#eat'), true);
|
Button.setDisabled($('#eat'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +223,7 @@ var Events = {
|
|||||||
if(Path.outfit['medicine'] > 0) {
|
if(Path.outfit['medicine'] > 0) {
|
||||||
Path.outfit['medicine']--;
|
Path.outfit['medicine']--;
|
||||||
World.updateSupplies();
|
World.updateSupplies();
|
||||||
if(Path.outfit['medicine'] == 0) {
|
if(Path.outfit['medicine'] === 0) {
|
||||||
Button.setDisabled($('#meds'), true);
|
Button.setDisabled($('#meds'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,7 +284,7 @@ var Events = {
|
|||||||
if(!validWeapons) {
|
if(!validWeapons) {
|
||||||
// enable or create the punch button
|
// enable or create the punch button
|
||||||
var fists = $('#attack_fists');
|
var fists = $('#attack_fists');
|
||||||
if(fists.length == 0) {
|
if(fists.length === 0) {
|
||||||
Events.createAttackButton('fists').prependTo('#buttons', Events.eventPanel());
|
Events.createAttackButton('fists').prependTo('#buttons', Events.eventPanel());
|
||||||
} else {
|
} else {
|
||||||
Button.setDisabled(fists, false);
|
Button.setDisabled(fists, false);
|
||||||
@@ -477,7 +475,7 @@ var Events = {
|
|||||||
}).appendTo(btns));
|
}).appendTo(btns));
|
||||||
|
|
||||||
Events.createEatMeatButton(0).appendTo(btns);
|
Events.createEatMeatButton(0).appendTo(btns);
|
||||||
if((Path.outfit['medicine'] || 0) != 0) {
|
if((Path.outfit['medicine'] || 0) !== 0) {
|
||||||
Events.createUseMedsButton(0).appendTo(btns);
|
Events.createUseMedsButton(0).appendTo(btns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -542,7 +540,7 @@ var Events = {
|
|||||||
var num = btn.data('numLeft');
|
var num = btn.data('numLeft');
|
||||||
num--;
|
num--;
|
||||||
btn.data('numLeft', num);
|
btn.data('numLeft', num);
|
||||||
if(num == 0) {
|
if(num === 0) {
|
||||||
Button.setDisabled(btn);
|
Button.setDisabled(btn);
|
||||||
btn.animate({'opacity':0}, 300, 'linear', function() {
|
btn.animate({'opacity':0}, 300, 'linear', function() {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
@@ -764,7 +762,7 @@ var Events = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(possibleEvents.length == 0) {
|
if(possibleEvents.length === 0) {
|
||||||
Events.scheduleNextEvent(0.5);
|
Events.scheduleNextEvent(0.5);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ Events.Outside = [
|
|||||||
{ /* Soldier attack */
|
{ /* Soldier attack */
|
||||||
title: _('A Military Raid'),
|
title: _('A Military Raid'),
|
||||||
isAvailable: function() {
|
isAvailable: function() {
|
||||||
return Engine.activeModule == Outside && $SM.get('game.population', true) > 0 && $SM.get('game.cityCleared');;
|
return Engine.activeModule == Outside && $SM.get('game.population', true) > 0 && $SM.get('game.cityCleared');
|
||||||
},
|
},
|
||||||
scenes: {
|
scenes: {
|
||||||
'start': {
|
'start': {
|
||||||
|
|||||||
@@ -132,9 +132,9 @@ Events.Room = [
|
|||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
var numWood = $SM.get('stores.wood', true);
|
var numWood = $SM.get('stores.wood', true);
|
||||||
numWood = Math.floor(numWood * 0.1);
|
numWood = Math.floor(numWood * 0.1);
|
||||||
if(numWood == 0) numWood = 1;
|
if(numWood === 0) numWood = 1;
|
||||||
var numScales = Math.floor(numWood / 5);
|
var numScales = Math.floor(numWood / 5);
|
||||||
if(numScales == 0) numScales = 1;
|
if(numScales === 0) numScales = 1;
|
||||||
$SM.addM('stores', {'wood': -numWood, 'scales': numScales});
|
$SM.addM('stores', {'wood': -numWood, 'scales': numScales});
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
@@ -152,9 +152,9 @@ Events.Room = [
|
|||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
var numWood = $SM.get('stores.wood', true);
|
var numWood = $SM.get('stores.wood', true);
|
||||||
numWood = Math.floor(numWood * 0.1);
|
numWood = Math.floor(numWood * 0.1);
|
||||||
if(numWood == 0) numWood = 1;
|
if(numWood === 0) numWood = 1;
|
||||||
var numTeeth = Math.floor(numWood / 5);
|
var numTeeth = Math.floor(numWood / 5);
|
||||||
if(numTeeth == 0) numTeeth = 1;
|
if(numTeeth === 0) numTeeth = 1;
|
||||||
$SM.addM('stores', {'wood': -numWood, 'teeth': numTeeth});
|
$SM.addM('stores', {'wood': -numWood, 'teeth': numTeeth});
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
@@ -172,9 +172,9 @@ Events.Room = [
|
|||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
var numWood = $SM.get('stores.wood', true);
|
var numWood = $SM.get('stores.wood', true);
|
||||||
numWood = Math.floor(numWood * 0.1);
|
numWood = Math.floor(numWood * 0.1);
|
||||||
if(numWood == 0) numWood = 1;
|
if(numWood === 0) numWood = 1;
|
||||||
var numCloth = Math.floor(numWood / 5);
|
var numCloth = Math.floor(numWood / 5);
|
||||||
if(numCloth == 0) numCloth = 1;
|
if(numCloth === 0) numCloth = 1;
|
||||||
$SM.addM('stores', {'wood': -numWood, 'cloth': numCloth});
|
$SM.addM('stores', {'wood': -numWood, 'cloth': numCloth});
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ var Notifications = {
|
|||||||
if(module != null && Engine.activeModule != module) {
|
if(module != null && Engine.activeModule != module) {
|
||||||
if(!noQueue) {
|
if(!noQueue) {
|
||||||
if(typeof this.notifyQueue[module] == 'undefined') {
|
if(typeof this.notifyQueue[module] == 'undefined') {
|
||||||
this.notifyQueue[module] = new Array();
|
this.notifyQueue[module] = [];
|
||||||
}
|
}
|
||||||
this.notifyQueue[module].push(text);
|
this.notifyQueue[module].push(text);
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-19
@@ -178,7 +178,7 @@ var Outside = {
|
|||||||
var space = Outside.getMaxPopulation() - $SM.get('game.population');
|
var space = Outside.getMaxPopulation() - $SM.get('game.population');
|
||||||
if(space > 0) {
|
if(space > 0) {
|
||||||
var num = Math.floor(Math.random()*(space/2) + space/2);
|
var num = Math.floor(Math.random()*(space/2) + space/2);
|
||||||
if(num == 0) num = 1;
|
if(num === 0) num = 1;
|
||||||
if(num == 1) {
|
if(num == 1) {
|
||||||
Notifications.notify(null, _('a stranger arrives in the night'));
|
Notifications.notify(null, _('a stranger arrives in the night'));
|
||||||
} else if(num < 5) {
|
} else if(num < 5) {
|
||||||
@@ -205,9 +205,9 @@ var Outside = {
|
|||||||
if(remaining < 0) {
|
if(remaining < 0) {
|
||||||
var gap = -remaining;
|
var gap = -remaining;
|
||||||
for(var k in $SM.get('game.workers')) {
|
for(var k in $SM.get('game.workers')) {
|
||||||
var num = $SM.get('game.workers["'+k+'"]');
|
var numWorkers = $SM.get('game.workers["'+k+'"]');
|
||||||
if(num < gap) {
|
if(numWorkers < gap) {
|
||||||
gap -= num;
|
gap -= numWorkers;
|
||||||
$SM.set('game.workers["'+k+'"]', 0);
|
$SM.set('game.workers["'+k+'"]', 0);
|
||||||
} else {
|
} else {
|
||||||
$SM.add('game.workers["'+k+'"]', gap * -1);
|
$SM.add('game.workers["'+k+'"]', gap * -1);
|
||||||
@@ -228,10 +228,10 @@ var Outside = {
|
|||||||
|
|
||||||
// If our population is 0 and we don't already have a workers view,
|
// If our population is 0 and we don't already have a workers view,
|
||||||
// there's nothing to do here.
|
// there's nothing to do here.
|
||||||
if(!workers.length && $SM.get('game.population') == 0) return;
|
if(!workers.length && $SM.get('game.population') === 0) return;
|
||||||
|
|
||||||
var needsAppend = false;
|
var needsAppend = false;
|
||||||
if(workers.length == 0) {
|
if(workers.length === 0) {
|
||||||
needsAppend = true;
|
needsAppend = true;
|
||||||
workers = $('<div>').attr('id', 'workers').css('opacity', 0);
|
workers = $('<div>').attr('id', 'workers').css('opacity', 0);
|
||||||
}
|
}
|
||||||
@@ -242,7 +242,7 @@ var Outside = {
|
|||||||
for(var k in $SM.get('game.workers')) {
|
for(var k in $SM.get('game.workers')) {
|
||||||
var workerCount = $SM.get('game.workers["'+k+'"]');
|
var workerCount = $SM.get('game.workers["'+k+'"]');
|
||||||
var row = $('div#workers_row_' + k.replace(' ', '-'), workers);
|
var row = $('div#workers_row_' + k.replace(' ', '-'), workers);
|
||||||
if(row.length == 0) {
|
if(row.length === 0) {
|
||||||
row = Outside.makeWorkerRow(k, workerCount);
|
row = Outside.makeWorkerRow(k, workerCount);
|
||||||
|
|
||||||
var curPrev = null;
|
var curPrev = null;
|
||||||
@@ -255,7 +255,7 @@ var Outside = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(curPrev == null && gatherer.length == 0) {
|
if(curPrev == null && gatherer.length === 0) {
|
||||||
row.prependTo(workers);
|
row.prependTo(workers);
|
||||||
}
|
}
|
||||||
else if(curPrev == null)
|
else if(curPrev == null)
|
||||||
@@ -271,7 +271,7 @@ var Outside = {
|
|||||||
$('div#' + row.attr('id') + ' > div.row_val > span', workers).text(workerCount);
|
$('div#' + row.attr('id') + ' > div.row_val > span', workers).text(workerCount);
|
||||||
}
|
}
|
||||||
numGatherers -= workerCount;
|
numGatherers -= workerCount;
|
||||||
if(workerCount == 0) {
|
if(workerCount === 0) {
|
||||||
$('.dnBtn', row).addClass('disabled');
|
$('.dnBtn', row).addClass('disabled');
|
||||||
$('.dnManyBtn', row).addClass('disabled');
|
$('.dnManyBtn', row).addClass('disabled');
|
||||||
} else {
|
} else {
|
||||||
@@ -280,14 +280,14 @@ var Outside = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gatherer.length == 0) {
|
if(gatherer.length === 0) {
|
||||||
gatherer = Outside.makeWorkerRow('gatherer', numGatherers);
|
gatherer = Outside.makeWorkerRow('gatherer', numGatherers);
|
||||||
gatherer.prependTo(workers);
|
gatherer.prependTo(workers);
|
||||||
} else {
|
} else {
|
||||||
$('div#workers_row_gatherer > div.row_val > span', workers).text(numGatherers);
|
$('div#workers_row_gatherer > div.row_val > span', workers).text(numGatherers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(numGatherers == 0) {
|
if(numGatherers === 0) {
|
||||||
$('.upBtn', '#workers').addClass('disabled');
|
$('.upBtn', '#workers').addClass('disabled');
|
||||||
$('.upManyBtn', '#workers').addClass('disabled');
|
$('.upManyBtn', '#workers').addClass('disabled');
|
||||||
} else {
|
} else {
|
||||||
@@ -363,7 +363,7 @@ var Outside = {
|
|||||||
updateVillageRow: function(name, num, village) {
|
updateVillageRow: function(name, num, village) {
|
||||||
var id = 'building_row_' + name.replace(' ', '-');
|
var id = 'building_row_' + name.replace(' ', '-');
|
||||||
var row = $('div#' + id, village);
|
var row = $('div#' + id, village);
|
||||||
if(row.length == 0 && num > 0) {
|
if(row.length === 0 && num > 0) {
|
||||||
row = $('<div>').attr('id', id).addClass('storeRow');
|
row = $('<div>').attr('id', id).addClass('storeRow');
|
||||||
$('<div>').addClass('row_key').text(_(name)).appendTo(row);
|
$('<div>').addClass('row_key').text(_(name)).appendTo(row);
|
||||||
$('<div>').addClass('row_val').text(num).appendTo(row);
|
$('<div>').addClass('row_val').text(num).appendTo(row);
|
||||||
@@ -385,7 +385,7 @@ var Outside = {
|
|||||||
}
|
}
|
||||||
} else if(num > 0) {
|
} else if(num > 0) {
|
||||||
$('div#' + row.attr('id') + ' > div.row_val', village).text(num);
|
$('div#' + row.attr('id') + ' > div.row_val', village).text(num);
|
||||||
} else if(num == 0) {
|
} else if(num === 0) {
|
||||||
row.remove();
|
row.remove();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -394,7 +394,7 @@ var Outside = {
|
|||||||
var village = $('div#village');
|
var village = $('div#village');
|
||||||
var population = $('div#population');
|
var population = $('div#population');
|
||||||
var needsAppend = false;
|
var needsAppend = false;
|
||||||
if(village.length == 0) {
|
if(village.length === 0) {
|
||||||
needsAppend = true;
|
needsAppend = true;
|
||||||
village = $('<div>').attr('id', 'village').css('opacity', 0);
|
village = $('<div>').attr('id', 'village').css('opacity', 0);
|
||||||
population = $('<div>').attr('id', 'population').appendTo(village);
|
population = $('<div>').attr('id', 'population').appendTo(village);
|
||||||
@@ -419,7 +419,7 @@ var Outside = {
|
|||||||
population.text(_('pop ') + $SM.get('game.population') + '/' + this.getMaxPopulation());
|
population.text(_('pop ') + $SM.get('game.population') + '/' + this.getMaxPopulation());
|
||||||
|
|
||||||
var hasPeeps;
|
var hasPeeps;
|
||||||
if($SM.get('game.buildings["hut"]', true) == 0) {
|
if($SM.get('game.buildings["hut"]', true) === 0) {
|
||||||
hasPeeps = false;
|
hasPeeps = false;
|
||||||
village.addClass('noHuts');
|
village.addClass('noHuts');
|
||||||
} else {
|
} else {
|
||||||
@@ -504,7 +504,7 @@ var Outside = {
|
|||||||
updateTrapButton: function() {
|
updateTrapButton: function() {
|
||||||
var btn = $('div#trapsButton');
|
var btn = $('div#trapsButton');
|
||||||
if($SM.get('game.buildings["trap"]', true) > 0) {
|
if($SM.get('game.buildings["trap"]', true) > 0) {
|
||||||
if(btn.length == 0) {
|
if(btn.length === 0) {
|
||||||
new Button.Button({
|
new Button.Button({
|
||||||
id: 'trapsButton',
|
id: 'trapsButton',
|
||||||
text: _("check traps"),
|
text: _("check traps"),
|
||||||
@@ -525,7 +525,7 @@ var Outside = {
|
|||||||
setTitle: function() {
|
setTitle: function() {
|
||||||
var numHuts = $SM.get('game.buildings["hut"]', true);
|
var numHuts = $SM.get('game.buildings["hut"]', true);
|
||||||
var title;
|
var title;
|
||||||
if(numHuts == 0) {
|
if(numHuts === 0) {
|
||||||
title = _("A Silent Forest");
|
title = _("A Silent Forest");
|
||||||
} else if(numHuts == 1) {
|
} else if(numHuts == 1) {
|
||||||
title = _("A Lonely Hut");
|
title = _("A Lonely Hut");
|
||||||
@@ -606,10 +606,10 @@ var Outside = {
|
|||||||
handleStateUpdates: function(e){
|
handleStateUpdates: function(e){
|
||||||
if(e.category == 'stores'){
|
if(e.category == 'stores'){
|
||||||
Outside.updateVillage();
|
Outside.updateVillage();
|
||||||
} else if(e.stateName.indexOf('game.workers') == 0 || e.stateName.indexOf('game.population') == 0){
|
} else if(e.stateName.indexOf('game.workers') === 0 || e.stateName.indexOf('game.population') === 0){
|
||||||
Outside.updateVillage();
|
Outside.updateVillage();
|
||||||
Outside.updateWorkersView();
|
Outside.updateWorkersView();
|
||||||
Outside.updateVillageIncome();
|
Outside.updateVillageIncome();
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+12
-12
@@ -97,14 +97,14 @@ var Path = {
|
|||||||
if($SM.get('character.perks')) {
|
if($SM.get('character.perks')) {
|
||||||
var perks = $('#perks');
|
var perks = $('#perks');
|
||||||
var needsAppend = false;
|
var needsAppend = false;
|
||||||
if(perks.length == 0) {
|
if(perks.length === 0) {
|
||||||
needsAppend = true;
|
needsAppend = true;
|
||||||
perks = $('<div>').attr('id', 'perks');
|
perks = $('<div>').attr('id', 'perks');
|
||||||
}
|
}
|
||||||
for(var k in $SM.get('character.perks')) {
|
for(var k in $SM.get('character.perks')) {
|
||||||
var id = 'perk_' + k.replace(' ', '-');
|
var id = 'perk_' + k.replace(' ', '-');
|
||||||
var r = $('#' + id);
|
var r = $('#' + id);
|
||||||
if($SM.get('character.perks["'+k+'"]') && r.length == 0) {
|
if($SM.get('character.perks["'+k+'"]') && r.length === 0) {
|
||||||
r = $('<div>').attr('id', id).addClass('perkRow').appendTo(perks);
|
r = $('<div>').attr('id', id).addClass('perkRow').appendTo(perks);
|
||||||
$('<div>').addClass('row_key').text(_(k)).appendTo(r);
|
$('<div>').addClass('row_key').text(_(k)).appendTo(r);
|
||||||
$('<div>').addClass('tooltip bottom right').text(Engine.Perks[k].desc).appendTo(r);
|
$('<div>').addClass('tooltip bottom right').text(Engine.Perks[k].desc).appendTo(r);
|
||||||
@@ -137,7 +137,7 @@ var Path = {
|
|||||||
else if($SM.get('stores["l armour"]', true) > 0)
|
else if($SM.get('stores["l armour"]', true) > 0)
|
||||||
armour = _("leather");
|
armour = _("leather");
|
||||||
var aRow = $('#armourRow');
|
var aRow = $('#armourRow');
|
||||||
if(aRow.length == 0) {
|
if(aRow.length === 0) {
|
||||||
aRow = $('<div>').attr('id', 'armourRow').addClass('outfitRow').prependTo(outfit);
|
aRow = $('<div>').attr('id', 'armourRow').addClass('outfitRow').prependTo(outfit);
|
||||||
$('<div>').addClass('row_key').text(_('armour')).appendTo(aRow);
|
$('<div>').addClass('row_key').text(_('armour')).appendTo(aRow);
|
||||||
$('<div>').addClass('row_val').text(armour).appendTo(aRow);
|
$('<div>').addClass('row_val').text(armour).appendTo(aRow);
|
||||||
@@ -148,7 +148,7 @@ var Path = {
|
|||||||
|
|
||||||
// Add the water row
|
// Add the water row
|
||||||
var wRow = $('#waterRow');
|
var wRow = $('#waterRow');
|
||||||
if(wRow.length == 0) {
|
if(wRow.length === 0) {
|
||||||
wRow = $('<div>').attr('id', 'waterRow').addClass('outfitRow').insertAfter(aRow);
|
wRow = $('<div>').attr('id', 'waterRow').addClass('outfitRow').insertAfter(aRow);
|
||||||
$('<div>').addClass('row_key').text(_('water')).appendTo(wRow);
|
$('<div>').addClass('row_key').text(_('water')).appendTo(wRow);
|
||||||
$('<div>').addClass('row_val').text(World.getMaxWater()).appendTo(wRow);
|
$('<div>').addClass('row_val').text(World.getMaxWater()).appendTo(wRow);
|
||||||
@@ -183,13 +183,13 @@ var Path = {
|
|||||||
var row = $('div#outfit_row_' + k.replace(' ', '-'), outfit);
|
var row = $('div#outfit_row_' + k.replace(' ', '-'), outfit);
|
||||||
if((store.type == 'tool' || store.type == 'weapon') && have > 0) {
|
if((store.type == 'tool' || store.type == 'weapon') && have > 0) {
|
||||||
total += num * Path.getWeight(k);
|
total += num * Path.getWeight(k);
|
||||||
if(row.length == 0) {
|
if(row.length === 0) {
|
||||||
row = Path.createOutfittingRow(k, num, store.name);
|
row = Path.createOutfittingRow(k, num, store.name);
|
||||||
|
|
||||||
var curPrev = null;
|
var curPrev = null;
|
||||||
outfit.children().each(function(i) {
|
outfit.children().each(function(i) {
|
||||||
var child = $(this);
|
var child = $(this);
|
||||||
if(child.attr('id').indexOf('outfit_row_') == 0) {
|
if(child.attr('id').indexOf('outfit_row_') === 0) {
|
||||||
var cName = child.attr('id').substring(11).replace('-', ' ');
|
var cName = child.attr('id').substring(11).replace('-', ' ');
|
||||||
if(cName < k && (curPrev == null || cName > curPrev)) {
|
if(cName < k && (curPrev == null || cName > curPrev)) {
|
||||||
curPrev = cName;
|
curPrev = cName;
|
||||||
@@ -207,7 +207,7 @@ var Path = {
|
|||||||
$('div#' + row.attr('id') + ' > div.row_val > span', outfit).text(num);
|
$('div#' + row.attr('id') + ' > div.row_val > span', outfit).text(num);
|
||||||
$('div#' + row.attr('id') + ' .tooltip .numAvailable', outfit).text(numAvailable - num);
|
$('div#' + row.attr('id') + ' .tooltip .numAvailable', outfit).text(numAvailable - num);
|
||||||
}
|
}
|
||||||
if(num == 0) {
|
if(num === 0) {
|
||||||
$('.dnBtn', row).addClass('disabled');
|
$('.dnBtn', row).addClass('disabled');
|
||||||
$('.dnManyBtn', row).addClass('disabled');
|
$('.dnManyBtn', row).addClass('disabled');
|
||||||
} else {
|
} else {
|
||||||
@@ -221,7 +221,7 @@ var Path = {
|
|||||||
$('.upBtn', row).removeClass('disabled');
|
$('.upBtn', row).removeClass('disabled');
|
||||||
$('.upManyBtn', row).removeClass('disabled');
|
$('.upManyBtn', row).removeClass('disabled');
|
||||||
}
|
}
|
||||||
} else if(have == 0 && row.length > 0) {
|
} else if(have === 0 && row.length > 0) {
|
||||||
row.remove();
|
row.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,7 +269,7 @@ var Path = {
|
|||||||
var maxExtraByStore = $SM.get('stores["'+supply+'"]', true) - cur;
|
var maxExtraByStore = $SM.get('stores["'+supply+'"]', true) - cur;
|
||||||
var maxExtraByBtn = btn.data;
|
var maxExtraByBtn = btn.data;
|
||||||
Path.outfit[supply] = cur + Math.min(maxExtraByBtn, Math.min(maxExtraByWeight, maxExtraByStore));
|
Path.outfit[supply] = cur + Math.min(maxExtraByBtn, Math.min(maxExtraByWeight, maxExtraByStore));
|
||||||
$SM.set('outfit['+supply+']', Path.outfit[supply])
|
$SM.set('outfit['+supply+']', Path.outfit[supply]);
|
||||||
Path.updateOutfitting();
|
Path.updateOutfitting();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -281,7 +281,7 @@ var Path = {
|
|||||||
cur = typeof cur == 'number' ? cur : 0;
|
cur = typeof cur == 'number' ? cur : 0;
|
||||||
if(cur > 0) {
|
if(cur > 0) {
|
||||||
Path.outfit[supply] = Math.max(0, cur - btn.data);
|
Path.outfit[supply] = Math.max(0, cur - btn.data);
|
||||||
$SM.set('outfit['+supply+']', Path.outfit[supply])
|
$SM.set('outfit['+supply+']', Path.outfit[supply]);
|
||||||
Path.updateOutfitting();
|
Path.updateOutfitting();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -310,8 +310,8 @@ var Path = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleStateUpdates: function(e){
|
handleStateUpdates: function(e){
|
||||||
if(e.category == 'character' && e.stateName.indexOf('character.perks') == 0 && Engine.activeModule == Path){
|
if(e.category == 'character' && e.stateName.indexOf('character.perks') === 0 && Engine.activeModule == Path){
|
||||||
Path.updatePerks();
|
Path.updatePerks();
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+13
-13
@@ -476,8 +476,8 @@ var Room = {
|
|||||||
|
|
||||||
// If this is the first time playing, the fire is dead and it's freezing.
|
// If this is the first time playing, the fire is dead and it's freezing.
|
||||||
// Otherwise grab past save state temp and fire level.
|
// Otherwise grab past save state temp and fire level.
|
||||||
$SM.set('game.temperature', $SM.get('game.temperature.value')==undefined?this.TempEnum.Freezing:$SM.get('game.temperature'));
|
$SM.set('game.temperature', $SM.get('game.temperature.value')===undefined?this.TempEnum.Freezing:$SM.get('game.temperature'));
|
||||||
$SM.set('game.fire', $SM.get('game.fire.value')==undefined?this.FireEnum.Dead:$SM.get('game.fire'));
|
$SM.set('game.fire', $SM.get('game.fire.value')===undefined?this.FireEnum.Dead:$SM.get('game.fire'));
|
||||||
|
|
||||||
// Create the room tab
|
// Create the room tab
|
||||||
this.tab = Header.addLocation(_("A Dark Room"), "room", Room);
|
this.tab = Header.addLocation(_("A Dark Room"), "room", Room);
|
||||||
@@ -720,7 +720,7 @@ var Room = {
|
|||||||
|
|
||||||
updateBuilderState: function() {
|
updateBuilderState: function() {
|
||||||
var lBuilder = $SM.get('game.builder.level');
|
var lBuilder = $SM.get('game.builder.level');
|
||||||
if(lBuilder == 0) {
|
if(lBuilder === 0) {
|
||||||
Notifications.notify(Room, _("a ragged stranger stumbles through the door and collapses in the corner"));
|
Notifications.notify(Room, _("a ragged stranger stumbles through the door and collapses in the corner"));
|
||||||
lBuilder = $SM.setget('game.builder.level', 1);
|
lBuilder = $SM.setget('game.builder.level', 1);
|
||||||
setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
|
setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
|
||||||
@@ -750,13 +750,13 @@ var Room = {
|
|||||||
var stores = $('div#stores');
|
var stores = $('div#stores');
|
||||||
var weapons = $('div#weapons');
|
var weapons = $('div#weapons');
|
||||||
var needsAppend = false, wNeedsAppend = false, newRow = false;
|
var needsAppend = false, wNeedsAppend = false, newRow = false;
|
||||||
if(stores.length == 0) {
|
if(stores.length === 0) {
|
||||||
stores = $('<div>').attr({
|
stores = $('<div>').attr({
|
||||||
id: 'stores'
|
id: 'stores'
|
||||||
}).css('opacity', 0);
|
}).css('opacity', 0);
|
||||||
needsAppend = true;
|
needsAppend = true;
|
||||||
}
|
}
|
||||||
if(weapons.length == 0) {
|
if(weapons.length === 0) {
|
||||||
weapons = $('<div>').attr({
|
weapons = $('<div>').attr({
|
||||||
id: 'weapons'
|
id: 'weapons'
|
||||||
}).css('opacity', 0);
|
}).css('opacity', 0);
|
||||||
@@ -803,7 +803,7 @@ var Room = {
|
|||||||
$SM.startThieves();
|
$SM.startThieves();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(row.length == 0 && num > 0) {
|
if(row.length === 0 && num > 0) {
|
||||||
row = $('<div>').attr('id', id).addClass('storeRow');
|
row = $('<div>').attr('id', id).addClass('storeRow');
|
||||||
$('<div>').addClass('row_key').text(_(k)).appendTo(row);
|
$('<div>').addClass('row_key').text(_(k)).appendTo(row);
|
||||||
$('<div>').addClass('row_val').text(Math.floor(num)).appendTo(row);
|
$('<div>').addClass('row_val').text(Math.floor(num)).appendTo(row);
|
||||||
@@ -848,7 +848,7 @@ var Room = {
|
|||||||
|
|
||||||
updateIncomeView: function() {
|
updateIncomeView: function() {
|
||||||
var stores = $('div#stores');
|
var stores = $('div#stores');
|
||||||
if(stores.length == 0 || typeof $SM.get('income') == 'undefined') return;
|
if(stores.length === 0 || typeof $SM.get('income') == 'undefined') return;
|
||||||
$('div.storeRow', stores).each(function(index, el) {
|
$('div.storeRow', stores).each(function(index, el) {
|
||||||
el = $(el);
|
el = $(el);
|
||||||
$('div.tooltip', el).remove();
|
$('div.tooltip', el).remove();
|
||||||
@@ -857,7 +857,7 @@ var Room = {
|
|||||||
for(var incomeSource in $SM.get('income')) {
|
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) {
|
for(var store in income.stores) {
|
||||||
if(store == storeName && income.stores[store] != 0) {
|
if(store == storeName && income.stores[store] !== 0) {
|
||||||
$('<div>').addClass('row_key').text(_(incomeSource)).appendTo(tt);
|
$('<div>').addClass('row_key').text(_(incomeSource)).appendTo(tt);
|
||||||
$('<div>')
|
$('<div>')
|
||||||
.addClass('row_val')
|
.addClass('row_val')
|
||||||
@@ -967,7 +967,7 @@ var Room = {
|
|||||||
}
|
}
|
||||||
if($SM.get('game.builder.level') < 4) return false;
|
if($SM.get('game.builder.level') < 4) return false;
|
||||||
var craftable = Room.Craftables[thing];
|
var craftable = Room.Craftables[thing];
|
||||||
if(Room.needsWorkshop(craftable.type) && $SM.get('game.buildings["'+'workshop'+'"]', true) == 0) return false;
|
if(Room.needsWorkshop(craftable.type) && $SM.get('game.buildings["'+'workshop'+'"]', true) === 0) return false;
|
||||||
var cost = craftable.cost();
|
var cost = craftable.cost();
|
||||||
|
|
||||||
//show button if one has already been built
|
//show button if one has already been built
|
||||||
@@ -1008,21 +1008,21 @@ var Room = {
|
|||||||
updateBuildButtons: function() {
|
updateBuildButtons: function() {
|
||||||
var buildSection = $('#buildBtns');
|
var buildSection = $('#buildBtns');
|
||||||
var needsAppend = false;
|
var needsAppend = false;
|
||||||
if(buildSection.length == 0) {
|
if(buildSection.length === 0) {
|
||||||
buildSection = $('<div>').attr('id', 'buildBtns').css('opacity', 0);
|
buildSection = $('<div>').attr('id', 'buildBtns').css('opacity', 0);
|
||||||
needsAppend = true;
|
needsAppend = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var craftSection = $('#craftBtns');
|
var craftSection = $('#craftBtns');
|
||||||
var cNeedsAppend = false;
|
var cNeedsAppend = false;
|
||||||
if(craftSection.length == 0 && $SM.get('game.buildings["workshop"]', true) > 0) {
|
if(craftSection.length === 0 && $SM.get('game.buildings["workshop"]', true) > 0) {
|
||||||
craftSection = $('<div>').attr('id', 'craftBtns').css('opacity', 0);
|
craftSection = $('<div>').attr('id', 'craftBtns').css('opacity', 0);
|
||||||
cNeedsAppend = true;
|
cNeedsAppend = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var buySection = $('#buyBtns');
|
var buySection = $('#buyBtns');
|
||||||
var bNeedsAppend = false;
|
var bNeedsAppend = false;
|
||||||
if(buySection.length == 0 && $SM.get('game.buildings["trading post"]', true) > 0) {
|
if(buySection.length === 0 && $SM.get('game.buildings["trading post"]', true) > 0) {
|
||||||
buySection = $('<div>').attr('id', 'buyBtns').css('opacity', 0);
|
buySection = $('<div>').attr('id', 'buyBtns').css('opacity', 0);
|
||||||
bNeedsAppend = true;
|
bNeedsAppend = true;
|
||||||
}
|
}
|
||||||
@@ -1113,7 +1113,7 @@ var Room = {
|
|||||||
} else if(e.category == 'income'){
|
} else if(e.category == 'income'){
|
||||||
Room.updateStoresView();
|
Room.updateStoresView();
|
||||||
Room.updateIncomeView();
|
Room.updateIncomeView();
|
||||||
} else if(e.stateName.indexOf('game.buildings') == 0){
|
} else if(e.stateName.indexOf('game.buildings') === 0){
|
||||||
Room.updateBuildButtons();
|
Room.updateBuildButtons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-11
@@ -136,7 +136,7 @@ var Space = {
|
|||||||
t.remove();
|
t.remove();
|
||||||
Space.hull--;
|
Space.hull--;
|
||||||
Space.updateHull();
|
Space.updateHull();
|
||||||
if(Space.hull == 0) {
|
if(Space.hull === 0) {
|
||||||
Space.crash();
|
Space.crash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ var Space = {
|
|||||||
dx += Space.getSpeed();
|
dx += Space.getSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dx != 0 && dy != 0) {
|
if(dx !== 0 && dy !== 0) {
|
||||||
dx = dx / Math.sqrt(2);
|
dx = dx / Math.sqrt(2);
|
||||||
dy = dy / Math.sqrt(2);
|
dy = dy / Math.sqrt(2);
|
||||||
}
|
}
|
||||||
@@ -226,13 +226,15 @@ var Space = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
startAscent: function() {
|
startAscent: function() {
|
||||||
|
var body_color;
|
||||||
|
var to_color;
|
||||||
if (Engine.isLightsOff()) {
|
if (Engine.isLightsOff()) {
|
||||||
var body_color = '#272823';
|
body_color = '#272823';
|
||||||
var to_color = '#EEEEEE';
|
to_color = '#EEEEEE';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var body_color = '#FFFFFF';
|
body_color = '#FFFFFF';
|
||||||
var to_color = '#000000';
|
to_color = '#000000';
|
||||||
}
|
}
|
||||||
|
|
||||||
$('body').addClass('noMask').css({backgroundColor: body_color}).animate({
|
$('body').addClass('noMask').css({backgroundColor: body_color}).animate({
|
||||||
@@ -251,7 +253,7 @@ var Space = {
|
|||||||
Space.drawStars();
|
Space.drawStars();
|
||||||
Space._timer = setInterval(function() {
|
Space._timer = setInterval(function() {
|
||||||
Space.altitude += 1;
|
Space.altitude += 1;
|
||||||
if(Space.altitude % 10 == 0) {
|
if(Space.altitude % 10 === 0) {
|
||||||
Space.setTitle();
|
Space.setTitle();
|
||||||
}
|
}
|
||||||
if(Space.altitude > 60) {
|
if(Space.altitude > 60) {
|
||||||
@@ -324,10 +326,11 @@ var Space = {
|
|||||||
clearInterval(Space._timer);
|
clearInterval(Space._timer);
|
||||||
clearInterval(Space._shipTimer);
|
clearInterval(Space._shipTimer);
|
||||||
clearTimeout(Space._panelTimeout);
|
clearTimeout(Space._panelTimeout);
|
||||||
|
var body_color;
|
||||||
if (Engine.isLightsOff())
|
if (Engine.isLightsOff())
|
||||||
var body_color = '#272823';
|
body_color = '#272823';
|
||||||
else
|
else
|
||||||
var body_color = '#FFFFFF';
|
body_color = '#FFFFFF';
|
||||||
// Craaaaash!
|
// Craaaaash!
|
||||||
$('body').removeClass('noMask').stop().animate({
|
$('body').removeClass('noMask').stop().animate({
|
||||||
backgroundColor: body_color
|
backgroundColor: body_color
|
||||||
@@ -392,10 +395,11 @@ var Space = {
|
|||||||
$('#header').empty();
|
$('#header').empty();
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('body').stop();
|
$('body').stop();
|
||||||
|
var container_color;
|
||||||
if (Engine.isLightsOff())
|
if (Engine.isLightsOff())
|
||||||
var container_color = '#EEE';
|
container_color = '#EEE';
|
||||||
else
|
else
|
||||||
var container_color = '#000';
|
container_color = '#000';
|
||||||
$('#starsContainer').animate({
|
$('#starsContainer').animate({
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
'background-color': container_color
|
'background-color': container_color
|
||||||
|
|||||||
+21
-21
@@ -41,7 +41,7 @@ var StateManager = {
|
|||||||
|
|
||||||
for(var which in cats) {
|
for(var which in cats) {
|
||||||
if(!$SM.get(cats[which])) $SM.set(cats[which], {});
|
if(!$SM.get(cats[which])) $SM.set(cats[which], {});
|
||||||
};
|
}
|
||||||
|
|
||||||
//subscribe to stateUpdates
|
//subscribe to stateUpdates
|
||||||
$.Dispatch('stateUpdate').subscribe($SM.handleStateUpdates);
|
$.Dispatch('stateUpdate').subscribe($SM.handleStateUpdates);
|
||||||
@@ -52,11 +52,11 @@ var StateManager = {
|
|||||||
var words = stateName.split(/[.\[\]'"]+/);
|
var words = stateName.split(/[.\[\]'"]+/);
|
||||||
//for some reason there are sometimes empty strings
|
//for some reason there are sometimes empty strings
|
||||||
for (var i = 0; i < words.length; i++) {
|
for (var i = 0; i < words.length; i++) {
|
||||||
if (words[i] == '') {
|
if (words[i] === '') {
|
||||||
words.splice(i, 1);
|
words.splice(i, 1);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
var obj = State;
|
var obj = State;
|
||||||
var w = null;
|
var w = null;
|
||||||
for(var i=0, len=words.length-1;i<len;i++){
|
for(var i=0, len=words.length-1;i<len;i++){
|
||||||
@@ -84,7 +84,7 @@ var StateManager = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//stores values can not be negative
|
//stores values can not be negative
|
||||||
if(stateName.indexOf('stores') == 0 && $SM.get(stateName, true) < 0) {
|
if(stateName.indexOf('stores') === 0 && $SM.get(stateName, true) < 0) {
|
||||||
eval('('+fullPath+') = 0');
|
eval('('+fullPath+') = 0');
|
||||||
Engine.log('WARNING: state:' + stateName + ' can not be a negative value. Set to 0 instead.');
|
Engine.log('WARNING: state:' + stateName + ' can not be a negative value. Set to 0 instead.');
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ var StateManager = {
|
|||||||
$SM.buildPath(parentName);
|
$SM.buildPath(parentName);
|
||||||
|
|
||||||
//make sure the state exists to avoid errors,
|
//make sure the state exists to avoid errors,
|
||||||
if($SM.get(parentName) == undefined) $SM.set(parentName, {}, true);
|
if($SM.get(parentName) === undefined) $SM.set(parentName, {}, true);
|
||||||
|
|
||||||
for(var k in list){
|
for(var k in list){
|
||||||
$SM.set(parentName+'["'+k+'"]', list[k], true);
|
$SM.set(parentName+'["'+k+'"]', list[k], true);
|
||||||
@@ -140,7 +140,7 @@ var StateManager = {
|
|||||||
var err = 0;
|
var err = 0;
|
||||||
|
|
||||||
//make sure the parent exists to avoid errors
|
//make sure the parent exists to avoid errors
|
||||||
if($SM.get(parentName) == undefined) $SM.set(parentName, {}, true);
|
if($SM.get(parentName) === undefined) $SM.set(parentName, {}, true);
|
||||||
|
|
||||||
for(var k in list){
|
for(var k in list){
|
||||||
if($SM.add(parentName+'["'+k+'"]', list[k], true)) err++;
|
if($SM.add(parentName+'["'+k+'"]', list[k], true)) err++;
|
||||||
@@ -188,7 +188,7 @@ var StateManager = {
|
|||||||
if(!noEvent){
|
if(!noEvent){
|
||||||
Engine.saveGame();
|
Engine.saveGame();
|
||||||
$SM.fireUpdate(stateName);
|
$SM.fireUpdate(stateName);
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//creates full reference from input
|
//creates full reference from input
|
||||||
@@ -231,7 +231,7 @@ var StateManager = {
|
|||||||
$SM.remove('income.hunter', true);
|
$SM.remove('income.hunter', true);
|
||||||
Engine.log('upgraded save to v1.1');
|
Engine.log('upgraded save to v1.1');
|
||||||
version = 1.1;
|
version = 1.1;
|
||||||
};
|
}
|
||||||
if(version == 1.1) {
|
if(version == 1.1) {
|
||||||
//v1.2 added the Swamp to the map, so add it to already generated maps
|
//v1.2 added the Swamp to the map, so add it to already generated maps
|
||||||
if($SM.get('world')) {
|
if($SM.get('world')) {
|
||||||
@@ -239,7 +239,7 @@ var StateManager = {
|
|||||||
}
|
}
|
||||||
Engine.log('upgraded save to v1.2');
|
Engine.log('upgraded save to v1.2');
|
||||||
version = 1.2;
|
version = 1.2;
|
||||||
};
|
}
|
||||||
if(version == 1.2) {
|
if(version == 1.2) {
|
||||||
//StateManager added, so move data to new locations
|
//StateManager added, so move data to new locations
|
||||||
$SM.remove('room.fire');
|
$SM.remove('room.fire');
|
||||||
@@ -249,7 +249,7 @@ var StateManager = {
|
|||||||
$SM.set('features.location.room', true);
|
$SM.set('features.location.room', true);
|
||||||
$SM.set('game.builder.level', $SM.get('room.builder'));
|
$SM.set('game.builder.level', $SM.get('room.builder'));
|
||||||
$SM.remove('room');
|
$SM.remove('room');
|
||||||
};
|
}
|
||||||
if($SM.get('outside')){
|
if($SM.get('outside')){
|
||||||
$SM.set('features.location.outside', true);
|
$SM.set('features.location.outside', true);
|
||||||
$SM.set('game.population', $SM.get('outside.population'));
|
$SM.set('game.population', $SM.get('outside.population'));
|
||||||
@@ -257,7 +257,7 @@ var StateManager = {
|
|||||||
$SM.set('game.workers', $SM.get('outside.workers'));
|
$SM.set('game.workers', $SM.get('outside.workers'));
|
||||||
$SM.set('game.outside.seenForest', $SM.get('outside.seenForest'));
|
$SM.set('game.outside.seenForest', $SM.get('outside.seenForest'));
|
||||||
$SM.remove('outside');
|
$SM.remove('outside');
|
||||||
};
|
}
|
||||||
if($SM.get('world')){
|
if($SM.get('world')){
|
||||||
$SM.set('features.location.world', true);
|
$SM.set('features.location.world', true);
|
||||||
$SM.set('game.world.map', $SM.get('world.map'));
|
$SM.set('game.world.map', $SM.get('world.map'));
|
||||||
@@ -267,7 +267,7 @@ var StateManager = {
|
|||||||
$SM.remove('world');
|
$SM.remove('world');
|
||||||
$SM.remove('starved');
|
$SM.remove('starved');
|
||||||
$SM.remove('dehydrated');
|
$SM.remove('dehydrated');
|
||||||
};
|
}
|
||||||
if($SM.get('ship')){
|
if($SM.get('ship')){
|
||||||
$SM.set('features.location.spaceShip', true);
|
$SM.set('features.location.spaceShip', true);
|
||||||
$SM.set('game.spaceShip.hull', $SM.get('ship.hull', true));
|
$SM.set('game.spaceShip.hull', $SM.get('ship.hull', true));
|
||||||
@@ -275,29 +275,29 @@ var StateManager = {
|
|||||||
$SM.set('game.spaceShip.seenWarning', $SM.get('ship.seenWarning'));
|
$SM.set('game.spaceShip.seenWarning', $SM.get('ship.seenWarning'));
|
||||||
$SM.set('game.spaceShip.seenShip', $SM.get('ship.seenShip'));
|
$SM.set('game.spaceShip.seenShip', $SM.get('ship.seenShip'));
|
||||||
$SM.remove('ship');
|
$SM.remove('ship');
|
||||||
};
|
}
|
||||||
if($SM.get('punches')){
|
if($SM.get('punches')){
|
||||||
$SM.set('character.punches', $SM.get('punches'));
|
$SM.set('character.punches', $SM.get('punches'));
|
||||||
$SM.remove('punches');
|
$SM.remove('punches');
|
||||||
};
|
}
|
||||||
if($SM.get('perks')){
|
if($SM.get('perks')){
|
||||||
$SM.set('character.perks', $SM.get('perks'));
|
$SM.set('character.perks', $SM.get('perks'));
|
||||||
$SM.remove('perks');
|
$SM.remove('perks');
|
||||||
};
|
}
|
||||||
if($SM.get('thieves')){
|
if($SM.get('thieves')){
|
||||||
$SM.set('game.thieves', $SM.get('thieves'));
|
$SM.set('game.thieves', $SM.get('thieves'));
|
||||||
$SM.remove('thieves');
|
$SM.remove('thieves');
|
||||||
};
|
}
|
||||||
if($SM.get('stolen')){
|
if($SM.get('stolen')){
|
||||||
$SM.set('game.stolen', $SM.get('stolen'));
|
$SM.set('game.stolen', $SM.get('stolen'));
|
||||||
$SM.remove('stolen');
|
$SM.remove('stolen');
|
||||||
};
|
}
|
||||||
if($SM.get('cityCleared')){
|
if($SM.get('cityCleared')){
|
||||||
$SM.set('character.cityCleared', $SM.get('cityCleared'));
|
$SM.set('character.cityCleared', $SM.get('cityCleared'));
|
||||||
$SM.remove('cityCleared');
|
$SM.remove('cityCleared');
|
||||||
};
|
}
|
||||||
$SM.set('version', 1.3);
|
$SM.set('version', 1.3);
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
@@ -369,7 +369,7 @@ var StateManager = {
|
|||||||
}
|
}
|
||||||
if(changed){
|
if(changed){
|
||||||
$SM.fireUpdate('income', true);
|
$SM.fireUpdate('income', true);
|
||||||
};
|
}
|
||||||
Engine._incomeTimeout = setTimeout($SM.collectIncome, 1000);
|
Engine._incomeTimeout = setTimeout($SM.collectIncome, 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -384,7 +384,7 @@ var StateManager = {
|
|||||||
} else {
|
} else {
|
||||||
$SM.add('game.stolen["'+k+'"]', stores[k] * -1);
|
$SM.add('game.stolen["'+k+'"]', stores[k] * -1);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
startThieves: function() {
|
startThieves: function() {
|
||||||
|
|||||||
+13
-13
@@ -243,7 +243,7 @@ var World = {
|
|||||||
|
|
||||||
// Add water
|
// Add water
|
||||||
var water = $('div#supply_water');
|
var water = $('div#supply_water');
|
||||||
if(World.water > 0 && water.length == 0) {
|
if(World.water > 0 && water.length === 0) {
|
||||||
water = World.createItemDiv('water', World.water);
|
water = World.createItemDiv('water', World.water);
|
||||||
water.prependTo(supplies);
|
water.prependTo(supplies);
|
||||||
} else if(World.water > 0) {
|
} else if(World.water > 0) {
|
||||||
@@ -257,7 +257,7 @@ var World = {
|
|||||||
var item = $('div#supply_' + k.replace(' ', '-'), supplies);
|
var item = $('div#supply_' + k.replace(' ', '-'), supplies);
|
||||||
var num = Path.outfit[k];
|
var num = Path.outfit[k];
|
||||||
total += num * Path.getWeight(k);
|
total += num * Path.getWeight(k);
|
||||||
if(num > 0 && item.length == 0) {
|
if(num > 0 && item.length === 0) {
|
||||||
item = World.createItemDiv(k, num);
|
item = World.createItemDiv(k, num);
|
||||||
if(k == 'cured meat' && World.water > 0) {
|
if(k == 'cured meat' && World.water > 0) {
|
||||||
item.insertAfter(water);
|
item.insertAfter(water);
|
||||||
@@ -410,11 +410,11 @@ var World = {
|
|||||||
checkDanger: function() {
|
checkDanger: function() {
|
||||||
World.danger = typeof World.danger == 'undefined' ? false: World.danger;
|
World.danger = typeof World.danger == 'undefined' ? false: World.danger;
|
||||||
if(!World.danger) {
|
if(!World.danger) {
|
||||||
if(!$SM.get('stores["i armour"]', true) > 0 && World.getDistance() >= 8) {
|
if($SM.get('stores["i armour"]', true) === 0 && World.getDistance() >= 8) {
|
||||||
World.danger = true;
|
World.danger = true;
|
||||||
return 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;
|
World.danger = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -441,7 +441,7 @@ var World = {
|
|||||||
World.foodMove = 0;
|
World.foodMove = 0;
|
||||||
var num = Path.outfit['cured meat'];
|
var num = Path.outfit['cured meat'];
|
||||||
num--;
|
num--;
|
||||||
if(num == 0) {
|
if(num === 0) {
|
||||||
Notifications.notify(World, _('the meat has run out'));
|
Notifications.notify(World, _('the meat has run out'));
|
||||||
} else if(num < 0) {
|
} else if(num < 0) {
|
||||||
// Starvation! Hooray!
|
// Starvation! Hooray!
|
||||||
@@ -471,7 +471,7 @@ var World = {
|
|||||||
World.waterMove = 0;
|
World.waterMove = 0;
|
||||||
var water = World.water;
|
var water = World.water;
|
||||||
water--;
|
water--;
|
||||||
if(water == 0) {
|
if(water === 0) {
|
||||||
Notifications.notify(World, _('there is no more water'));
|
Notifications.notify(World, _('there is no more water'));
|
||||||
} else if(water < 0) {
|
} else if(water < 0) {
|
||||||
water = 0;
|
water = 0;
|
||||||
@@ -754,7 +754,7 @@ var World = {
|
|||||||
|
|
||||||
drawMap: function() {
|
drawMap: function() {
|
||||||
var map = $('#map');
|
var map = $('#map');
|
||||||
if(map.length == 0) {
|
if(map.length === 0) {
|
||||||
map = new $('<div>').attr('id', 'map').appendTo('#worldOuter');
|
map = new $('<div>').attr('id', 'map').appendTo('#worldOuter');
|
||||||
// register click handler
|
// register click handler
|
||||||
map.click(World.click);
|
map.click(World.click);
|
||||||
@@ -831,15 +831,15 @@ var World = {
|
|||||||
goHome: function() {
|
goHome: function() {
|
||||||
// Home safe! Commit the changes.
|
// Home safe! Commit the changes.
|
||||||
$SM.setM('game.world', World.state);
|
$SM.setM('game.world', World.state);
|
||||||
if(World.state.sulphurmine && $SM.get('game.buildings["sulphur mine"]', true) == 0) {
|
if(World.state.sulphurmine && $SM.get('game.buildings["sulphur mine"]', true) === 0) {
|
||||||
$SM.add('game.buildings["sulphur mine"]', 1);
|
$SM.add('game.buildings["sulphur mine"]', 1);
|
||||||
Engine.event('progress', 'sulphur mine');
|
Engine.event('progress', 'sulphur mine');
|
||||||
}
|
}
|
||||||
if(World.state.ironmine && $SM.get('game.buildings["iron mine"]', true) == 0) {
|
if(World.state.ironmine && $SM.get('game.buildings["iron mine"]', true) === 0) {
|
||||||
$SM.add('game.buildings["iron mine"]', 1);
|
$SM.add('game.buildings["iron mine"]', 1);
|
||||||
Engine.event('progress', 'iron mine');
|
Engine.event('progress', 'iron mine');
|
||||||
}
|
}
|
||||||
if(World.state.coalmine && $SM.get('game.buildings["coal mine"]', true) == 0) {
|
if(World.state.coalmine && $SM.get('game.buildings["coal mine"]', true) === 0) {
|
||||||
$SM.add('game.buildings["coal mine"]', 1);
|
$SM.add('game.buildings["coal mine"]', 1);
|
||||||
Engine.event('progress', 'coal mine');
|
Engine.event('progress', 'coal mine');
|
||||||
}
|
}
|
||||||
@@ -868,8 +868,8 @@ var World = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
leaveItAtHome: function(thing) {
|
leaveItAtHome: function(thing) {
|
||||||
return thing != 'cured meat' && thing != 'bullets' && thing != 'energy cell' && thing != 'charm' && thing != 'medicine'
|
return thing != 'cured meat' && thing != 'bullets' && thing != 'energy cell' && thing != 'charm' && thing != 'medicine' &&
|
||||||
&& typeof World.Weapons[thing] == 'undefined' && typeof Room.Craftables[thing] == 'undefined';
|
typeof World.Weapons[thing] == 'undefined' && typeof Room.Craftables[thing] == 'undefined';
|
||||||
},
|
},
|
||||||
|
|
||||||
getMaxHealth: function() {
|
getMaxHealth: function() {
|
||||||
@@ -905,7 +905,7 @@ var World = {
|
|||||||
x = typeof x == 'number' ? x : World.curPos[0];
|
x = typeof x == 'number' ? x : World.curPos[0];
|
||||||
y = typeof y == 'number' ? y : World.curPos[1];
|
y = typeof y == 'number' ? y : World.curPos[1];
|
||||||
var used = World.usedOutposts[x + ',' + y];
|
var used = World.usedOutposts[x + ',' + y];
|
||||||
return typeof used != 'undefined' && used == true;
|
return typeof used != 'undefined' && used === true;
|
||||||
},
|
},
|
||||||
|
|
||||||
useOutpost: function() {
|
useOutpost: function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user