Check for delayed events

This triggers onload for all those events whose (possible) reward is registered with a time delay.
This commit is contained in:
Andrea Rendine
2015-05-09 02:17:42 +02:00
committed by Blake Grotewold
parent cb717b41d0
commit da0d39b579
4 changed files with 126 additions and 34 deletions
+44 -28
View File
@@ -273,15 +273,15 @@ Events.Room = [
notification: _('a mysterious wanderer arrives'),
blink: true,
buttons: {
'100wood': {
'wood100': {
text: _('give 100'),
cost: {wood: 100},
nextScene: { 1: '100wood'}
nextScene: { 1: 'wood100'}
},
'500wood': {
'wood500': {
text: _('give 500'),
cost: {wood: 500},
nextScene: { 1: '500wood' }
nextScene: { 1: 'wood500' }
},
'deny': {
text: _('turn him away'),
@@ -289,16 +289,20 @@ Events.Room = [
}
}
},
'100wood': {
'wood100': {
text: [
_('the wanderer leaves, cart loaded with wood')
],
action: function(delay) {
var delay = delay || false;
Events.saveDelay(function() {
$SM.add('stores.wood', 300);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
}, 'Room[4].scenes.wood100.action', delay);
},
onLoad: function() {
if(Math.random() < 0.5) {
Engine.setTimeout(function() {
$SM.add('stores.wood', 300);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
}, 60 * 1000);
this.action(60);
}
},
buttons: {
@@ -308,16 +312,20 @@ Events.Room = [
}
}
},
'500wood': {
'wood500': {
text: [
_('the wanderer leaves, cart loaded with wood')
],
action: function(delay) {
var delay = delay || false;
Events.saveDelay(function() {
$SM.add('stores.wood', 1500);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
}, 'Room[4].scenes.wood500.action', delay);
},
onLoad: function() {
if(Math.random() < 0.3) {
Engine.setTimeout(function() {
$SM.add('stores.wood', 1500);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
}, 60 * 1000);
this.action(60);
}
},
buttons: {
@@ -344,15 +352,15 @@ Events.Room = [
notification: _('a mysterious wanderer arrives'),
blink: true,
buttons: {
'100fur': {
'fur100': {
text: _('give 100'),
cost: {fur: 100},
nextScene: { 1: '100fur'}
nextScene: { 1: 'fur100'}
},
'500fur': {
'fur500': {
text: _('give 500'),
cost: {fur: 500},
nextScene: { 1: '500fur' }
nextScene: { 1: 'fur500' }
},
'deny': {
text: _('turn her away'),
@@ -360,16 +368,20 @@ Events.Room = [
}
}
},
'100fur': {
'fur100': {
text: [
_('the wanderer leaves, cart loaded with furs')
],
action: function(delay) {
var delay = delay || false;
Events.saveDelay(function() {
$SM.add('stores.wood', 300);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
}, 'Room[5].scenes.fur100.action', delay);
},
onLoad: function() {
if(Math.random() < 0.5) {
Engine.setTimeout(function() {
$SM.add('stores.fur', 300);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
}, 60 * 1000);
this.action(60);
}
},
buttons: {
@@ -379,16 +391,20 @@ Events.Room = [
}
}
},
'500fur': {
'fur500': {
text: [
_('the wanderer leaves, cart loaded with furs')
],
action: function(delay) {
var delay = delay || false;
Events.saveDelay(function() {
$SM.add('stores.wood', 1500);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
}, 'Room[5].scenes.fur500.action', delay);
},
onLoad: function() {
if(Math.random() < 0.3) {
Engine.setTimeout(function() {
$SM.add('stores.fur', 1500);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
}, 60 * 1000);
this.action(60);
}
},
buttons: {