mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-06-12 23:47:13 +08:00
Some general code cleanup.
This commit is contained in:
+6
-7
@@ -376,21 +376,21 @@ var Engine = {
|
|||||||
case 37: // Left
|
case 37: // Left
|
||||||
case 65:
|
case 65:
|
||||||
if(Engine.activeModule == Ship && Path.tab)
|
if(Engine.activeModule == Ship && Path.tab)
|
||||||
Engine.travelTo(Path)
|
Engine.travelTo(Path);
|
||||||
else if(Engine.activeModule == Path && Outside.tab)
|
else if(Engine.activeModule == Path && Outside.tab)
|
||||||
Engine.travelTo(Outside)
|
Engine.travelTo(Outside);
|
||||||
else if(Engine.activeModule == Outside && Room.tab)
|
else if(Engine.activeModule == Outside && Room.tab)
|
||||||
Engine.travelTo(Room)
|
Engine.travelTo(Room);
|
||||||
Engine.log('left');
|
Engine.log('left');
|
||||||
break;
|
break;
|
||||||
case 39: // Right
|
case 39: // Right
|
||||||
case 68:
|
case 68:
|
||||||
if(Engine.activeModule == Room && Outside.tab)
|
if(Engine.activeModule == Room && Outside.tab)
|
||||||
Engine.travelTo(Outside)
|
Engine.travelTo(Outside);
|
||||||
else if(Engine.activeModule == Outside && Path.tab)
|
else if(Engine.activeModule == Outside && Path.tab)
|
||||||
Engine.travelTo(Path)
|
Engine.travelTo(Path);
|
||||||
else if(Engine.activeModule == Path && Ship.tab)
|
else if(Engine.activeModule == Path && Ship.tab)
|
||||||
Engine.travelTo(Ship)
|
Engine.travelTo(Ship);
|
||||||
Engine.log('right');
|
Engine.log('right');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -431,7 +431,6 @@ var Engine = {
|
|||||||
//create jQuery Callbacks() to handle object events
|
//create jQuery Callbacks() to handle object events
|
||||||
$.Dispatch = function( id ) {
|
$.Dispatch = function( id ) {
|
||||||
var callbacks,
|
var callbacks,
|
||||||
method,
|
|
||||||
topic = id && Engine.topics[ id ];
|
topic = id && Engine.topics[ id ];
|
||||||
if ( !topic ) {
|
if ( !topic ) {
|
||||||
callbacks = jQuery.Callbacks();
|
callbacks = jQuery.Callbacks();
|
||||||
|
|||||||
+5
-6
@@ -298,7 +298,7 @@ var Events = {
|
|||||||
dmg = weapon.damage;
|
dmg = weapon.damage;
|
||||||
if(typeof dmg == 'number') {
|
if(typeof dmg == 'number') {
|
||||||
if(weapon.type == 'unarmed' && $SM.hasPerk('boxer')) {
|
if(weapon.type == 'unarmed' && $SM.hasPerk('boxer')) {
|
||||||
dmg *= 2
|
dmg *= 2;
|
||||||
}
|
}
|
||||||
if(weapon.type == 'unarmed' && $SM.hasPerk('martial artist')) {
|
if(weapon.type == 'unarmed' && $SM.hasPerk('martial artist')) {
|
||||||
dmg *= 3;
|
dmg *= 3;
|
||||||
@@ -336,7 +336,7 @@ var Events = {
|
|||||||
|
|
||||||
fighter.stop(true, true).animate(start, Events._FIGHT_SPEED, function() {
|
fighter.stop(true, true).animate(start, Events._FIGHT_SPEED, function() {
|
||||||
var enemyHp = enemy.data('hp');
|
var enemyHp = enemy.data('hp');
|
||||||
var msg;
|
var msg = "";
|
||||||
if(typeof dmg == 'number') {
|
if(typeof dmg == 'number') {
|
||||||
if(dmg < 0) {
|
if(dmg < 0) {
|
||||||
msg = 'miss';
|
msg = 'miss';
|
||||||
@@ -381,7 +381,7 @@ var Events = {
|
|||||||
$('<div>').css(start).addClass('bullet').text('o').appendTo('#description')
|
$('<div>').css(start).addClass('bullet').text('o').appendTo('#description')
|
||||||
.animate(end, Events._FIGHT_SPEED * 2, 'linear', function() {
|
.animate(end, Events._FIGHT_SPEED * 2, 'linear', function() {
|
||||||
var enemyHp = enemy.data('hp');
|
var enemyHp = enemy.data('hp');
|
||||||
var msg;
|
var msg = "";
|
||||||
if(typeof dmg == 'number') {
|
if(typeof dmg == 'number') {
|
||||||
if(dmg < 0) {
|
if(dmg < 0) {
|
||||||
msg = 'miss';
|
msg = 'miss';
|
||||||
@@ -508,7 +508,7 @@ var Events = {
|
|||||||
|
|
||||||
dropStuff: function(e) {
|
dropStuff: function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
var btn = $(this)
|
var btn = $(this);
|
||||||
var thing = btn.data('thing');
|
var thing = btn.data('thing');
|
||||||
var num = btn.data('num');
|
var num = btn.data('num');
|
||||||
var lootButtons = $('#lootButtons');
|
var lootButtons = $('#lootButtons');
|
||||||
@@ -537,7 +537,6 @@ var Events = {
|
|||||||
var weight = Path.getWeight(name);
|
var weight = Path.getWeight(name);
|
||||||
var freeSpace = Path.getFreeSpace();
|
var freeSpace = Path.getFreeSpace();
|
||||||
if(weight <= freeSpace) {
|
if(weight <= freeSpace) {
|
||||||
var loot = Events.activeEvent().scenes[Events.activeScene].loot[name];
|
|
||||||
var num = btn.data('numLeft');
|
var num = btn.data('numLeft');
|
||||||
num--;
|
num--;
|
||||||
btn.data('numLeft', num);
|
btn.data('numLeft', num);
|
||||||
@@ -791,7 +790,7 @@ var Events = {
|
|||||||
|
|
||||||
scheduleNextEvent: function(scale) {
|
scheduleNextEvent: function(scale) {
|
||||||
var nextEvent = Math.floor(Math.random()*(Events._EVENT_TIME_RANGE[1] - Events._EVENT_TIME_RANGE[0])) + Events._EVENT_TIME_RANGE[0];
|
var nextEvent = Math.floor(Math.random()*(Events._EVENT_TIME_RANGE[1] - Events._EVENT_TIME_RANGE[0])) + Events._EVENT_TIME_RANGE[0];
|
||||||
if(scale > 0) { nextEvent *= scale }
|
if(scale > 0) { nextEvent *= scale; }
|
||||||
Engine.log('next event scheduled in ' + nextEvent + ' minutes');
|
Engine.log('next event scheduled in ' + nextEvent + ' minutes');
|
||||||
Events._eventTimeout = setTimeout(Events.triggerEvent, nextEvent * 60 * 1000);
|
Events._eventTimeout = setTimeout(Events.triggerEvent, nextEvent * 60 * 1000);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ var Notifications = {
|
|||||||
Engine.saveGame();
|
Engine.saveGame();
|
||||||
},
|
},
|
||||||
|
|
||||||
printMessage: function(text) {
|
printMessage: function(t) {
|
||||||
var text = $('<div>').addClass('notification').css('opacity', '0').text(text).prependTo('div#notifications');
|
var text = $('<div>').addClass('notification').css('opacity', '0').text(t).prependTo('div#notifications');
|
||||||
text.animate({opacity: 1}, 500, 'linear');
|
text.animate({opacity: 1}, 500, 'linear');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
+27
-27
@@ -350,36 +350,36 @@ 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) {
|
||||||
var 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);
|
||||||
$('<div>').addClass('clear').appendTo(row);
|
$('<div>').addClass('clear').appendTo(row);
|
||||||
var curPrev = null;
|
var curPrev = null;
|
||||||
village.children().each(function(i) {
|
village.children().each(function(i) {
|
||||||
var child = $(this);
|
var child = $(this);
|
||||||
if(child.attr('id') != 'population') {
|
if(child.attr('id') != 'population') {
|
||||||
var cName = child.attr('id').substring(13).replace('-', ' ');
|
var cName = child.attr('id').substring(13).replace('-', ' ');
|
||||||
if(cName < name && (curPrev == null || cName > curPrev)) {
|
if(cName < name && (curPrev == null || cName > curPrev)) {
|
||||||
curPrev = cName;
|
curPrev = cName;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
if(curPrev == null) {
|
|
||||||
row.prependTo(village);
|
|
||||||
} else {
|
|
||||||
row.insertAfter('#building_row_' + curPrev.replace(' ', '-'));
|
|
||||||
}
|
}
|
||||||
} else if(num > 0) {
|
});
|
||||||
$('div#' + row.attr('id') + ' > div.row_val', village).text(num);
|
if(curPrev == null) {
|
||||||
} else if(num == 0) {
|
row.prependTo(village);
|
||||||
row.remove();
|
} else {
|
||||||
|
row.insertAfter('#building_row_' + curPrev.replace(' ', '-'));
|
||||||
}
|
}
|
||||||
|
} else if(num > 0) {
|
||||||
|
$('div#' + row.attr('id') + ' > div.row_val', village).text(num);
|
||||||
|
} else if(num == 0) {
|
||||||
|
row.remove();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateVillage: function() {
|
updateVillage: function() {
|
||||||
var village = $('div#village');
|
var village = $('div#village');
|
||||||
var pop = $('div#population');
|
var population = $('div#population');
|
||||||
var needsAppend = false;
|
var needsAppend = false;
|
||||||
if(village.length == 0) {
|
if(village.length == 0) {
|
||||||
needsAppend = true;
|
needsAppend = true;
|
||||||
@@ -440,7 +440,7 @@ var Outside = {
|
|||||||
'sulphur mine': ['sulphur miner'],
|
'sulphur mine': ['sulphur miner'],
|
||||||
'steelworks': ['steelworker'],
|
'steelworks': ['steelworker'],
|
||||||
'armoury' : ['armourer']
|
'armoury' : ['armourer']
|
||||||
}
|
};
|
||||||
|
|
||||||
var jobs = jobMap[name];
|
var jobs = jobMap[name];
|
||||||
var added = false;
|
var added = false;
|
||||||
@@ -449,7 +449,7 @@ var Outside = {
|
|||||||
var job = jobs[i];
|
var job = jobs[i];
|
||||||
if(typeof $SM.get('game.buildings["'+name+'"]') == 'number' &&
|
if(typeof $SM.get('game.buildings["'+name+'"]') == 'number' &&
|
||||||
typeof $SM.get('game.workers["'+job+'"]') != 'number') {
|
typeof $SM.get('game.workers["'+job+'"]') != 'number') {
|
||||||
Engine.log('adding ' + job + ' to the workers list')
|
Engine.log('adding ' + job + ' to the workers list');
|
||||||
$SM.set('game.workers["'+job+'"]', 0);
|
$SM.set('game.workers["'+job+'"]', 0);
|
||||||
added = true;
|
added = true;
|
||||||
}
|
}
|
||||||
@@ -545,7 +545,7 @@ var Outside = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
gatherWood: function() {
|
gatherWood: function() {
|
||||||
Notifications.notify(Outside, "dry brush and dead branches litter the forest floor")
|
Notifications.notify(Outside, "dry brush and dead branches litter the forest floor");
|
||||||
var gatherAmt = $SM.get('game.buildings["cart"]', true) > 0 ? 50 : 10;
|
var gatherAmt = $SM.get('game.buildings["cart"]', true) > 0 ? 50 : 10;
|
||||||
$SM.add('stores.wood', gatherAmt);
|
$SM.add('stores.wood', gatherAmt);
|
||||||
},
|
},
|
||||||
@@ -561,7 +561,7 @@ var Outside = {
|
|||||||
for(var j in Outside.TrapDrops) {
|
for(var j in Outside.TrapDrops) {
|
||||||
var drop = Outside.TrapDrops[j];
|
var drop = Outside.TrapDrops[j];
|
||||||
if(roll < drop.rollUnder) {
|
if(roll < drop.rollUnder) {
|
||||||
var num = drops[drop.name]
|
var num = drops[drop.name];
|
||||||
if(typeof num == 'undefined') {
|
if(typeof num == 'undefined') {
|
||||||
num = 0;
|
num = 0;
|
||||||
msg.push(drop.message);
|
msg.push(drop.message);
|
||||||
|
|||||||
+5
-5
@@ -35,7 +35,7 @@ var Path = {
|
|||||||
|
|
||||||
// Add the outfitting area
|
// Add the outfitting area
|
||||||
var outfitting = $('<div>').attr('id', 'outfitting').appendTo(this.panel);
|
var outfitting = $('<div>').attr('id', 'outfitting').appendTo(this.panel);
|
||||||
var bagspace = $('<div>').attr('id', 'bagspace').appendTo(outfitting);
|
$('<div>').attr('id', 'bagspace').appendTo(outfitting);
|
||||||
|
|
||||||
// Add the embark button
|
// Add the embark button
|
||||||
new Button.Button({
|
new Button.Button({
|
||||||
@@ -114,10 +114,10 @@ var Path = {
|
|||||||
if(needsAppend && perks.children().length > 0) {
|
if(needsAppend && perks.children().length > 0) {
|
||||||
perks.appendTo(Path.panel);
|
perks.appendTo(Path.panel);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if(Engine.activeModule === Path) {
|
||||||
if(Engine.activeModule === Path) {
|
$('#storesContainer').css({top: perks.height() + 26 + 'px'});
|
||||||
$('#storesContainer').css({top: perks.height() + 26 + 'px'});
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
+19
-19
@@ -65,7 +65,7 @@ var Room = {
|
|||||||
wood: 200,
|
wood: 200,
|
||||||
fur: 10,
|
fur: 10,
|
||||||
meat: 5
|
meat: 5
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'trading post': {
|
'trading post': {
|
||||||
@@ -261,7 +261,7 @@ var Room = {
|
|||||||
return {
|
return {
|
||||||
'leather': 200,
|
'leather': 200,
|
||||||
'iron': 100
|
'iron': 100
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
's armour': {
|
's armour': {
|
||||||
@@ -272,7 +272,7 @@ var Room = {
|
|||||||
return {
|
return {
|
||||||
'leather': 200,
|
'leather': 200,
|
||||||
'steel': 100
|
'steel': 100
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'iron sword': {
|
'iron sword': {
|
||||||
@@ -307,7 +307,7 @@ var Room = {
|
|||||||
'wood': 200,
|
'wood': 200,
|
||||||
'steel': 50,
|
'steel': 50,
|
||||||
'sulphur': 50
|
'sulphur': 50
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -331,7 +331,7 @@ var Room = {
|
|||||||
return {
|
return {
|
||||||
'fur': 150,
|
'fur': 150,
|
||||||
'scales': 50
|
'scales': 50
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'coal': {
|
'coal': {
|
||||||
@@ -340,7 +340,7 @@ var Room = {
|
|||||||
return {
|
return {
|
||||||
'fur': 200,
|
'fur': 200,
|
||||||
'teeth': 50
|
'teeth': 50
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'steel': {
|
'steel': {
|
||||||
@@ -350,7 +350,7 @@ var Room = {
|
|||||||
'fur': 300,
|
'fur': 300,
|
||||||
'scales': 50,
|
'scales': 50,
|
||||||
'teeth': 50
|
'teeth': 50
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'medicine': {
|
'medicine': {
|
||||||
@@ -358,7 +358,7 @@ var Room = {
|
|||||||
cost: function() {
|
cost: function() {
|
||||||
return {
|
return {
|
||||||
'scales': 50, 'teeth': 30
|
'scales': 50, 'teeth': 30
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'bullets': {
|
'bullets': {
|
||||||
@@ -366,7 +366,7 @@ var Room = {
|
|||||||
cost: function() {
|
cost: function() {
|
||||||
return {
|
return {
|
||||||
'scales': 10
|
'scales': 10
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'energy cell': {
|
'energy cell': {
|
||||||
@@ -375,7 +375,7 @@ var Room = {
|
|||||||
return {
|
return {
|
||||||
'scales': 10,
|
'scales': 10,
|
||||||
'teeth': 10
|
'teeth': 10
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'bolas': {
|
'bolas': {
|
||||||
@@ -383,7 +383,7 @@ var Room = {
|
|||||||
cost: function() {
|
cost: function() {
|
||||||
return {
|
return {
|
||||||
'teeth': 10
|
'teeth': 10
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'grenade': {
|
'grenade': {
|
||||||
@@ -392,7 +392,7 @@ var Room = {
|
|||||||
return {
|
return {
|
||||||
'scales': 100,
|
'scales': 100,
|
||||||
'teeth': 50
|
'teeth': 50
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'bayonet': {
|
'bayonet': {
|
||||||
@@ -401,7 +401,7 @@ var Room = {
|
|||||||
return {
|
return {
|
||||||
'scales': 500,
|
'scales': 500,
|
||||||
'teeth': 250
|
'teeth': 250
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'alien alloy': {
|
'alien alloy': {
|
||||||
@@ -411,7 +411,7 @@ var Room = {
|
|||||||
'fur': 1500,
|
'fur': 1500,
|
||||||
'scales': 750,
|
'scales': 750,
|
||||||
'teeth': 300
|
'teeth': 300
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'compass': {
|
'compass': {
|
||||||
@@ -468,7 +468,7 @@ var Room = {
|
|||||||
Engine.updateSlider();
|
Engine.updateSlider();
|
||||||
|
|
||||||
// Create the light button
|
// Create the light button
|
||||||
var lbtn = new Button.Button({
|
new Button.Button({
|
||||||
id: 'lightButton',
|
id: 'lightButton',
|
||||||
text: 'light fire',
|
text: 'light fire',
|
||||||
click: Room.lightFire,
|
click: Room.lightFire,
|
||||||
@@ -478,7 +478,7 @@ var Room = {
|
|||||||
}).appendTo('div#roomPanel');
|
}).appendTo('div#roomPanel');
|
||||||
|
|
||||||
// Create the stoke button
|
// Create the stoke button
|
||||||
var btn = new Button.Button({
|
new Button.Button({
|
||||||
id: 'stokeButton',
|
id: 'stokeButton',
|
||||||
text: "stoke fire",
|
text: "stoke fire",
|
||||||
click: Room.stokeFire,
|
click: Room.stokeFire,
|
||||||
@@ -537,7 +537,7 @@ var Room = {
|
|||||||
stores: {'wood' : 2 }
|
stores: {'wood' : 2 }
|
||||||
});
|
});
|
||||||
Room.updateIncomeView();
|
Room.updateIncomeView();
|
||||||
Notifications.notify(Room, "the stranger is standing by the fire. she says she can help. says she builds things.")
|
Notifications.notify(Room, "the stranger is standing by the fire. she says she can help. says she builds things.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine.moveStoresView(null, transition_diff);
|
Engine.moveStoresView(null, transition_diff);
|
||||||
@@ -703,7 +703,7 @@ var Room = {
|
|||||||
setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
|
setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
|
||||||
}
|
}
|
||||||
else if(lBuilder < 3 && Room.temperature.value >= Room.TempEnum.Warm.value) {
|
else if(lBuilder < 3 && Room.temperature.value >= Room.TempEnum.Warm.value) {
|
||||||
var msg;
|
var msg = "";
|
||||||
switch(lBuilder) {
|
switch(lBuilder) {
|
||||||
case 1:
|
case 1:
|
||||||
msg = "the stranger shivers, and mumbles quietly. her words are unintelligible.";
|
msg = "the stranger shivers, and mumbles quietly. her words are unintelligible.";
|
||||||
@@ -781,7 +781,7 @@ var Room = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(row.length == 0 && num > 0) {
|
if(row.length == 0 && num > 0) {
|
||||||
var 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);
|
||||||
$('<div>').addClass('clear').appendTo(row);
|
$('<div>').addClass('clear').appendTo(row);
|
||||||
|
|||||||
+1
-1
@@ -120,7 +120,7 @@ var Ship = {
|
|||||||
return false;
|
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)
|
$SM.add('game.spaceShip.thrusters', 1);
|
||||||
$('#engineRow .row_val', Ship.panel).text($SM.get('game.spaceShip.thrusters'));
|
$('#engineRow .row_val', Ship.panel).text($SM.get('game.spaceShip.thrusters'));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -103,7 +103,7 @@ var Space = {
|
|||||||
if(r < 0.2)
|
if(r < 0.2)
|
||||||
c = '#';
|
c = '#';
|
||||||
else if(r < 0.4)
|
else if(r < 0.4)
|
||||||
c = '$'
|
c = '$';
|
||||||
else if(r < 0.6)
|
else if(r < 0.6)
|
||||||
c = '%';
|
c = '%';
|
||||||
else if(r < 0.8)
|
else if(r < 0.8)
|
||||||
@@ -112,7 +112,7 @@ var Space = {
|
|||||||
c = 'H';
|
c = 'H';
|
||||||
|
|
||||||
var x = Math.floor(Math.random() * 700);
|
var x = Math.floor(Math.random() * 700);
|
||||||
var a = $('<div>').addClass('asteroid').text(c).appendTo('#spacePanel').css('left', x + 'px')
|
var a = $('<div>').addClass('asteroid').text(c).appendTo('#spacePanel').css('left', x + 'px');
|
||||||
a.data({
|
a.data({
|
||||||
xMin: x,
|
xMin: x,
|
||||||
xMax: x + a.width(),
|
xMax: x + a.width(),
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ 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.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!noEvent) {
|
if(!noEvent) {
|
||||||
@@ -95,7 +95,7 @@ var StateManager = {
|
|||||||
|
|
||||||
//sets a list of states
|
//sets a list of states
|
||||||
setM: function(parentName, list, noEvent) {
|
setM: function(parentName, list, noEvent) {
|
||||||
var whichParent = $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);
|
||||||
@@ -125,7 +125,7 @@ var StateManager = {
|
|||||||
$SM.set(stateName, old + value, noEvent);
|
$SM.set(stateName, old + value, noEvent);
|
||||||
} else if(typeof old != 'number' || typeof value != 'number'){
|
} else if(typeof old != 'number' || typeof value != 'number'){
|
||||||
Engine.log('WARNING: Can not do math with state:'+stateName+' or value:'+value+' because at least one is not a number.');
|
Engine.log('WARNING: Can not do math with state:'+stateName+' or value:'+value+' because at least one is not a number.');
|
||||||
err = 1
|
err = 1;
|
||||||
} else {
|
} else {
|
||||||
$SM.set(stateName, old + value, noEvent); //setState handles event and save
|
$SM.set(stateName, old + value, noEvent); //setState handles event and save
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ var StateManager = {
|
|||||||
fireUpdate: function(stateName, save){
|
fireUpdate: function(stateName, save){
|
||||||
var category = $SM.getCategory(stateName);
|
var category = $SM.getCategory(stateName);
|
||||||
if(stateName == undefined) stateName = category = 'all'; //best if this doesn't happen as it will trigger more stuff
|
if(stateName == undefined) stateName = category = 'all'; //best if this doesn't happen as it will trigger more stuff
|
||||||
$.Dispatch('stateUpdate').publish({'category': category, 'stateName':stateName})
|
$.Dispatch('stateUpdate').publish({'category': category, 'stateName':stateName});
|
||||||
if(save) Engine.saveGame();
|
if(save) Engine.saveGame();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
+3
-5
@@ -334,7 +334,7 @@ var World = {
|
|||||||
World.doSpace();
|
World.doSpace();
|
||||||
if(World.checkDanger()) {
|
if(World.checkDanger()) {
|
||||||
if(World.danger) {
|
if(World.danger) {
|
||||||
Notifications.notify(World, 'dangerous to be this far from the village without proper protection')
|
Notifications.notify(World, 'dangerous to be this far from the village without proper protection');
|
||||||
} else {
|
} else {
|
||||||
Notifications.notify(World, 'safer here');
|
Notifications.notify(World, 'safer here');
|
||||||
}
|
}
|
||||||
@@ -441,7 +441,7 @@ var World = {
|
|||||||
// Starvation! Hooray!
|
// Starvation! Hooray!
|
||||||
num = 0;
|
num = 0;
|
||||||
if(!World.starvation) {
|
if(!World.starvation) {
|
||||||
Notifications.notify(World, 'starvation sets in')
|
Notifications.notify(World, 'starvation sets in');
|
||||||
World.starvation = true;
|
World.starvation = true;
|
||||||
} else {
|
} else {
|
||||||
$SM.set('character.starved', $SM.get('character.starved', true));
|
$SM.set('character.starved', $SM.get('character.starved', true));
|
||||||
@@ -620,7 +620,7 @@ var World = {
|
|||||||
// Spiral out from there
|
// Spiral out from there
|
||||||
map[World.RADIUS][World.RADIUS] = World.TILE.VILLAGE;
|
map[World.RADIUS][World.RADIUS] = World.TILE.VILLAGE;
|
||||||
for(var r = 1; r <= World.RADIUS; r++) {
|
for(var r = 1; r <= World.RADIUS; r++) {
|
||||||
for(t = 0; t < r * 8; t++) {
|
for(var t = 0; t < r * 8; t++) {
|
||||||
var x, y;
|
var x, y;
|
||||||
if(t < 2 * r) {
|
if(t < 2 * r) {
|
||||||
x = World.RADIUS - r + t;
|
x = World.RADIUS - r + t;
|
||||||
@@ -689,8 +689,6 @@ var World = {
|
|||||||
|
|
||||||
chooseTile: function(x, y, map) {
|
chooseTile: function(x, y, map) {
|
||||||
|
|
||||||
var log = x == World.RADIUS + 1 && y == World.RADIUS + 1;
|
|
||||||
|
|
||||||
var adjacent = [
|
var adjacent = [
|
||||||
y > 0 ? map[x][y-1] : null,
|
y > 0 ? map[x][y-1] : null,
|
||||||
y < World.RADIUS * 2 ? map[x][y+1] : null,
|
y < World.RADIUS * 2 ? map[x][y+1] : null,
|
||||||
|
|||||||
Reference in New Issue
Block a user