Merge pull request #222 from anubisthejackle/issue80

This commit is contained in:
Blake Grotewold
2015-02-09 19:37:10 -05:00
7 changed files with 58 additions and 33 deletions
+27 -2
View File
@@ -74,7 +74,8 @@
state: null,
debug: false,
log: false,
dropbox: false
dropbox: false,
doubleTime: false
},
init: function(options) {
@@ -137,7 +138,19 @@
.text(_('lights off.'))
.click(Engine.turnLightsOff)
.appendTo(menu);
$('<span>')
.addClass('menuBtn')
.text(_('hyper.'))
.click(function(){
Engine.options.doubleTime = !Engine.options.doubleTime;
if(Engine.options.doubleTime)
$(this).text(_('classic.'));
else
$(this).text(_('hyper.'));
})
.appendTo(menu);
$('<span>')
.addClass('menuBtn')
.text(_('restart.'))
@@ -680,7 +693,19 @@
if(lang && typeof Storage != 'undefined' && localStorage) {
localStorage.lang = lang;
}
},
setTimeout: function(callback, timeout, skipDouble){
if( Engine.options.doubleTime && !skipDouble ){
Engine.log('Double time, cutting timeout in half');
timeout /= 2;
}
return setTimeout(callback, timeout);
}
};
function eventNullifier(e) {
+8 -8
View File
@@ -113,7 +113,7 @@ var Events = {
}
// Set up the enemy attack timer
Events._enemyAttackTimer = setTimeout(Events.enemyAttack, scene.attackDelay * 1000);
Events._enemyAttackTimer = Engine.setTimeout(Events.enemyAttack, scene.attackDelay * 1000);
},
createEatMeatButton: function(cooldown) {
@@ -354,7 +354,7 @@ var Events = {
if(dmg == 'stun') {
msg = _('stunned');
enemy.data('stunned', true);
setTimeout(function() {
Engine.setTimeout(function() {
enemy.data('stunned', false);
}, Events.STUN_DURATION);
}
@@ -399,7 +399,7 @@ var Events = {
if(dmg == 'stun') {
msg = _('stunned');
enemy.data('stunned', true);
setTimeout(function() {
Engine.setTimeout(function() {
enemy.data('stunned', false);
}, Events.STUN_DURATION);
}
@@ -438,14 +438,14 @@ var Events = {
});
}
Events._enemyAttackTimer = setTimeout(Events.enemyAttack, scene.attackDelay * 1000);
Events._enemyAttackTimer = Engine.setTimeout(Events.enemyAttack, scene.attackDelay * 1000);
},
winFight: function() {
Events.won = true;
clearTimeout(Events._enemyAttackTimer);
$('#enemy').animate({opacity: 0}, 300, 'linear', function() {
setTimeout(function() {
Engine.setTimeout(function() {
try {
var scene = Events.activeEvent().scenes[Events.activeScene];
var desc = $('#description', Events.eventPanel());
@@ -482,7 +482,7 @@ var Events = {
} catch(e) {
// It is possible to die and win if the timing is perfect. Just let it fail.
}
}, 1000);
}, 1000, true);
});
},
@@ -742,7 +742,7 @@ var Events = {
// every 3 seconds change title to '*** EVENT ***', then 1.5 seconds later, change it back to the original title.
Events.BLINK_INTERVAL = setInterval(function() {
document.title = _('*** EVENT ***');
setTimeout(function() {document.title = title;}, 1500);
Engine.setTimeout(function() {document.title = title;}, 1500, true);
}, 3000);
},
@@ -824,7 +824,7 @@ var Events = {
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; }
Engine.log('next event scheduled in ' + nextEvent + ' minutes');
Events._eventTimeout = setTimeout(Events.triggerEvent, nextEvent * 60 * 1000);
Events._eventTimeout = Engine.setTimeout(Events.triggerEvent, nextEvent * 60 * 1000);
},
endEvent: function() {
+4 -4
View File
@@ -295,7 +295,7 @@ Events.Room = [
],
onLoad: function() {
if(Math.random() < 0.5) {
setTimeout(function() {
Engine.setTimeout(function() {
$SM.add('stores.wood', 300);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
}, 60 * 1000);
@@ -314,7 +314,7 @@ Events.Room = [
],
onLoad: function() {
if(Math.random() < 0.3) {
setTimeout(function() {
Engine.setTimeout(function() {
$SM.add('stores.wood', 1500);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
}, 60 * 1000);
@@ -366,7 +366,7 @@ Events.Room = [
],
onLoad: function() {
if(Math.random() < 0.5) {
setTimeout(function() {
Engine.setTimeout(function() {
$SM.add('stores.fur', 300);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
}, 60 * 1000);
@@ -385,7 +385,7 @@ Events.Room = [
],
onLoad: function() {
if(Math.random() < 0.3) {
setTimeout(function() {
Engine.setTimeout(function() {
$SM.add('stores.fur', 1500);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
}, 60 * 1000);
+1 -1
View File
@@ -220,7 +220,7 @@ var Outside = {
schedulePopIncrease: function() {
var nextIncrease = Math.floor(Math.random()*(Outside._POP_DELAY[1] - Outside._POP_DELAY[0])) + Outside._POP_DELAY[0];
Engine.log('next population increase scheduled in ' + nextIncrease + ' minutes');
Outside._popTimeout = setTimeout(Outside.increasePopulation, nextIncrease * 60 * 1000);
Outside._popTimeout = Engine.setTimeout(Outside.increasePopulation, nextIncrease * 60 * 1000);
},
updateWorkersView: function() {
+11 -11
View File
@@ -521,8 +521,8 @@ var Room = {
Room.updateIncomeView();
Room.updateBuildButtons();
Room._fireTimer = setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
Room._tempTimer = setTimeout(Room.adjustTemp, Room._ROOM_WARM_DELAY);
Room._fireTimer = Engine.setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
Room._tempTimer = Engine.setTimeout(Room.adjustTemp, Room._ROOM_WARM_DELAY);
/*
* Builder states:
@@ -533,12 +533,12 @@ var Room = {
* 4 - Helping
*/
if($SM.get('game.builder.level') >= 0 && $SM.get('game.builder.level') < 3) {
Room._builderTimer = setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
Room._builderTimer = Engine.setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
}
if($SM.get('game.builder.level') == 1 && $SM.get('stores.wood', true) < 0) {
setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
Engine.setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
}
setTimeout($SM.collectIncome, 1000);
Engine.setTimeout($SM.collectIncome, 1000);
Notifications.notify(Room, _("the room is {0}", Room.TempEnum.fromInt($SM.get('game.temperature.value')).text));
Notifications.notify(Room, _("the fire is {0}", Room.FireEnum.fromInt($SM.get('game.fire.value')).text));
@@ -671,10 +671,10 @@ var Room = {
if($SM.get('game.fire.value') > 1 && $SM.get('game.builder.level') < 0) {
$SM.set('game.builder.level', 0);
Notifications.notify(Room, _("the light from the fire spills from the windows, out into the dark"));
setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
Engine.setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
}
window.clearTimeout(Room._fireTimer);
Room._fireTimer = setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
Room._fireTimer = Engine.setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
Room.updateButton();
Room.setTitle();
},
@@ -689,7 +689,7 @@ var Room = {
}
if($SM.get('game.fire.value') > 0) {
$SM.set('game.fire',Room.FireEnum.fromInt($SM.get('game.fire.value') - 1));
Room._fireTimer = setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
Room._fireTimer = Engine.setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
Room.onFireChange();
}
},
@@ -707,7 +707,7 @@ var Room = {
if($SM.get('game.temperature.value') != old) {
Room.changed = true;
}
Room._tempTimer = setTimeout(Room.adjustTemp, Room._ROOM_WARM_DELAY);
Room._tempTimer = Engine.setTimeout(Room.adjustTemp, Room._ROOM_WARM_DELAY);
},
unlockForest: function() {
@@ -723,7 +723,7 @@ var Room = {
if(lBuilder === 0) {
Notifications.notify(Room, _("a ragged stranger stumbles through the door and collapses in the corner"));
lBuilder = $SM.setget('game.builder.level', 1);
setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
Engine.setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
}
else if(lBuilder < 3 && $SM.get('game.temperature.value') >= Room.TempEnum.Warm.value) {
var msg = "";
@@ -741,7 +741,7 @@ var Room = {
}
}
if(lBuilder < 3) {
setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
Engine.setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
}
Engine.saveGame();
},
+5 -5
View File
@@ -166,7 +166,7 @@ var Space = {
}
if(!Space.done) {
setTimeout(Space.createAsteroid, 1000 - (Space.altitude * 10));
Engine.setTimeout(Space.createAsteroid, 1000 - (Space.altitude * 10));
}
}
},
@@ -261,7 +261,7 @@ var Space = {
}
}, 1000);
Space._panelTimeout = setTimeout(function() {
Space._panelTimeout = Engine.setTimeout(function() {
if (Engine.isLightsOff())
$('#spacePanel, .menu, select.menuBtn').animate({color: '#272823'}, 500, 'linear');
else
@@ -315,7 +315,7 @@ var Space = {
left: left
}).appendTo(el2);
if(num < Space.NUM_STARS) {
setTimeout(function() { Space.drawStarAsync(el, el2, num + 1); }, 100);
Engine.setTimeout(function() { Space.drawStarAsync(el, el2, num + 1); }, 100);
}
},
@@ -385,7 +385,7 @@ var Space = {
top: '350px',
left: '240px'
}, 3000, 'linear', function() {
setTimeout(function() {
Engine.setTimeout(function() {
Space.ship.animate({
top: '-100px'
}, 200, 'linear', function() {
@@ -393,7 +393,7 @@ var Space = {
$('#outerSlider').css({'left': '0px', 'top': '0px'});
$('#locationSlider, #worldPanel, #spacePanel, #notifications').remove();
$('#header').empty();
setTimeout(function() {
Engine.setTimeout(function() {
$('body').stop();
var container_color;
if (Engine.isLightsOff())
+2 -2
View File
@@ -818,12 +818,12 @@ var World = {
Engine.activeModule = Room;
$('div.headerButton').removeClass('selected');
Room.tab.addClass('selected');
setTimeout(function(){
Engine.setTimeout(function(){
Room.onArrival();
$('#outerSlider').animate({opacity:'1'}, 600, 'linear');
Button.cooldown($('#embarkButton'));
Engine.keyLock = false;
}, 2000);
}, 2000, true);
});
}
},