').attr('id', 'drop_' + k.replace(' ', '-'))
- .text(_(k) + ' x' + numToDrop)
- .data('thing', k)
- .data('num', numToDrop)
- .click(Events.dropStuff);
- dropRow.appendTo(dropMenu);
- }
- }
+ if(!skipButtonSet){
+ Events.setTakeAll();
}
- dropMenu.appendTo(btn);
- btn.one("mouseleave", function() {
- $('#dropMenu').remove();
- });
}
+ if(!skipButtonSet){
+ Events.drawDrop(btn);
+ }
+ }
+ },
+
+ takeAll: function(btn){
+ var target = $('#'+ btn.attr('id').substring(4));
+ for(var k = 0; k < btn.data('numLeft'); k++){
+ Events.getLoot(target, true);
+ }
+ Events.setTakeAll();
+ },
+
+ takeEverything: function(btn){
+ $('#lootButtons').children('.lootRow').each(function(i){
+ var target = $(this).children('.lootTakeAll').first();
+ if(!target.hasClass('disabled')){
+ Events.takeAll(target);
+ }
+ });
+ if(btn.data('canLeave')){
+ btn.data('leaveBtn').click();
}
},
@@ -642,6 +752,7 @@ var Events = {
startStory: function(scene) {
// Write the text
var desc = $('#description', Events.eventPanel());
+ var leaveBtn = false;
for(var i in scene.text) {
$('
').text(scene.text[i]).appendTo(desc);
}
@@ -651,19 +762,23 @@ var Events = {
if(scene.readonly) {
ta.attr('readonly', true);
}
+ Engine.autoSelect('#description textarea');
}
// Draw any loot
if(scene.loot) {
- Events.drawLoot(scene.loot);
+ var takeETbtn = Events.drawLoot(scene.loot);
}
// Draw the buttons
- Events.drawButtons(scene);
+ leaveBtn = Events.drawButtons(scene);
+
+ Events.allowLeave(takeETbtn, leaveBtn);
},
drawButtons: function(scene) {
var btns = $('#buttons', Events.eventPanel());
+ var btnsList = [];
for(var id in scene.buttons) {
var info = scene.buttons[id];
var b = new Button.Button({
@@ -679,9 +794,11 @@ var Events = {
if(typeof info.cooldown == 'number') {
Button.cooldown(b);
}
+ btnsList.push(b);
}
Events.updateButtons();
+ return (btnsList.length == 1) ? btnsList[0] : false;
},
updateButtons: function() {
@@ -837,6 +954,7 @@ var Events = {
if(event) {
Engine.event('game event', 'event');
Engine.keyLock = true;
+ Engine.tabNavigation = false;
Events.eventStack.unshift(event);
event.eventPanel = $('
').attr('id', 'event').addClass('eventPanel').css('opacity', '0');
if(options != null && options.width != null) {
@@ -869,6 +987,7 @@ var Events = {
Events.eventStack.shift();
Engine.log(Events.eventStack.length + ' events remaining');
Engine.keyLock = false;
+ Engine.tabNavigation = true;
if (Events.BLINK_INTERVAL) {
Events.stopTitleBlink();
}
@@ -881,5 +1000,49 @@ var Events = {
if((e.category == 'stores' || e.category == 'income') && Events.activeEvent() != null){
Events.updateButtons();
}
+ },
+
+ initDelay: function(){
+ if($SM.get(Events.delayState)){
+ Events.recallDelay(Events.delayState, Events);
+ }
+ },
+
+ recallDelay: function(stateName, target){
+ var state = $SM.get(stateName);
+ for(var i in state){
+ if(typeof(state[i]) == 'object'){
+ Events.recallDelay(stateName +'["'+ i +'"]', target[i]);
+ } else {
+ if(typeof target[i] == 'function'){
+ target[i]();
+ } else {
+ $SM.remove(stateName)
+ }
+ }
+ }
+ if($.isEmptyObject(state)){
+ $SM.remove(stateName);
+ }
+ },
+
+ saveDelay: function(action, stateName, delay){
+ var state = Events.delayState + '.' + stateName;
+ if(delay){
+ $SM.set(state, delay);
+ } else {
+ var delay = $SM.get(state, true)
+ }
+ var time = Engine.setInterval(function(){
+ // update state every half second
+ $SM.set(state, ($SM.get(state) - 0.5), true);
+ }, 500);
+ Engine.setTimeout(function(){
+ // outcome realizes. erase countdown
+ window.clearInterval(time);
+ $SM.remove(state);
+ $SM.removeBranch(Events.delayState);
+ action();
+ }, delay * 1000);
}
};
diff --git a/script/events/encounters.js b/script/events/encounters.js
index 936dfeb..c5e165f 100644
--- a/script/events/encounters.js
+++ b/script/events/encounters.js
@@ -123,8 +123,8 @@ Events.Encounters = [
scenes: {
'start': {
combat: true,
- enemy: 'shivering man',
- enemyName: _('shivering man'),
+ enemy: 'shivering man',
+ enemyName: _('shivering man'),
deathMessage: _('the shivering man is dead'),
chara: 'E',
damage: 5,
@@ -165,8 +165,8 @@ Events.Encounters = [
scenes: {
'start': {
combat: true,
- enemy: 'man-eater',
- enemyName: _('man-eater'),
+ enemy: 'man-eater',
+ enemyName: _('man-eater'),
deathMessage: _('the man-eater is dead'),
chara: 'T',
damage: 3,
@@ -202,8 +202,8 @@ Events.Encounters = [
scenes: {
'start': {
combat: true,
- enemy: 'scavenger',
- enemyName: _('scavenger'),
+ enemy: 'scavenger',
+ enemyName: _('scavenger'),
deathMessage: _('the scavenger is dead'),
chara: 'E',
damage: 4,
@@ -244,8 +244,8 @@ Events.Encounters = [
scenes: {
'start': {
combat: true,
- enemy: 'lizard',
- enemyName: _('lizard'),
+ enemy: 'lizard',
+ enemyName: _('lizard'),
deathMessage: _('the lizard is dead'),
chara: 'T',
damage: 5,
@@ -282,8 +282,8 @@ Events.Encounters = [
scenes: {
'start': {
combat: true,
- enemy: 'feral terror',
- enemyName: _('feral terror'),
+ enemy: 'feral terror',
+ enemyName: _('feral terror'),
deathMessage: _('the feral terror is dead'),
chara: 'T',
damage: 6,
@@ -319,8 +319,8 @@ Events.Encounters = [
scenes: {
'start': {
combat: true,
- enemy: 'soldier',
- enemyName: _('soldier'),
+ enemy: 'soldier',
+ enemyName: _('soldier'),
deathMessage: _('the soldier is dead'),
ranged: true,
chara: 'D',
@@ -362,8 +362,8 @@ Events.Encounters = [
scenes: {
'start': {
combat: true,
- enemy: 'sniper',
- enemyName: _('sniper'),
+ enemy: 'sniper',
+ enemyName: _('sniper'),
deathMessage: _('the sniper is dead'),
chara: 'D',
damage: 15,
diff --git a/script/events/outside.js b/script/events/outside.js
index c2baeb1..d54a1c4 100644
--- a/script/events/outside.js
+++ b/script/events/outside.js
@@ -37,6 +37,7 @@ Events.Outside = [
_('the tracks disappear after just a few minutes.'),
_('the forest is silent.')
],
+ notification: _('nothing was found'),
buttons: {
'end': {
text: _('go home'),
@@ -49,6 +50,7 @@ Events.Outside = [
_('not far from the village lies a large beast, its fur matted with blood.'),
_('it puts up little resistance before the knife.')
],
+ notification: _('there was a beast. it\'s dead now'),
reward: {
fur: 100,
meat: 100,
@@ -63,7 +65,7 @@ Events.Outside = [
}
}
},
- {
+ { /* Hut fire */
title: _('Fire'),
isAvailable: function() {
return Engine.activeModule == Outside && $SM.get('game.buildings["hut"]', true) > 0 && $SM.get('game.population', true) > 5;
@@ -77,10 +79,7 @@ Events.Outside = [
notification: _('a fire has started'),
blink: true,
onLoad: function() {
- var population = $SM.get('game.population', true);
- var huts = $SM.get('game.buildings["hut"]', true);
- $SM.set('game.buildings["hut"]', (huts - 1));
- Outside.killVillagers(4);
+ Outside.destroyHuts(1);
},
buttons: {
'mourn': {
@@ -103,7 +102,7 @@ Events.Outside = [
_('a sickness is spreading through the village.'),
_('medicine is needed immediately.')
],
-
+ notification: _('some villagers are ill'),
blink: true,
buttons: {
'heal': {
@@ -121,6 +120,7 @@ Events.Outside = [
text: [
_('the sickness is cured in time.')
],
+ notification: _('sufferers are healed'),
buttons: {
'end': {
text: _('go home'),
@@ -134,8 +134,9 @@ Events.Outside = [
_('the days are spent with burials.'),
_('the nights are rent with screams.')
],
+ notification: _('sufferers are left to die'),
onLoad: function() {
- var numKilled = Math.floor(Math.random() * 20) + 1;
+ var numKilled = Math.floor(Math.random() * Math.floor($SM.get('game.population', true)/2)) + 1;
Outside.killVillagers(numKilled);
},
buttons: {
@@ -159,6 +160,7 @@ Events.Outside = [
_('a terrible plague is fast spreading through the village.'),
_('medicine is needed immediately.')
],
+ notification: _('a plague afflicts the village'),
blink: true,
buttons: {
/* Because there is a serious need for medicine, the price is raised. */
@@ -185,6 +187,7 @@ Events.Outside = [
_('only a few die.'),
_('the rest bury them.')
],
+ notification: _('epidemic is eradicated eventually'),
onLoad: function() {
var numKilled = Math.floor(Math.random() * 5) + 2;
Outside.killVillagers(numKilled);
@@ -202,6 +205,7 @@ Events.Outside = [
_('the nights are rent with screams.'),
_('the only hope is a quick death.')
],
+ notification: _('population is almost exterminated'),
onLoad: function() {
var numKilled = Math.floor(Math.random() * 80) + 10;
Outside.killVillagers(numKilled);
@@ -228,6 +232,7 @@ Events.Outside = [
_('the fight is short and bloody, but the beasts are repelled.'),
_('the villagers retreat to mourn the dead.')
],
+ notification: _('wild beasts attack the villagers'),
onLoad: function() {
var numKilled = Math.floor(Math.random() * 10) + 1;
Outside.killVillagers(numKilled);
@@ -241,6 +246,7 @@ Events.Outside = [
buttons: {
'end': {
text: _('go home'),
+ notification: _('predators become prey. price is unfair'),
nextScene: 'end'
}
}
@@ -260,6 +266,7 @@ Events.Outside = [
_('well armed men charge out of the forest, firing into the crowd.'),
_('after a skirmish they are driven away, but not without losses.')
],
+ notification: _('troops storm the village'),
onLoad: function() {
var numKilled = Math.floor(Math.random() * 40) + 1;
Outside.killVillagers(numKilled);
@@ -273,6 +280,7 @@ Events.Outside = [
buttons: {
'end': {
text: _('go home'),
+ notification: _('warfare is bloodthirsty'),
nextScene: 'end'
}
}
diff --git a/script/events/room.js b/script/events/room.js
index a3d98ce..82635f9 100644
--- a/script/events/room.js
+++ b/script/events/room.js
@@ -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: {
diff --git a/script/localization.js b/script/localization.js
index 81c07c7..dd1aa9d 100644
--- a/script/localization.js
+++ b/script/localization.js
@@ -66,19 +66,4 @@
];
delete keywords;
-
- //translate text in css by overriding attributes
- $("