Skip to content

Commit

Permalink
Merge pull request doublespeakgames#204 from rgravina/188_fix_jshint_…
Browse files Browse the repository at this point in the history
…warnings
  • Loading branch information
groteworld committed Feb 10, 2015
2 parents afe1230 + 67b3c7f commit 5d921d9
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 117 deletions.
9 changes: 4 additions & 5 deletions script/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@
.addClass('customSelect')
.addClass('menuBtn')
.appendTo(menu);
var options = $('<span>')
var selectOptions = $('<span>')
.addClass('customSelectOptions')
.appendTo(customSelect);
var optionsList = $('<ul>')
.appendTo(options);
.appendTo(selectOptions);
$('<li>')
.text("language.")
.appendTo(optionsList);
Expand Down Expand Up @@ -339,7 +339,7 @@
}
}
});
Engine.autoSelect('#description textarea')
Engine.autoSelect('#description textarea');
},

import64: function(string64) {
Expand Down Expand Up @@ -462,7 +462,6 @@
var darkCss = Engine.findStylesheet('darkenLights');
if (darkCss == null) {
$('head').append('<link rel="stylesheet" href="css/dark.css" type="text/css" title="darkenLights" />');
Engine.turnLightsOff;
$('.lightsOff').text(_('lights on.'));
} else if (darkCss.disabled) {
darkCss.disabled = false;
Expand Down Expand Up @@ -496,7 +495,7 @@
var diff = Math.abs(panelIndex - currentIndex);
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...?
stores.animate({right: -(panelIndex * 700) + 'px'}, 300 * diff);
}
Expand Down
26 changes: 12 additions & 14 deletions script/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var Events = {
);

// Build the Event Pool
Events.EventPool = new Array().concat(
Events.EventPool = [].concat(
Events.Global,
Events.Room,
Events.Outside
Expand All @@ -35,9 +35,7 @@ var Events = {

options: {}, // Nothing for now

activeEvent: null,
activeScene: null,
eventPanel: null,

loadScene: function(name) {
Engine.log('loading scene: ' + name);
Expand Down Expand Up @@ -88,7 +86,7 @@ var Events = {
for(var k in World.Weapons) {
var weapon = World.Weapons[k];
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
numWeapons--;
} else if(weapon.cost){
Expand All @@ -104,13 +102,13 @@ var Events = {
Events.createAttackButton(k).appendTo(btns);
}
}
if(numWeapons == 0) {
if(numWeapons === 0) {
// No weapons? You can punch stuff!
Events.createAttackButton('fists').prependTo(btns);
}

Events.createEatMeatButton().appendTo(btns);
if((Path.outfit['medicine'] || 0) != 0) {
if((Path.outfit['medicine'] || 0) !== 0) {
Events.createUseMedsButton().appendTo(btns);
}

Expand All @@ -131,7 +129,7 @@ var Events = {
cost: { 'cured meat': 1 }
});

if(Path.outfit['cured meat'] == 0) {
if(Path.outfit['cured meat'] === 0) {
Button.setDisabled(btn, true);
}

Expand All @@ -151,7 +149,7 @@ var Events = {
cost: { 'medicine': 1 }
});

if((Path.outfit['medicine'] || 0) == 0) {
if((Path.outfit['medicine'] || 0) === 0) {
Button.setDisabled(btn, true);
}

Expand Down Expand Up @@ -203,7 +201,7 @@ var Events = {
if(Path.outfit['cured meat'] > 0) {
Path.outfit['cured meat']--;
World.updateSupplies();
if(Path.outfit['cured meat'] == 0) {
if(Path.outfit['cured meat'] === 0) {
Button.setDisabled($('#eat'), true);
}

Expand All @@ -225,7 +223,7 @@ var Events = {
if(Path.outfit['medicine'] > 0) {
Path.outfit['medicine']--;
World.updateSupplies();
if(Path.outfit['medicine'] == 0) {
if(Path.outfit['medicine'] === 0) {
Button.setDisabled($('#meds'), true);
}

Expand Down Expand Up @@ -286,7 +284,7 @@ var Events = {
if(!validWeapons) {
// enable or create the punch button
var fists = $('#attack_fists');
if(fists.length == 0) {
if(fists.length === 0) {
Events.createAttackButton('fists').prependTo('#buttons', Events.eventPanel());
} else {
Button.setDisabled(fists, false);
Expand Down Expand Up @@ -477,7 +475,7 @@ var Events = {
}).appendTo(btns));

Events.createEatMeatButton(0).appendTo(btns);
if((Path.outfit['medicine'] || 0) != 0) {
if((Path.outfit['medicine'] || 0) !== 0) {
Events.createUseMedsButton(0).appendTo(btns);
}
}
Expand Down Expand Up @@ -542,7 +540,7 @@ var Events = {
var num = btn.data('numLeft');
num--;
btn.data('numLeft', num);
if(num == 0) {
if(num === 0) {
Button.setDisabled(btn);
btn.animate({'opacity':0}, 300, 'linear', function() {
$(this).remove();
Expand Down Expand Up @@ -764,7 +762,7 @@ var Events = {
}
}

if(possibleEvents.length == 0) {
if(possibleEvents.length === 0) {
Events.scheduleNextEvent(0.5);
return;
} else {
Expand Down
2 changes: 1 addition & 1 deletion script/events/outside.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Events.Outside = [
{ /* Soldier attack */
title: _('A Military Raid'),
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: {
'start': {
Expand Down
12 changes: 6 additions & 6 deletions script/events/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ Events.Room = [
onLoad: function() {
var numWood = $SM.get('stores.wood', true);
numWood = Math.floor(numWood * 0.1);
if(numWood == 0) numWood = 1;
if(numWood === 0) numWood = 1;
var numScales = Math.floor(numWood / 5);
if(numScales == 0) numScales = 1;
if(numScales === 0) numScales = 1;
$SM.addM('stores', {'wood': -numWood, 'scales': numScales});
},
buttons: {
Expand All @@ -153,9 +153,9 @@ Events.Room = [
onLoad: function() {
var numWood = $SM.get('stores.wood', true);
numWood = Math.floor(numWood * 0.1);
if(numWood == 0) numWood = 1;
if(numWood === 0) numWood = 1;
var numTeeth = Math.floor(numWood / 5);
if(numTeeth == 0) numTeeth = 1;
if(numTeeth === 0) numTeeth = 1;
$SM.addM('stores', {'wood': -numWood, 'teeth': numTeeth});
},
buttons: {
Expand All @@ -173,9 +173,9 @@ Events.Room = [
onLoad: function() {
var numWood = $SM.get('stores.wood', true);
numWood = Math.floor(numWood * 0.1);
if(numWood == 0) numWood = 1;
if(numWood === 0) numWood = 1;
var numCloth = Math.floor(numWood / 5);
if(numCloth == 0) numCloth = 1;
if(numCloth === 0) numCloth = 1;
$SM.addM('stores', {'wood': -numWood, 'cloth': numCloth});
},
buttons: {
Expand Down
2 changes: 1 addition & 1 deletion script/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var Notifications = {
if(module != null && Engine.activeModule != module) {
if(!noQueue) {
if(typeof this.notifyQueue[module] == 'undefined') {
this.notifyQueue[module] = new Array();
this.notifyQueue[module] = [];
}
this.notifyQueue[module].push(text);
}
Expand Down
38 changes: 19 additions & 19 deletions script/outside.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ var Outside = {
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;
if(num === 0) num = 1;
if(num == 1) {
Notifications.notify(null, _('a stranger arrives in the night'));
} else if(num < 5) {
Expand All @@ -205,9 +205,9 @@ var Outside = {
if(remaining < 0) {
var gap = -remaining;
for(var k in $SM.get('game.workers')) {
var num = $SM.get('game.workers["'+k+'"]');
if(num < gap) {
gap -= num;
var numWorkers = $SM.get('game.workers["'+k+'"]');
if(numWorkers < gap) {
gap -= numWorkers;
$SM.set('game.workers["'+k+'"]', 0);
} else {
$SM.add('game.workers["'+k+'"]', gap * -1);
Expand All @@ -228,10 +228,10 @@ 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.population') == 0) return;
if(!workers.length && $SM.get('game.population') === 0) return;

var needsAppend = false;
if(workers.length == 0) {
if(workers.length === 0) {
needsAppend = true;
workers = $('<div>').attr('id', 'workers').css('opacity', 0);
}
Expand All @@ -242,7 +242,7 @@ var Outside = {
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) {
if(row.length === 0) {
row = Outside.makeWorkerRow(k, workerCount);

var curPrev = null;
Expand All @@ -255,7 +255,7 @@ var Outside = {
}
}
});
if(curPrev == null && gatherer.length == 0) {
if(curPrev == null && gatherer.length === 0) {
row.prependTo(workers);
}
else if(curPrev == null)
Expand All @@ -271,7 +271,7 @@ var Outside = {
$('div#' + row.attr('id') + ' > div.row_val > span', workers).text(workerCount);
}
numGatherers -= workerCount;
if(workerCount == 0) {
if(workerCount === 0) {
$('.dnBtn', row).addClass('disabled');
$('.dnManyBtn', row).addClass('disabled');
} else {
Expand All @@ -280,14 +280,14 @@ var Outside = {
}
}

if(gatherer.length == 0) {
if(gatherer.length === 0) {
gatherer = Outside.makeWorkerRow('gatherer', numGatherers);
gatherer.prependTo(workers);
} else {
$('div#workers_row_gatherer > div.row_val > span', workers).text(numGatherers);
}

if(numGatherers == 0) {
if(numGatherers === 0) {
$('.upBtn', '#workers').addClass('disabled');
$('.upManyBtn', '#workers').addClass('disabled');
} else {
Expand Down Expand Up @@ -363,7 +363,7 @@ var Outside = {
updateVillageRow: function(name, num, village) {
var id = 'building_row_' + name.replace(' ', '-');
var row = $('div#' + id, village);
if(row.length == 0 && num > 0) {
if(row.length === 0 && num > 0) {
row = $('<div>').attr('id', id).addClass('storeRow');
$('<div>').addClass('row_key').text(_(name)).appendTo(row);
$('<div>').addClass('row_val').text(num).appendTo(row);
Expand All @@ -385,7 +385,7 @@ var Outside = {
}
} else if(num > 0) {
$('div#' + row.attr('id') + ' > div.row_val', village).text(num);
} else if(num == 0) {
} else if(num === 0) {
row.remove();
}
},
Expand All @@ -394,7 +394,7 @@ var Outside = {
var village = $('div#village');
var population = $('div#population');
var needsAppend = false;
if(village.length == 0) {
if(village.length === 0) {
needsAppend = true;
village = $('<div>').attr('id', 'village').css('opacity', 0);
population = $('<div>').attr('id', 'population').appendTo(village);
Expand All @@ -419,7 +419,7 @@ var Outside = {
population.text(_('pop ') + $SM.get('game.population') + '/' + this.getMaxPopulation());

var hasPeeps;
if($SM.get('game.buildings["hut"]', true) == 0) {
if($SM.get('game.buildings["hut"]', true) === 0) {
hasPeeps = false;
village.addClass('noHuts');
} else {
Expand Down Expand Up @@ -504,7 +504,7 @@ var Outside = {
updateTrapButton: function() {
var btn = $('div#trapsButton');
if($SM.get('game.buildings["trap"]', true) > 0) {
if(btn.length == 0) {
if(btn.length === 0) {
new Button.Button({
id: 'trapsButton',
text: _("check traps"),
Expand All @@ -525,7 +525,7 @@ var Outside = {
setTitle: function() {
var numHuts = $SM.get('game.buildings["hut"]', true);
var title;
if(numHuts == 0) {
if(numHuts === 0) {
title = _("A Silent Forest");
} else if(numHuts == 1) {
title = _("A Lonely Hut");
Expand Down Expand Up @@ -606,10 +606,10 @@ 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){
} else if(e.stateName.indexOf('game.workers') === 0 || e.stateName.indexOf('game.population') === 0){
Outside.updateVillage();
Outside.updateWorkersView();
Outside.updateVillageIncome();
};
}
}
};
Loading

0 comments on commit 5d921d9

Please sign in to comment.