Merge pull request #102 from anubisthejackle/whitespace-fixes

Covert whitespace to tabs as per coding standard
This commit is contained in:
Blake Grotewold
2014-07-17 19:25:45 -04:00
15 changed files with 2261 additions and 2203 deletions
+100 -100
View File
@@ -6,136 +6,136 @@
**/ **/
var Base64 = { var Base64 = {
// private property // private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding // public method for encoding
encode : function (input) { encode : function (input) {
var output = ""; var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0; var i = 0;
input = Base64._utf8_encode(input); input = Base64._utf8_encode(input);
while (i < input.length) { while (i < input.length) {
chr1 = input.charCodeAt(i++); chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2; enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63; enc4 = chr3 & 63;
if (isNaN(chr2)) { if (isNaN(chr2)) {
enc3 = enc4 = 64; enc3 = enc4 = 64;
} else if (isNaN(chr3)) { } else if (isNaN(chr3)) {
enc4 = 64; enc4 = 64;
} }
output = output + output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
} }
return output; return output;
}, },
// public method for decoding // public method for decoding
decode : function (input) { decode : function (input) {
var output = ""; var output = "";
var chr1, chr2, chr3; var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4; var enc1, enc2, enc3, enc4;
var i = 0; var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) { while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++)); enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4); chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4; chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1); output = output + String.fromCharCode(chr1);
if (enc3 != 64) { if (enc3 != 64) {
output = output + String.fromCharCode(chr2); output = output + String.fromCharCode(chr2);
} }
if (enc4 != 64) { if (enc4 != 64) {
output = output + String.fromCharCode(chr3); output = output + String.fromCharCode(chr3);
} }
} }
output = Base64._utf8_decode(output); output = Base64._utf8_decode(output);
return output;
return output; },
}, // private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
// private method for UTF-8 encoding for (var n = 0; n < string.length; n++) {
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n);
var c = string.charCodeAt(n); if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
if (c < 128) { }
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
} return utftext;
},
return utftext; // private method for UTF-8 decoding
}, _utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
// private method for UTF-8 decoding while ( i < utftext.length ) {
_utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) { c = utftext.charCodeAt(i);
c = utftext.charCodeAt(i); if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
if (c < 128) { }
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
} return string;
}
return string;
} }
}
+256 -235
View File
@@ -114,10 +114,10 @@
.appendTo('body'); .appendTo('body');
if(typeof langs != 'undefined'){ if(typeof langs != 'undefined'){
var selectWrap = $('<span>') var selectWrap = $('<span>')
.addClass('select-wrap') .addClass('select-wrap')
.appendTo(menu); .appendTo(menu);
var select = $('<select>') var select = $('<select>')
.addClass('menuBtn') .addClass('menuBtn')
.append($('<option>').text("language.")) .append($('<option>').text("language."))
.change(Engine.switchLanguage) .change(Engine.switchLanguage)
@@ -127,9 +127,8 @@
$('<option>').text(display).val(name).appendTo(select) $('<option>').text(display).val(name).appendTo(select)
}); });
} }
$('<span>')
$('<span>')
.addClass('lightsOff menuBtn') .addClass('lightsOff menuBtn')
.text(_('lights off.')) .text(_('lights off.'))
.click(Engine.turnLightsOff) .click(Engine.turnLightsOff)
@@ -146,7 +145,7 @@
.text(_('share.')) .text(_('share.'))
.click(Engine.share) .click(Engine.share)
.appendTo(menu); .appendTo(menu);
$('<span>') $('<span>')
.addClass('menuBtn') .addClass('menuBtn')
.text(_('save.')) .text(_('save.'))
@@ -204,14 +203,11 @@
}, },
browserValid: function() { browserValid: function() {
return location.search.indexOf('ignorebrowser=true') >= 0 || ( return ( location.search.indexOf( 'ignorebrowser=true' ) >= 0 || ( typeof Storage != 'undefined' && !oldIE ) );
typeof Storage != 'undefined' &&
!oldIE);
}, },
isMobile: function() { isMobile: function() {
return location.search.indexOf('ignorebrowser=true') < 0 && return ( location.search.indexOf( 'ignorebrowser=true' ) < 0 && /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test( navigator.userAgent ) );
/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
}, },
saveGame: function() { saveGame: function() {
@@ -242,111 +238,133 @@
} }
}, },
exportImport: function() { exportImport: function() {
Events.startEvent({ Events.startEvent({
title: _('Export / Import'), title: _('Export / Import'),
scenes: { scenes: {
start: { start: {
text: [_('export or import save data, for backing up'), text: [
_('or migrating computers')], _('export or import save data, for backing up'),
buttons: { _('or migrating computers')
'export': { ],
text: _('export'), buttons: {
onChoose: Engine.export64 'export': {
text: _('export'),
onChoose: Engine.export64
},
'import': {
text: _('import'),
nextScene: {1: 'confirm'},
},
'cancel': {
text: _('cancel'),
nextScene: 'end'
}
}, },
'import': { 'confirm': {
text: _('import'), text: [
nextScene: {1: 'confirm'}, _('are you sure?'),
_('if the code is invalid, all data will be lost.'),
_('this is irreversible.')
],
buttons: {
'yes': {
text: _('yes'),
nextScene: {1: 'inputImport'},
onChoose: Engine.enableSelection
},
'no': {
text: _('no'),
nextScene: 'end'
}
}
}, },
'cancel': { 'inputImport': {
text: _('cancel'), text: [
nextScene: 'end' _('put the save code here.')
],
textarea: '',
buttons: {
'okay': {
text: _('import'),
nextScene: 'end',
onChoose: Engine.import64
},
'cancel': {
text: _('cancel'),
nextScene: 'end'
}
}
} }
} },
}, 'inputImport': {
'confirm': { text: [_('put the save code here.')],
text: [_('are you sure?'), textarea: '',
_('if the code is invalid, all data will be lost.'), buttons: {
_('this is irreversible.')], 'okay': {
buttons: { text: _('import'),
'yes': { nextScene: 'end',
text: _('yes'), onChoose: Engine.import64
nextScene: {1: 'inputImport'}, },
onChoose: Engine.enableSelection 'cancel': {
}, text: _('cancel'),
'no': { nextScene: 'end'
text: _('no'), }
nextScene: 'end'
}
}
},
'inputImport': {
text: [_('put the save code here.')],
textarea: '',
buttons: {
'okay': {
text: _('import'),
nextScene: 'end',
onChoose: Engine.import64
},
'cancel': {
text: _('cancel'),
nextScene: 'end'
} }
} }
} }
} });
}); },
},
generateExport64: function(){ generateExport64: function(){
var string64 = Base64.encode(localStorage.gameState); var string64 = Base64.encode(localStorage.gameState);
string64 = string64.replace(/\s/g, ''); string64 = string64.replace(/\s/g, '');
string64 = string64.replace(/\./g, ''); string64 = string64.replace(/\./g, '');
string64 = string64.replace(/\n/g, ''); string64 = string64.replace(/\n/g, '');
return string64;
},
export64: function() {
Engine.saveGame();
var string64 = Engine.generateExport64();
Engine.enableSelection();
Events.startEvent({
title: _('Export'),
scenes: {
start: {
text: [_('save this.')],
textarea: string64,
buttons: {
'done': {
text: _('got it'),
nextScene: 'end',
onChoose: Engine.disableSelection
}
}
}
}
});
Engine.autoSelect('#description textarea')
},
import64: function(string64) {
Engine.disableSelection();
string64 = string64.replace(/\s/g, '');
string64 = string64.replace(/\./g, '');
string64 = string64.replace(/\n/g, '');
var decodedSave = Base64.decode(string64);
localStorage.gameState = decodedSave;
location.reload();
},
return string64;
},
export64: function() {
Engine.saveGame();
var string64 = Engine.generateExport64();
Engine.enableSelection();
Events.startEvent({
title: _('Export'),
scenes: {
start: {
text: [_('save this.')],
textarea: string64,
buttons: {
'done': {
text: _('got it'),
nextScene: 'end',
onChoose: Engine.disableSelection
}
}
}
}
});
Engine.autoSelect('#description textarea')
},
import64: function(string64) {
Engine.disableSelection();
string64 = string64.replace(/\s/g, '');
string64 = string64.replace(/\./g, '');
string64 = string64.replace(/\n/g, '');
var decodedSave = Base64.decode(string64);
localStorage.gameState = decodedSave;
location.reload();
},
event: function(cat, act) { event: function(cat, act) {
if(typeof ga === 'function') { if(typeof ga === 'function') {
ga('send', 'event', cat, act); ga('send', 'event', cat, act);
} }
}, },
confirmDelete: function() { confirmDelete: function() {
Events.startEvent({ Events.startEvent({
title: _('Restart?'), title: _('Restart?'),
@@ -368,19 +386,19 @@
} }
}); });
}, },
deleteSave: function(noReload) { deleteSave: function(noReload) {
if(typeof Storage != 'undefined' && localStorage) { if(typeof Storage != 'undefined' && localStorage) {
var prestige = Prestige.get(); var prestige = Prestige.get();
window.State = {}; window.State = {};
localStorage.clear(); localStorage.clear();
Prestige.set(prestige); Prestige.set(prestige);
} }
if(!noReload) { if(!noReload) {
location.reload(); location.reload();
} }
}, },
share: function() { share: function() {
Events.startEvent({ Events.startEvent({
title: _('Share'), title: _('Share'),
@@ -404,17 +422,17 @@
}, },
'twitter': { 'twitter': {
text: _('twitter'), text: _('twitter'),
nextScene: 'end',
onChoose: function() { onChoose: function() {
window.open('https://twitter.com/intent/tweet?text=A%20Dark%20Room&url=' + Engine.SITE_URL, 'sharer', 'width=660,height=260,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no'); window.open('https://twitter.com/intent/tweet?text=A%20Dark%20Room&url=' + Engine.SITE_URL, 'sharer', 'width=660,height=260,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no');
}, }
nextScene: 'end'
}, },
'reddit': { 'reddit': {
text: _('reddit'), text: _('reddit'),
nextScene: 'end',
onChoose: function() { onChoose: function() {
window.open('http://www.reddit.com/submit?url=' + Engine.SITE_URL, 'sharer', 'width=960,height=700,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no'); window.open('http://www.reddit.com/submit?url=' + Engine.SITE_URL, 'sharer', 'width=960,height=700,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no');
}, }
nextScene: 'end'
}, },
'close': { 'close': {
text: _('close'), text: _('close'),
@@ -423,78 +441,77 @@
} }
} }
} }
}, {width: '400px'}); },
{
width: '400px'
});
},
findStylesheet: function(title) {
for(var i=0; i<document.styleSheets.length; i++) {
var sheet = document.styleSheets[i];
if(sheet.title == title) {
return sheet;
}
}
return null;
},
isLightsOff: function() {
var darkCss = Engine.findStylesheet('darkenLights');
if ( darkCss != null && !darkCss.disabled ) {
return true;
}
return false;
}, },
findStylesheet: function(title) { turnLightsOff: function() {
for(var i=0; i<document.styleSheets.length; i++) { var darkCss = Engine.findStylesheet('darkenLights');
var sheet = document.styleSheets[i]; if (darkCss == null) {
if(sheet.title == title) { $('head').append('<link rel="stylesheet" href="css/dark.css" type="text/css" title="darkenLights" />');
return sheet; Engine.turnLightsOff;
} $('.lightsOff').text(_('lights on.'));
} } else if (darkCss.disabled) {
return null; darkCss.disabled = false;
}, $('.lightsOff').text(_('lights on.'));
} else {
$("#darkenLights").attr("disabled", "disabled");
darkCss.disabled = true;
$('.lightsOff').text(_('lights off.'));
}
},
isLightsOff: function() {
var darkCss = Engine.findStylesheet('darkenLights');
if (darkCss != null) {
if (darkCss.disabled)
return false;
return true;
}
return false;
},
turnLightsOff: function() {
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;
$('.lightsOff').text(_('lights on.'));
}
else {
$("#darkenLights").attr("disabled", "disabled");
darkCss.disabled = true;
$('.lightsOff').text(_('lights off.'));
}
},
// Gets a guid // Gets a guid
getGuid: function() { getGuid: function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16); return v.toString(16);
}); });
}, },
activeModule: null, activeModule: null,
travelTo: function(module) { travelTo: function(module) {
if(Engine.activeModule != module) { if(Engine.activeModule != module) {
var currentIndex = Engine.activeModule ? $('.location').index(Engine.activeModule.panel) : 1; var currentIndex = Engine.activeModule ? $('.location').index(Engine.activeModule.panel) : 1;
$('div.headerButton').removeClass('selected'); $('div.headerButton').removeClass('selected');
module.tab.addClass('selected'); module.tab.addClass('selected');
var slider = $('#locationSlider'); var slider = $('#locationSlider');
var stores = $('#storesContainer'); var stores = $('#storesContainer');
var panelIndex = $('.location').index(module.panel); var panelIndex = $('.location').index(module.panel);
var diff = Math.abs(panelIndex - currentIndex); var diff = Math.abs(panelIndex - currentIndex);
slider.animate({left: -(panelIndex * 700) + 'px'}, 300 * diff); 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...? // FIXME Why does this work if there's an animation queue...?
stores.animate({right: -(panelIndex * 700) + 'px'}, 300 * diff); stores.animate({right: -(panelIndex * 700) + 'px'}, 300 * diff);
} }
Engine.activeModule = module; Engine.activeModule = module;
module.onArrival(diff); module.onArrival(diff);
if(Engine.activeModule == Room || Engine.activeModule == Path) { if(Engine.activeModule == Room || Engine.activeModule == Path) {
// Don't fade out the weapons if we're switching to a module // Don't fade out the weapons if we're switching to a module
// where we're going to keep showing them anyway. // where we're going to keep showing them anyway.
@@ -502,28 +519,28 @@
$('div#weapons').animate({opacity: 0}, 300); $('div#weapons').animate({opacity: 0}, 300);
} }
} }
if(module == Room || module == Path) { if(module == Room || module == Path) {
$('div#weapons').animate({opacity: 1}, 300); $('div#weapons').animate({opacity: 1}, 300);
} }
Notifications.printQueue(module); Notifications.printQueue(module);
} }
}, },
// Move the stores panel beneath top_container (or to top: 0px if top_container /* Move the stores panel beneath top_container (or to top: 0px if top_container
// either hasn't been filled in or is null) using transition_diff to sync with * either hasn't been filled in or is null) using transition_diff to sync with
// the animation in Engine.travelTo(). * the animation in Engine.travelTo().
*/
moveStoresView: function(top_container, transition_diff) { moveStoresView: function(top_container, transition_diff) {
var stores = $('#storesContainer'); var stores = $('#storesContainer');
// If we don't have a storesContainer yet, leave. // If we don't have a storesContainer yet, leave.
if(typeof(stores) === 'undefined') return; if(typeof(stores) === 'undefined') return;
if(typeof(transition_diff) === 'undefined') transition_diff = 1; if(typeof(transition_diff) === 'undefined') transition_diff = 1;
if(top_container === null) { if(top_container === null) {
stores.animate({top: '0px'}, {queue: false, duration: 300 * transition_diff}); stores.animate({top: '0px'}, {queue: false, duration: 300 * transition_diff});
} }
@@ -531,32 +548,37 @@
stores.animate({top: '0px'}, {queue: false, duration: 300 * transition_diff}); stores.animate({top: '0px'}, {queue: false, duration: 300 * transition_diff});
} }
else { else {
stores.animate({top: top_container.height() + 26 + 'px'}, stores.animate({
{queue: false, duration: 300 * transition_diff}); top: top_container.height() + 26 + 'px'
},
{
queue: false,
duration: 300 * transition_diff
});
} }
}, },
log: function(msg) { log: function(msg) {
if(this._log) { if(this._log) {
console.log(msg); console.log(msg);
} }
}, },
updateSlider: function() { updateSlider: function() {
var slider = $('#locationSlider'); var slider = $('#locationSlider');
slider.width((slider.children().length * 700) + 'px'); slider.width((slider.children().length * 700) + 'px');
}, },
updateOuterSlider: function() { updateOuterSlider: function() {
var slider = $('#outerSlider'); var slider = $('#outerSlider');
slider.width((slider.children().length * 700) + 'px'); slider.width((slider.children().length * 700) + 'px');
}, },
getIncomeMsg: function(num, delay) { getIncomeMsg: function(num, delay) {
return _("{0} per {1}s", (num > 0 ? "+" : "") + num, delay); return _("{0} per {1}s", (num > 0 ? "+" : "") + num, delay);
//return (num > 0 ? "+" : "") + num + " per " + delay + "s"; //return (num > 0 ? "+" : "") + num + " per " + delay + "s";
}, },
keyDown: function(e) { keyDown: function(e) {
if(!Engine.keyPressed && !Engine.keyLock) { if(!Engine.keyPressed && !Engine.keyLock) {
Engine.pressed = true; Engine.pressed = true;
@@ -566,91 +588,91 @@
} }
return !(jQuery.inArray(window.event.keycode, [37,38,39,40])); return !(jQuery.inArray(window.event.keycode, [37,38,39,40]));
}, },
keyUp: function(e) { keyUp: function(e) {
Engine.pressed = false; Engine.pressed = false;
if(Engine.activeModule.keyUp) { if(Engine.activeModule.keyUp) {
Engine.activeModule.keyUp(e); Engine.activeModule.keyUp(e);
} }
else else
{ {
switch(e.which) { switch(e.which) {
case 38: // Up case 38: // Up
case 87: case 87:
Engine.log('up'); Engine.log('up');
break; break;
case 40: // Down case 40: // Down
case 83: case 83:
Engine.log('down'); Engine.log('down');
break; break;
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;
} }
} }
return false; return false;
}, },
swipeLeft: function(e) { swipeLeft: function(e) {
if(Engine.activeModule.swipeLeft) { if(Engine.activeModule.swipeLeft) {
Engine.activeModule.swipeLeft(e); Engine.activeModule.swipeLeft(e);
} }
}, },
swipeRight: function(e) { swipeRight: function(e) {
if(Engine.activeModule.swipeRight) { if(Engine.activeModule.swipeRight) {
Engine.activeModule.swipeRight(e); Engine.activeModule.swipeRight(e);
} }
}, },
swipeUp: function(e) { swipeUp: function(e) {
if(Engine.activeModule.swipeUp) { if(Engine.activeModule.swipeUp) {
Engine.activeModule.swipeUp(e); Engine.activeModule.swipeUp(e);
} }
}, },
swipeDown: function(e) { swipeDown: function(e) {
if(Engine.activeModule.swipeDown) { if(Engine.activeModule.swipeDown) {
Engine.activeModule.swipeDown(e); Engine.activeModule.swipeDown(e);
} }
}, },
disableSelection: function() { disableSelection: function() {
document.onselectstart = eventNullifier; // this is for IE document.onselectstart = eventNullifier; // this is for IE
document.onmousedown = eventNullifier; // this is for the rest document.onmousedown = eventNullifier; // this is for the rest
}, },
enableSelection: function() { enableSelection: function() {
document.onselectstart = eventPassthrough; document.onselectstart = eventPassthrough;
document.onmousedown = eventPassthrough; document.onmousedown = eventPassthrough;
}, },
autoSelect: function(selector) { autoSelect: function(selector) {
$(selector).focus().select(); $(selector).focus().select();
}, },
handleStateUpdates: function(e){ handleStateUpdates: function(e){
},
},
switchLanguage: function(dom){ switchLanguage: function(dom){
var lang = $(this).val(); var lang = $(this).val();
if(document.location.href.search(/[\?\&]lang=[a-z]+/) != -1){ if(document.location.href.search(/[\?\&]lang=[a-z]+/) != -1){
@@ -659,7 +681,7 @@
document.location.href = document.location.href + ( (document.location.href.search(/\?/) != -1 )?"&":"?") + "lang="+lang; document.location.href = document.location.href + ( (document.location.href.search(/\?/) != -1 )?"&":"?") + "lang="+lang;
} }
}, },
saveLanguage: function(){ saveLanguage: function(){
var lang = decodeURIComponent((new RegExp('[?|&]lang=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null; var lang = decodeURIComponent((new RegExp('[?|&]lang=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
if(lang && typeof Storage != 'undefined' && localStorage) { if(lang && typeof Storage != 'undefined' && localStorage) {
@@ -667,21 +689,20 @@
} }
} }
}; };
function eventNullifier(e) { function eventNullifier(e) {
return $(e.target).hasClass('menuBtn'); return $(e.target).hasClass('menuBtn');
} }
function eventPassthrough(e) { function eventPassthrough(e) {
return true; return true;
} }
})(); })();
//create jQuery Callbacks() to handle object events //create jQuery Callbacks() to handle object events
$.Dispatch = function( id ) { $.Dispatch = function( id ) {
var callbacks, var callbacks, topic = id && Engine.topics[ id ];
topic = id && Engine.topics[ id ];
if ( !topic ) { if ( !topic ) {
callbacks = jQuery.Callbacks(); callbacks = jQuery.Callbacks();
topic = { topic = {
+58 -59
View File
@@ -109,8 +109,8 @@ var Events = {
Events.createEatMeatButton().appendTo(btns); Events.createEatMeatButton().appendTo(btns);
if((Path.outfit['medicine'] || 0) != 0) { if((Path.outfit['medicine'] || 0) != 0) {
Events.createUseMedsButton().appendTo(btns); Events.createUseMedsButton().appendTo(btns);
} }
// Set up the enemy attack timer // Set up the enemy attack timer
Events._enemyAttackTimer = setTimeout(Events.enemyAttack, scene.attackDelay * 1000); Events._enemyAttackTimer = setTimeout(Events.enemyAttack, scene.attackDelay * 1000);
@@ -438,8 +438,7 @@ var Events = {
}); });
} }
Events._enemyAttackTimer = Events._enemyAttackTimer = setTimeout(Events.enemyAttack, scene.attackDelay * 1000);
setTimeout(Events.enemyAttack, scene.attackDelay * 1000);
}, },
winFight: function() { winFight: function() {
@@ -476,8 +475,8 @@ var Events = {
Events.createEatMeatButton(0).appendTo(btns); Events.createEatMeatButton(0).appendTo(btns);
if((Path.outfit['medicine'] || 0) != 0) { if((Path.outfit['medicine'] || 0) != 0) {
Events.createUseMedsButton(0).appendTo(btns); Events.createUseMedsButton(0).appendTo(btns);
} }
} }
} catch(e) { } catch(e) {
// It is possible to die and win if the timing is perfect. Just let it fail. // It is possible to die and win if the timing is perfect. Just let it fail.
@@ -728,41 +727,41 @@ var Events = {
} }
}, },
// Makes an event happen! // Makes an event happen!
triggerEvent: function() { triggerEvent: function() {
if(Events.activeEvent() == null) { if(Events.activeEvent() == null) {
var possibleEvents = []; var possibleEvents = [];
for(var i in Events.EventPool) { for(var i in Events.EventPool) {
var event = Events.EventPool[i]; var event = Events.EventPool[i];
if(event.isAvailable()) { if(event.isAvailable()) {
possibleEvents.push(event); possibleEvents.push(event);
} }
} }
if(possibleEvents.length == 0) { if(possibleEvents.length == 0) {
Events.scheduleNextEvent(0.5); Events.scheduleNextEvent(0.5);
return; return;
} else { } else {
var r = Math.floor(Math.random()*(possibleEvents.length)); var r = Math.floor(Math.random()*(possibleEvents.length));
Events.startEvent(possibleEvents[r]); Events.startEvent(possibleEvents[r]);
} }
} }
Events.scheduleNextEvent(); Events.scheduleNextEvent();
}, },
triggerFight: function() { triggerFight: function() {
var possibleFights = []; var possibleFights = [];
for(var i in Events.Encounters) { for(var i in Events.Encounters) {
var fight = Events.Encounters[i]; var fight = Events.Encounters[i];
if(fight.isAvailable()) { if(fight.isAvailable()) {
possibleFights.push(fight); possibleFights.push(fight);
} }
} }
var r = Math.floor(Math.random()*(possibleFights.length)); var r = Math.floor(Math.random()*(possibleFights.length));
Events.startEvent(possibleFights[r]); Events.startEvent(possibleFights[r]);
}, },
activeEvent: function() { activeEvent: function() {
if(Events.eventStack && Events.eventStack.length > 0) { if(Events.eventStack && Events.eventStack.length > 0) {
@@ -774,8 +773,8 @@ var Events = {
eventPanel: function() { eventPanel: function() {
return Events.activeEvent().eventPanel; return Events.activeEvent().eventPanel;
}, },
startEvent: function(event, options) { startEvent: function(event, options) {
if(event) { if(event) {
Engine.event('game event', 'event'); Engine.event('game event', 'event');
Engine.keyLock = true; Engine.keyLock = true;
@@ -791,30 +790,30 @@ var Events = {
$('div#wrapper').append(Events.eventPanel()); $('div#wrapper').append(Events.eventPanel());
Events.eventPanel().animate({opacity: 1}, Events._PANEL_FADE, 'linear'); Events.eventPanel().animate({opacity: 1}, Events._PANEL_FADE, 'linear');
} }
}, },
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);
}, },
endEvent: function() { endEvent: function() {
Events.eventPanel().animate({opacity:0}, Events._PANEL_FADE, 'linear', function() { Events.eventPanel().animate({opacity:0}, Events._PANEL_FADE, 'linear', function() {
Events.eventPanel().remove(); Events.eventPanel().remove();
Events.activeEvent().eventPanel = null; Events.activeEvent().eventPanel = null;
Events.eventStack.shift(); Events.eventStack.shift();
Engine.log(Events.eventStack.length + ' events remaining'); Engine.log(Events.eventStack.length + ' events remaining');
Engine.keyLock = false; Engine.keyLock = false;
// Force refocus on the body. I hate you, IE. // Force refocus on the body. I hate you, IE.
$('body').focus(); $('body').focus();
}); });
}, },
handleStateUpdates: function(e){ handleStateUpdates: function(e){
if(e.category == 'stores' && Events.activeEvent() != null){ if(e.category == 'stores' && Events.activeEvent() != null){
Events.updateButtons(); Events.updateButtons();
} }
} }
}; };
+367 -367
View File
@@ -5,396 +5,396 @@ Events.Encounters = [
/* Tier 1 */ /* Tier 1 */
{ /* Snarling Beast */ { /* Snarling Beast */
title: _('A Snarling Beast'), title: _('A Snarling Beast'),
isAvailable: function() { isAvailable: function() {
return World.getDistance() <= 10 && World.getTerrain() == World.TILE.FOREST; return World.getDistance() <= 10 && World.getTerrain() == World.TILE.FOREST;
}, },
scenes: { scenes: {
'start': { 'start': {
combat: true, combat: true,
enemy: 'snarling beast', enemy: 'snarling beast',
enemyName: _('snarling beast'), enemyName: _('snarling beast'),
deathMessage: _('the snarling beast is dead'), deathMessage: _('the snarling beast is dead'),
chara: 'B', chara: 'B',
damage: 1, damage: 1,
hit: 0.8, hit: 0.8,
attackDelay: 1, attackDelay: 1,
health: 5, health: 5,
loot: { loot: {
'fur': { 'fur': {
min: 1, min: 1,
max: 3, max: 3,
chance: 1 chance: 1
}, },
'meat': { 'meat': {
min: 1, min: 1,
max: 3, max: 3,
chance: 1 chance: 1
}, },
'teeth': { 'teeth': {
min: 1, min: 1,
max: 3, max: 3,
chance: 0.8 chance: 0.8
} }
}, },
notification: _('a snarling beast leaps out of the underbrush') notification: _('a snarling beast leaps out of the underbrush')
} }
} }
}, },
{ /* Gaunt Man */ { /* Gaunt Man */
title: _('A Gaunt Man'), title: _('A Gaunt Man'),
isAvailable: function() { isAvailable: function() {
return World.getDistance() <= 10 && World.getTerrain() == World.TILE.BARRENS; return World.getDistance() <= 10 && World.getTerrain() == World.TILE.BARRENS;
}, },
scenes: { scenes: {
'start': { 'start': {
combat: true, combat: true,
enemy: 'gaunt man', enemy: 'gaunt man',
enemyName: _('gaunt man'), enemyName: _('gaunt man'),
deathMessage: _('the gaunt man is dead'), deathMessage: _('the gaunt man is dead'),
chara: 'G', chara: 'G',
damage: 2, damage: 2,
hit: 0.8, hit: 0.8,
attackDelay: 2, attackDelay: 2,
health: 6, health: 6,
loot: { loot: {
'cloth': { 'cloth': {
min: 1, min: 1,
max: 3, max: 3,
chance: 0.8 chance: 0.8
}, },
'teeth': { 'teeth': {
min: 1, min: 1,
max: 2, max: 2,
chance: 0.8 chance: 0.8
}, },
'leather': { 'leather': {
min: 1, min: 1,
max: 2, max: 2,
chance: 0.5 chance: 0.5
} }
}, },
notification: _('a gaunt man approaches, a crazed look in his eye') notification: _('a gaunt man approaches, a crazed look in his eye')
} }
} }
}, },
{ /* Strange Bird */ { /* Strange Bird */
title: _('A Strange Bird'), title: _('A Strange Bird'),
isAvailable: function() { isAvailable: function() {
return World.getDistance() <= 10 && World.getTerrain() == World.TILE.FIELD; return World.getDistance() <= 10 && World.getTerrain() == World.TILE.FIELD;
}, },
scenes: { scenes: {
'start': { 'start': {
combat: true, combat: true,
enemy: 'strange bird', enemy: 'strange bird',
enemyName: _('strange bird'), enemyName: _('strange bird'),
deathMessage: _('the strange bird is dead'), deathMessage: _('the strange bird is dead'),
chara: 'B', chara: 'B',
damage: 3, damage: 3,
hit: 0.8, hit: 0.8,
attackDelay: 2, attackDelay: 2,
health: 4, health: 4,
loot: { loot: {
'scales': { 'scales': {
min: 1, min: 1,
max: 3, max: 3,
chance: 0.8 chance: 0.8
}, },
'teeth': { 'teeth': {
min: 1, min: 1,
max: 2, max: 2,
chance: 0.5 chance: 0.5
}, },
'meat': { 'meat': {
min: 1, min: 1,
max: 3, max: 3,
chance: 0.8 chance: 0.8
} }
}, },
notification: _('a strange looking bird speeds across the plains') notification: _('a strange looking bird speeds across the plains')
} }
} }
}, },
/* Tier 2*/ /* Tier 2*/
{ /* Shivering Man */ { /* Shivering Man */
title: _('A Shivering Man'), title: _('A Shivering Man'),
isAvailable: function() { isAvailable: function() {
return World.getDistance() > 10 && World.getDistance() <= 20 && World.getTerrain() == World.TILE.BARRENS; return World.getDistance() > 10 && World.getDistance() <= 20 && World.getTerrain() == World.TILE.BARRENS;
}, },
scenes: { scenes: {
'start': { 'start': {
combat: true, combat: true,
enemy: 'shivering man', enemy: 'shivering man',
enemyName: _('shivering man'), enemyName: _('shivering man'),
deathMessage: _('the shivering man is dead'), deathMessage: _('the shivering man is dead'),
chara: 'S', chara: 'S',
damage: 5, damage: 5,
hit: 0.5, hit: 0.5,
attackDelay: 1, attackDelay: 1,
health: 20, health: 20,
loot: { loot: {
'cloth': { 'cloth': {
min: 1, min: 1,
max: 1, max: 1,
chance: 0.2 chance: 0.2
}, },
'teeth': { 'teeth': {
min: 1, min: 1,
max: 2, max: 2,
chance: 0.8 chance: 0.8
}, },
'leather': { 'leather': {
min: 1, min: 1,
max: 1, max: 1,
chance: 0.2 chance: 0.2
}, },
'medicine': { 'medicine': {
min: 1, min: 1,
max: 3, max: 3,
chance: 0.7 chance: 0.7
} }
}, },
notification: _('a shivering man approaches and attacks with surprising strength') notification: _('a shivering man approaches and attacks with surprising strength')
} }
} }
}, },
{ /* Man-eater */ { /* Man-eater */
title: _('A Man-Eater'), title: _('A Man-Eater'),
isAvailable: function() { isAvailable: function() {
return World.getDistance() > 10 && World.getDistance() <= 20 && World.getTerrain() == World.TILE.FOREST; return World.getDistance() > 10 && World.getDistance() <= 20 && World.getTerrain() == World.TILE.FOREST;
}, },
scenes: { scenes: {
'start': { 'start': {
combat: true, combat: true,
enemy: 'man-eater', enemy: 'man-eater',
enemyName: _('man-eater'), enemyName: _('man-eater'),
deathMessage: _('the man-eater is dead'), deathMessage: _('the man-eater is dead'),
chara: 'E', chara: 'E',
damage: 3, damage: 3,
hit: 0.8, hit: 0.8,
attackDelay: 1, attackDelay: 1,
health: 25, health: 25,
loot: { loot: {
'fur': { 'fur': {
min: 5, min: 5,
max: 10, max: 10,
chance: 1 chance: 1
}, },
'meat': { 'meat': {
min: 5, min: 5,
max: 10, max: 10,
chance: 1 chance: 1
}, },
'teeth': { 'teeth': {
min: 5, min: 5,
max: 10, max: 10,
chance: 0.8 chance: 0.8
} }
}, },
notification: _('a large creature attacks, claws freshly bloodied') notification: _('a large creature attacks, claws freshly bloodied')
} }
} }
}, },
{ /* Scavenger */ { /* Scavenger */
title: _('A Scavenger'), title: _('A Scavenger'),
isAvailable: function() { isAvailable: function() {
return World.getDistance() > 10 && World.getDistance() <= 20 && World.getTerrain() == World.TILE.BARRENS; return World.getDistance() > 10 && World.getDistance() <= 20 && World.getTerrain() == World.TILE.BARRENS;
}, },
scenes: { scenes: {
'start': { 'start': {
combat: true, combat: true,
enemy: 'scavenger', enemy: 'scavenger',
enemyName: _('scavenger'), enemyName: _('scavenger'),
deathMessage: _('the scavenger is dead'), deathMessage: _('the scavenger is dead'),
chara: 'S', chara: 'S',
damage: 4, damage: 4,
hit: 0.8, hit: 0.8,
attackDelay: 2, attackDelay: 2,
health: 30, health: 30,
loot: { loot: {
'cloth': { 'cloth': {
min: 5, min: 5,
max: 10, max: 10,
chance: 0.8 chance: 0.8
}, },
'leather': { 'leather': {
min: 5, min: 5,
max: 10, max: 10,
chance: 0.8 chance: 0.8
}, },
'iron': { 'iron': {
min: 1, min: 1,
max: 5, max: 5,
chance: 0.5 chance: 0.5
}, },
'medicine': { 'medicine': {
min: 1, min: 1,
max: 2, max: 2,
chance: 0.1 chance: 0.1
} }
}, },
notification: _('a scavenger draws close, hoping for an easy score') notification: _('a scavenger draws close, hoping for an easy score')
} }
} }
}, },
{ /* Huge Lizard */ { /* Huge Lizard */
title: _('A Huge Lizard'), title: _('A Huge Lizard'),
isAvailable: function() { isAvailable: function() {
return World.getDistance() > 10 && World.getDistance() <= 20 && World.getTerrain() == World.TILE.FIELD; return World.getDistance() > 10 && World.getDistance() <= 20 && World.getTerrain() == World.TILE.FIELD;
}, },
scenes: { scenes: {
'start': { 'start': {
combat: true, combat: true,
enemy: 'lizard', enemy: 'lizard',
enemyName: _('lizard'), enemyName: _('lizard'),
deathMessage: _('the lizard is dead'), deathMessage: _('the lizard is dead'),
chara: 'L', chara: 'L',
damage: 5, damage: 5,
hit: 0.8, hit: 0.8,
attackDelay: 2, attackDelay: 2,
health: 20, health: 20,
loot: { loot: {
'scales': { 'scales': {
min: 5, min: 5,
max: 10, max: 10,
chance: 0.8 chance: 0.8
}, },
'teeth': { 'teeth': {
min: 5, min: 5,
max: 10, max: 10,
chance: 0.5 chance: 0.5
}, },
'meat': { 'meat': {
min: 5, min: 5,
max: 10, max: 10,
chance: 0.8 chance: 0.8
} }
}, },
notification: _('the grass thrashes wildly as a huge lizard pushes through') notification: _('the grass thrashes wildly as a huge lizard pushes through')
} }
} }
}, },
/* Tier 3*/ /* Tier 3*/
{ /* Feral Terror */ { /* Feral Terror */
title: _('A Feral Terror'), title: _('A Feral Terror'),
isAvailable: function() { isAvailable: function() {
return World.getDistance() > 20 && World.getTerrain() == World.TILE.FOREST; return World.getDistance() > 20 && World.getTerrain() == World.TILE.FOREST;
}, },
scenes: { scenes: {
'start': { 'start': {
combat: true, combat: true,
enemy: 'feral terror', enemy: 'feral terror',
enemyName: _('feral terror'), enemyName: _('feral terror'),
deathMessage: _('the feral terror is dead'), deathMessage: _('the feral terror is dead'),
chara: 'F', chara: 'F',
damage: 6, damage: 6,
hit: 0.8, hit: 0.8,
attackDelay: 1, attackDelay: 1,
health: 45, health: 45,
loot: { loot: {
'fur': { 'fur': {
min: 5, min: 5,
max: 10, max: 10,
chance: 1 chance: 1
}, },
'meat': { 'meat': {
min: 5, min: 5,
max: 10, max: 10,
chance: 1 chance: 1
}, },
'teeth': { 'teeth': {
min: 5, min: 5,
max: 10, max: 10,
chance: 0.8 chance: 0.8
} }
}, },
notification: _('a beast, wilder than imagining, erupts out of the foliage') notification: _('a beast, wilder than imagining, erupts out of the foliage')
} }
} }
}, },
{ /* Soldier */ { /* Soldier */
title: _('A Soldier'), title: _('A Soldier'),
isAvailable: function() { isAvailable: function() {
return World.getDistance() > 20 && World.getTerrain() == World.TILE.BARRENS; return World.getDistance() > 20 && World.getTerrain() == World.TILE.BARRENS;
}, },
scenes: { scenes: {
'start': { 'start': {
combat: true, combat: true,
enemy: 'soldier', enemy: 'soldier',
enemyName: _('soldier'), enemyName: _('soldier'),
deathMessage: _('the soldier is dead'), deathMessage: _('the soldier is dead'),
ranged: true, ranged: true,
chara: 'D', chara: 'D',
damage: 8, damage: 8,
hit: 0.8, hit: 0.8,
attackDelay: 2, attackDelay: 2,
health: 50, health: 50,
loot: { loot: {
'cloth': { 'cloth': {
min: 5, min: 5,
max: 10, max: 10,
chance: 0.8 chance: 0.8
}, },
'bullets': { 'bullets': {
min: 1, min: 1,
max: 5, max: 5,
chance: 0.5 chance: 0.5
}, },
'rifle': { 'rifle': {
min: 1, min: 1,
max: 1, max: 1,
chance: 0.2 chance: 0.2
}, },
'medicine': { 'medicine': {
min: 1, min: 1,
max: 2, max: 2,
chance: 0.1 chance: 0.1
} }
}, },
notification: _('a soldier opens fire from across the desert') notification: _('a soldier opens fire from across the desert')
} }
} }
}, },
{ /* Sniper */ { /* Sniper */
title: _('A Sniper'), title: _('A Sniper'),
isAvailable: function() { isAvailable: function() {
return World.getDistance() > 20 && World.getTerrain() == World.TILE.FIELD; return World.getDistance() > 20 && World.getTerrain() == World.TILE.FIELD;
}, },
scenes: { scenes: {
'start': { 'start': {
combat: true, combat: true,
enemy: 'sniper', enemy: 'sniper',
enemyName: _('sniper'), enemyName: _('sniper'),
deathMessage: _('the sniper is dead'), deathMessage: _('the sniper is dead'),
chara: 'S', chara: 'S',
damage: 15, damage: 15,
hit: 0.8, hit: 0.8,
attackDelay: 4, attackDelay: 4,
health: 30, health: 30,
ranged: true, ranged: true,
loot: { loot: {
'cloth': { 'cloth': {
min: 5, min: 5,
max: 10, max: 10,
chance: 0.8 chance: 0.8
}, },
'bullets': { 'bullets': {
min: 1, min: 1,
max: 5, max: 5,
chance: 0.5 chance: 0.5
}, },
'rifle': { 'rifle': {
min: 1, min: 1,
max: 1, max: 1,
chance: 0.2 chance: 0.2
}, },
'medicine': { 'medicine': {
min: 1, min: 1,
max: 2, max: 2,
chance: 0.1 chance: 0.1
} }
}, },
notification: _('a shot rings out, from somewhere in the long grass') notification: _('a shot rings out, from somewhere in the long grass')
} }
} }
} }
]; ];
+24 -24
View File
@@ -28,15 +28,15 @@ Events.Global = [
}, },
'hang': { 'hang': {
text: [ text: [
_('the villagers hang the thief high in front of the store room.'), _('the villagers hang the thief high in front of the store room.'),
_('the point is made. in the next few days, the missing supplies are returned.') _('the point is made. in the next few days, the missing supplies are returned.')
], ],
onLoad: function() { onLoad: function() {
$SM.set('game.thieves', 2); $SM.set('game.thieves', 2);
$SM.remove('income.thieves'); $SM.remove('income.thieves');
$SM.addM('stores', $SM.get('game.stolen')); $SM.addM('stores', $SM.get('game.stolen'));
}, },
buttons: { buttons: {
'leave': { 'leave': {
text: _('leave'), text: _('leave'),
nextScene: 'end' nextScene: 'end'
@@ -45,21 +45,21 @@ Events.Global = [
}, },
'spare': { 'spare': {
text: [ text: [
_("the man says he's grateful. says he won't come around any more."), _("the man says he's grateful. says he won't come around any more."),
_("shares what he knows about sneaking before he goes.") _("shares what he knows about sneaking before he goes.")
], ],
onLoad: function() { onLoad: function() {
$SM.set('game.thieves', 2); $SM.set('game.thieves', 2);
$SM.remove('income.thieves'); $SM.remove('income.thieves');
$SM.addPerk('stealthy'); $SM.addPerk('stealthy');
}, },
buttons: { buttons: {
'leave': { 'leave': {
text: _('leave'), text: _('leave'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
} }
]; ];
+149 -153
View File
@@ -2,8 +2,8 @@
* Events that can occur when the Outside module is active * Events that can occur when the Outside module is active
**/ **/
Events.Outside = [ Events.Outside = [
{ /* Ruined traps */ { /* Ruined traps */
title: _('A Ruined Trap'), title: _('A Ruined Trap'),
isAvailable: function() { isAvailable: function() {
return Engine.activeModule == Outside && $SM.get('game.buildings["trap"]', true) > 0; return Engine.activeModule == Outside && $SM.get('game.buildings["trap"]', true) > 0;
}, },
@@ -45,9 +45,9 @@ Events.Outside = [
}, },
'catch': { 'catch': {
text: [ text: [
_('not far from the village lies a large beast, its fur matted with blood.'), _('not far from the village lies a large beast, its fur matted with blood.'),
_('it puts up little resistance before the knife.') _('it puts up little resistance before the knife.')
], ],
reward: { reward: {
fur: 100, fur: 100,
meat: 100, meat: 100,
@@ -61,147 +61,144 @@ Events.Outside = [
} }
} }
} }
}, },
{ /* Sickness */ { /* Sickness */
title: _('Sickness'), title: _('Sickness'),
isAvailable: function() { isAvailable: function() {
return Engine.activeModule == Outside && return Engine.activeModule == Outside && $SM.get('game.population', true) > 10 && $SM.get('game.population', true) < 50 && $SM.get('stores.medicine', true) > 0;
$SM.get('game.population', true) > 10 && },
$SM.get('game.population', true) < 50 && scenes: {
$SM.get('stores.medicine', true) > 0; 'start': {
}, text: [
scenes: { _('a sickness is spreading through the village.'),
'start': { _('medicine is needed immediately.')
text: [ ],
_('a sickness is spreading through the village.'), buttons: {
_('medicine is needed immediately.') 'heal': {
], text: _('1 medicine'),
buttons: { cost: { 'medicine' : 1 },
'heal': { nextScene: {1: 'healed'}
text: _('1 medicine'), },
cost: { 'medicine' : 1 }, 'ignore': {
nextScene: {1: 'healed'} text: _('ignore it'),
}, nextScene: {1: 'death'}
'ignore': { }
text: _('ignore it'), }
nextScene: {1: 'death'} },
} 'healed': {
} text: [
}, _('the sickness is cured in time.')
'healed': { ],
text: [ buttons: {
_('the sickness is cured in time.') 'end': {
], text: _('go home'),
buttons: { nextScene: 'end'
'end': { }
text: _('go home'), }
nextScene: 'end' },
} 'death': {
} text: [
}, _('the sickness spreads through the village.'),
'death': { _('the days are spent with burials.'),
text: [ _('the nights are rent with screams.')
_('the sickness spreads through the village.'), ],
_('the days are spent with burials.'), onLoad: function() {
_('the nights are rent with screams.') var numKilled = Math.floor(Math.random() * 20) + 1;
], Outside.killVillagers(numKilled);
onLoad: function() { },
var numKilled = Math.floor(Math.random() * 20) + 1; buttons: {
Outside.killVillagers(numKilled); 'end': {
}, text: _('go home'),
buttons: { nextScene: 'end'
'end': { }
text: _('go home'), }
nextScene: 'end' }
} }
} },
}
} { /* Plague */
}, title: _('Plague'),
isAvailable: function() {
{ /* Plague */ return Engine.activeModule == Outside && $SM.get('game.population', true) > 50 && $SM.get('stores.medicine', true) > 0;
title: _('Plague'), },
isAvailable: function() { scenes: {
return Engine.activeModule == Outside && $SM.get('game.population', true) > 50 && $SM.get('stores.medicine', true) > 0; 'start': {
}, text: [
scenes: { _('a terrible plague is fast spreading through the village.'),
'start': { _('medicine is needed immediately.')
text: [ ],
_('a terrible plague is fast spreading through the village.'), buttons: {
_('medicine is needed immediately.') 'heal': {
], text: _('5 medicine'),
buttons: { cost: { 'medicine' : 5 },
'heal': { nextScene: {1: 'healed'}
text: _('5 medicine'), },
cost: { 'medicine' : 5 }, 'ignore': {
nextScene: {1: 'healed'} text: _('do nothing'),
}, nextScene: {1: 'death'}
'ignore': { }
text: _('do nothing'), }
nextScene: {1: 'death'} },
} 'healed': {
} text: [
}, _('the plague is kept from spreading.'),
'healed': { _('only a few die.'),
text: [ _('the rest bury them.')
_('the plague is kept from spreading.'), ],
_('only a few die.'), onLoad: function() {
_('the rest bury them.') var numKilled = Math.floor(Math.random() * 5) + 2;
], Outside.killVillagers(numKilled);
onLoad: function() { },
var numKilled = Math.floor(Math.random() * 5) + 2; buttons: {
Outside.killVillagers(numKilled); 'end': {
}, text: _('go home'),
buttons: { nextScene: 'end'
'end': { }
text: _('go home'), }
nextScene: 'end' },
} 'death': {
} text: [
}, _('the plague rips through the village.'),
'death': { _('the nights are rent with screams.'),
text: [ _('the only hope is a quick death.')
_('the plague rips through the village.'), ],
_('the nights are rent with screams.'), onLoad: function() {
_('the only hope is a quick death.') var numKilled = Math.floor(Math.random() * 80) + 10;
], Outside.killVillagers(numKilled);
onLoad: function() { },
var numKilled = Math.floor(Math.random() * 80) + 10; buttons: {
Outside.killVillagers(numKilled); 'end': {
}, text: _('go home'),
buttons: { nextScene: 'end'
'end': { }
text: _('go home'), }
nextScene: 'end' }
} }
} },
}
} { /* Beast attack */
}, title: _('A Beast Attack'),
{ /* Beast attack */
title: _('A Beast Attack'),
isAvailable: function() { isAvailable: function() {
return Engine.activeModule == Outside && $SM.get('game.population', true) > 0; return Engine.activeModule == Outside && $SM.get('game.population', true) > 0;
}, },
scenes: { scenes: {
'start': { 'start': {
text: [ text: [
_('a pack of snarling beasts pours out of the trees.'), _('a pack of snarling beasts pours out of the trees.'),
_('the fight is short and bloody, but the beasts are repelled.'), _('the fight is short and bloody, but the beasts are repelled.'),
_('the villagers retreat to mourn the dead.') _('the villagers retreat to mourn the dead.')
], ],
onLoad: function() { onLoad: function() {
var numKilled = Math.floor(Math.random() * 10) + 1; var numKilled = Math.floor(Math.random() * 10) + 1;
Outside.killVillagers(numKilled); Outside.killVillagers(numKilled);
}, },
reward: { reward: {
fur: 100, fur: 100,
meat: 100, meat: 100,
teeth: 10 teeth: 10
}, },
buttons: { buttons: {
'end': { 'end': {
text: _('go home'), text: _('go home'),
nextScene: 'end' nextScene: 'end'
@@ -209,29 +206,29 @@ Events.Outside = [
} }
} }
} }
}, },
{ /* Soldier attack */ { /* Soldier attack */
title: _('A Military Raid'), title: _('A Military Raid'),
isAvailable: function() { 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: { scenes: {
'start': { 'start': {
text: [ text: [
_('a gunshot rings through the trees.'), _('a gunshot rings through the trees.'),
_('well armed men charge out of the forest, firing into the crowd.'), _('well armed men charge out of the forest, firing into the crowd.'),
_('after a skirmish they are driven away, but not without losses.') _('after a skirmish they are driven away, but not without losses.')
], ],
onLoad: function() { onLoad: function() {
var numKilled = Math.floor(Math.random() * 40) + 1; var numKilled = Math.floor(Math.random() * 40) + 1;
Outside.killVillagers(numKilled); Outside.killVillagers(numKilled);
}, },
reward: { reward: {
bullets: 10, bullets: 10,
'cured meat': 50 'cured meat': 50
}, },
buttons: { buttons: {
'end': { 'end': {
text: _('go home'), text: _('go home'),
nextScene: 'end' nextScene: 'end'
@@ -239,6 +236,5 @@ Events.Outside = [
} }
} }
} }
} }
]; ];
+275 -275
View File
@@ -106,8 +106,8 @@ Events.Room = [
scenes: { scenes: {
start: { start: {
text: [ text: [
_('scratching noises can be heard from the store room.'), _('scratching noises can be heard from the store room.'),
_('something\'s in there.') _('something\'s in there.')
], ],
notification: _('something\'s in the store room'), notification: _('something\'s in the store room'),
buttons: { buttons: {
@@ -123,63 +123,63 @@ Events.Room = [
}, },
scales: { scales: {
text: [ text: [
_('some wood is missing.'), _('some wood is missing.'),
_('the ground is littered with small scales') _('the ground is littered with small scales')
], ],
onLoad: function() { onLoad: function() {
var numWood = $SM.get('stores.wood', true); var numWood = $SM.get('stores.wood', true);
numWood = Math.floor(numWood * 0.1); numWood = Math.floor(numWood * 0.1);
if(numWood == 0) numWood = 1; if(numWood == 0) numWood = 1;
var numScales = Math.floor(numWood / 5); var numScales = Math.floor(numWood / 5);
if(numScales == 0) numScales = 1; if(numScales == 0) numScales = 1;
$SM.addM('stores', {'wood': -numWood, 'scales': numScales}); $SM.addM('stores', {'wood': -numWood, 'scales': numScales});
}, },
buttons: { buttons: {
'leave': { 'leave': {
text: _('leave'), text: _('leave'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
teeth: { teeth: {
text: [ text: [
_('some wood is missing.'), _('some wood is missing.'),
_('the ground is littered with small teeth') _('the ground is littered with small teeth')
], ],
onLoad: function() { onLoad: function() {
var numWood = $SM.get('stores.wood', true); var numWood = $SM.get('stores.wood', true);
numWood = Math.floor(numWood * 0.1); numWood = Math.floor(numWood * 0.1);
if(numWood == 0) numWood = 1; if(numWood == 0) numWood = 1;
var numTeeth = Math.floor(numWood / 5); var numTeeth = Math.floor(numWood / 5);
if(numTeeth == 0) numTeeth = 1; if(numTeeth == 0) numTeeth = 1;
$SM.addM('stores', {'wood': -numWood, 'teeth': numTeeth}); $SM.addM('stores', {'wood': -numWood, 'teeth': numTeeth});
}, },
buttons: { buttons: {
'leave': { 'leave': {
text: _('leave'), text: _('leave'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
cloth: { cloth: {
text: [ text: [
_('some wood is missing.'), _('some wood is missing.'),
_('the ground is littered with scraps of cloth') _('the ground is littered with scraps of cloth')
], ],
onLoad: function() { onLoad: function() {
var numWood = $SM.get('stores.wood', true); var numWood = $SM.get('stores.wood', true);
numWood = Math.floor(numWood * 0.1); numWood = Math.floor(numWood * 0.1);
if(numWood == 0) numWood = 1; if(numWood == 0) numWood = 1;
var numCloth = Math.floor(numWood / 5); var numCloth = Math.floor(numWood / 5);
if(numCloth == 0) numCloth = 1; if(numCloth == 0) numCloth = 1;
$SM.addM('stores', {'wood': -numWood, 'cloth': numCloth}); $SM.addM('stores', {'wood': -numWood, 'cloth': numCloth});
}, },
buttons: { buttons: {
'leave': { 'leave': {
text: _('leave'), text: _('leave'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}, },
@@ -191,8 +191,8 @@ Events.Room = [
scenes: { scenes: {
start: { start: {
text: [ text: [
_('a beggar arrives.'), _('a beggar arrives.'),
_('asks for any spare furs to keep him warm at night.') _('asks for any spare furs to keep him warm at night.')
], ],
notification: _('a beggar arrives'), notification: _('a beggar arrives'),
buttons: { buttons: {
@@ -215,41 +215,41 @@ Events.Room = [
scales: { scales: {
reward: { scales: 20 }, reward: { scales: 20 },
text: [ text: [
_('the beggar expresses his thanks.'), _('the beggar expresses his thanks.'),
_('leaves a pile of small scales behind.') _('leaves a pile of small scales behind.')
], ],
buttons: { buttons: {
'leave': { 'leave': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
teeth: { teeth: {
reward: { teeth: 20 }, reward: { teeth: 20 },
text: [ text: [
_('the beggar expresses his thanks.'), _('the beggar expresses his thanks.'),
_('leaves a pile of small teeth behind.') _('leaves a pile of small teeth behind.')
], ],
buttons: { buttons: {
'leave': { 'leave': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
cloth: { cloth: {
reward: { cloth: 20 }, reward: { cloth: 20 },
text: [ text: [
_('the beggar expresses his thanks.'), _('the beggar expresses his thanks.'),
_('leaves some scraps of cloth behind.') _('leaves some scraps of cloth behind.')
], ],
buttons: { buttons: {
'leave': { 'leave': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}, },
@@ -262,8 +262,8 @@ Events.Room = [
scenes: { scenes: {
start: { start: {
text: [ text: [
_('a wanderer arrives with an empty cart. says if he leaves with wood, he\'ll be back with more.'), _('a wanderer arrives with an empty cart. says if he leaves with wood, he\'ll be back with more.'),
_("builder's not sure he's to be trusted.") _("builder's not sure he's to be trusted.")
], ],
notification: _('a mysterious wanderer arrives'), notification: _('a mysterious wanderer arrives'),
buttons: { buttons: {
@@ -285,41 +285,41 @@ Events.Room = [
}, },
'100wood': { '100wood': {
text: [ text: [
_('the wanderer leaves, cart loaded with wood') _('the wanderer leaves, cart loaded with wood')
], ],
onLoad: function() { onLoad: function() {
if(Math.random() < 0.5) { if(Math.random() < 0.5) {
setTimeout(function() { setTimeout(function() {
$SM.add('stores.wood', 300); $SM.add('stores.wood', 300);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.')); Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
}, 60 * 1000); }, 60 * 1000);
} }
}, },
buttons: { buttons: {
'leave': { 'leave': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
'500wood': { '500wood': {
text: [ text: [
_('the wanderer leaves, cart loaded with wood') _('the wanderer leaves, cart loaded with wood')
], ],
onLoad: function() { onLoad: function() {
if(Math.random() < 0.3) { if(Math.random() < 0.3) {
setTimeout(function() { setTimeout(function() {
$SM.add('stores.wood', 1500); $SM.add('stores.wood', 1500);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.')); Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with wood.'));
}, 60 * 1000); }, 60 * 1000);
} }
}, },
buttons: { buttons: {
'leave': { 'leave': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}, },
@@ -332,8 +332,8 @@ Events.Room = [
scenes: { scenes: {
start: { start: {
text: [ text: [
_('a wanderer arrives with an empty cart. says if she leaves with furs, she\'ll be back with more.'), _('a wanderer arrives with an empty cart. says if she leaves with furs, she\'ll be back with more.'),
_("builder's not sure she's to be trusted.") _("builder's not sure she's to be trusted.")
], ],
notification: _('a mysterious wanderer arrives'), notification: _('a mysterious wanderer arrives'),
buttons: { buttons: {
@@ -355,41 +355,41 @@ Events.Room = [
}, },
'100fur': { '100fur': {
text: [ text: [
_('the wanderer leaves, cart loaded with furs') _('the wanderer leaves, cart loaded with furs')
], ],
onLoad: function() { onLoad: function() {
if(Math.random() < 0.5) { if(Math.random() < 0.5) {
setTimeout(function() { setTimeout(function() {
$SM.add('stores.fur', 300); $SM.add('stores.fur', 300);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.')); Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
}, 60 * 1000); }, 60 * 1000);
} }
}, },
buttons: { buttons: {
'leave': { 'leave': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
'500fur': { '500fur': {
text: [ text: [
_('the wanderer leaves, cart loaded with furs') _('the wanderer leaves, cart loaded with furs')
], ],
onLoad: function() { onLoad: function() {
if(Math.random() < 0.3) { if(Math.random() < 0.3) {
setTimeout(function() { setTimeout(function() {
$SM.add('stores.fur', 1500); $SM.add('stores.fur', 1500);
Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.')); Notifications.notify(Room, _('the mysterious wanderer returns, cart piled high with furs.'));
}, 60 * 1000); }, 60 * 1000);
} }
}, },
buttons: { buttons: {
'leave': { 'leave': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}, },
@@ -424,9 +424,9 @@ Events.Room = [
} }
}, },
'leave': { 'leave': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
@@ -462,132 +462,132 @@ Events.Room = [
}, },
'agree': { 'agree': {
text: [ text: [
_('in exchange, the wanderer offers his wisdom.') _('in exchange, the wanderer offers his wisdom.')
], ],
buttons: { buttons: {
'evasion': { 'evasion': {
text: _('evasion'), text: _('evasion'),
available: function() { available: function() {
return !$SM.hasPerk('evasive'); return !$SM.hasPerk('evasive');
}, },
onChoose: function() { onChoose: function() {
$SM.addPerk('evasive'); $SM.addPerk('evasive');
}, },
nextScene: 'end' nextScene: 'end'
}, },
'precision': { 'precision': {
text: _('precision'), text: _('precision'),
available: function() { available: function() {
return !$SM.hasPerk('precise'); return !$SM.hasPerk('precise');
}, },
onChoose: function() { onChoose: function() {
$SM.addPerk('precise'); $SM.addPerk('precise');
}, },
nextScene: 'end' nextScene: 'end'
}, },
'force': { 'force': {
text: _('force'), text: _('force'),
available: function() { available: function() {
return !$SM.hasPerk('barbarian'); return !$SM.hasPerk('barbarian');
}, },
onChoose: function() { onChoose: function() {
$SM.addPerk('barbarian'); $SM.addPerk('barbarian');
}, },
nextScene: 'end' nextScene: 'end'
}, },
'nothing': { 'nothing': {
text: _('nothing'), text: _('nothing'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}, },
{ /* The Sick Man */ { /* The Sick Man */
title: _('The Sick Man'), title: _('The Sick Man'),
isAvailable: function() { isAvailable: function() {
return Engine.activeModule == Room && $SM.get('stores.medicine', true) > 0; return Engine.activeModule == Room && $SM.get('stores.medicine', true) > 0;
}, },
scenes: { scenes: {
'start': { 'start': {
text: [ text: [
_("a man hobbles up, coughing."), _("a man hobbles up, coughing."),
_("he begs for medicine.") _("he begs for medicine.")
], ],
notification: _('a sick man hobbles up'), notification: _('a sick man hobbles up'),
buttons: { buttons: {
'help': { 'help': {
text: _('give 1 medicine'), text: _('give 1 medicine'),
cost: { 'medicine': 1 }, cost: { 'medicine': 1 },
notification: _('the man swallows the medicine eagerly'), notification: _('the man swallows the medicine eagerly'),
nextScene: { 0.1: 'alloy', 0.3: 'cells', 0.5: 'scales', 1.0: 'nothing' } nextScene: { 0.1: 'alloy', 0.3: 'cells', 0.5: 'scales', 1.0: 'nothing' }
}, },
'ignore': { 'ignore': {
text: _('tell him to leave'), text: _('tell him to leave'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
'alloy': { 'alloy': {
text: [ text: [
_("the man is thankful."), _("the man is thankful."),
_('he leaves a reward.'), _('he leaves a reward.'),
_('some weird metal he picked up on his travels.') _('some weird metal he picked up on his travels.')
], ],
onLoad: function() { onLoad: function() {
$SM.add('stores["alien alloy"]', 1); $SM.add('stores["alien alloy"]', 1);
}, },
buttons: { buttons: {
'bye': { 'bye': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
'cells': { 'cells': {
text: [ text: [
_("the man is thankful."), _("the man is thankful."),
_('he leaves a reward.'), _('he leaves a reward.'),
_('some weird glowing boxes he picked up on his travels.') _('some weird glowing boxes he picked up on his travels.')
], ],
onLoad: function() { onLoad: function() {
$SM.add('stores["energy cell"]', 3); $SM.add('stores["energy cell"]', 3);
}, },
buttons: { buttons: {
'bye': { 'bye': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
'scales': { 'scales': {
text: [ text: [
_("the man is thankful."), _("the man is thankful."),
_('he leaves a reward.'), _('he leaves a reward.'),
_('all he has are some scales.') _('all he has are some scales.')
], ],
onLoad: function() { onLoad: function() {
$SM.add('stores.scales', 5); $SM.add('stores.scales', 5);
}, },
buttons: { buttons: {
'bye': { 'bye': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
'nothing': { 'nothing': {
text: [ text: [
_("the man expresses his thanks and hobbles off.") _("the man expresses his thanks and hobbles off.")
], ],
buttons: { buttons: {
'bye': { 'bye': {
text: _('say goodbye'), text: _('say goodbye'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
} }
]; ];
+914 -916
View File
File diff suppressed because it is too large Load Diff
+67 -21
View File
@@ -1,29 +1,75 @@
(function(){ (function(){
//only used for poedit to find translatable strings //only used for poedit to find translatable strings
var keywords = [ _('saved.'), _('wood'),_('builder'),_('teeth'),_('meat'),_('fur'), _('alien alloy'), _('bullets'), var keywords = [
_('charm'),_('leather'),_('iron'), _('steel'), _('coal'), _('enegy cell'), _('saved.'),
_('torch'),_('medicine'),_('hunter'),_('trapper'),_('tanner'), _('grenade'), _('bolas'), _('wood'),
_("charcutier"),_('iron miner'),_('coal miner'), _('sulphur miner'), _('armourer'), _('builder'),
_('steelworker'),_('bait'),_('cured meat'), _('scales'), _('compass'), _('laser rifle'), _('teeth'),
_('gatherer'),_('cloth'), _('scales'), _('cured meat'), _('thieves'), _('meat'),
_('not enough fur'), _('not enough wood'), _('not enough coal'), _('not enough iron'), _('not enough steel'), _('baited trap'), _('fur'),
_('not enough scales'),_('not enough cloth'), _('not enough teeth'), _('not enough leather'), _('alien alloy'),
_('the compass points east.'), _('the compass points west.'), _('the compass points north.'), _('the compass points south.'), _('bullets'),
_('the compass points northeast.'), _('the compass points northwest.'), _('the compass points southeast.'), _('the compass points southwest.')]; _('charm'),
_('leather'),
_('iron'),
_('steel'),
_('coal'),
_('enegy cell'),
_('torch'),
_('medicine'),
_('hunter'),
_('trapper'),
_('tanner'),
_('grenade'),
_('bolas'),
_("charcutier"),
_('iron miner'),
_('coal miner'),
_('sulphur miner'), _('armourer'),
_('steelworker'),
_('bait'),
_('cured meat'),
_('scales'),
_('compass'),
_('laser rifle'),
_('gatherer'),
_('cloth'),
_('scales'),
_('cured meat'),
_('thieves'),
_('not enough fur'),
_('not enough wood'),
_('not enough coal'),
_('not enough iron'),
_('not enough steel'),
_('baited trap'),
_('not enough scales'),
_('not enough cloth'), _('not enough teeth'),
_('not enough leather'),
_('the compass points east.'),
_('the compass points west.'),
_('the compass points north.'),
_('the compass points south.'),
_('the compass points northeast.'),
_('the compass points northwest.'),
_('the compass points southeast.'),
_('the compass points southwest.')
];
delete keywords; delete keywords;
//translate text in css by overriding attributes //translate text in css by overriding attributes
$("<style>").text('\ $("<style>").text('\
div#stores:before{ content: \''+ _("stores") + '\'}\ div#stores:before{ content: \''+ _("stores") + '\'}\
div#weapons:before{ content: \''+ _("weapons") + '\'}\ div#weapons:before{ content: \''+ _("weapons") + '\'}\
div#buildBtns:before{ content: \''+ _("build:") + '\'}\ div#buildBtns:before{ content: \''+ _("build:") + '\'}\
div#craftBtns:before{ content: \''+ _("craft:") + '\'}\ div#craftBtns:before{ content: \''+ _("craft:") + '\'}\
div#buyBtns:before{ content: \''+ _("buy:") + '\'}\ div#buyBtns:before{ content: \''+ _("buy:") + '\'}\
div#outfitting:before{ content: \''+ _("supplies:") + '\'}\ div#outfitting:before{ content: \''+ _("supplies:") + '\'}\
div#perks:before{ content: \''+ _("perks:") + '\'}\ div#perks:before{ content: \''+ _("perks:") + '\'}\
div#lootButtons:before { content: \''+ _("take:") + '\'}\ div#lootButtons:before { content: \''+ _("take:") + '\'}\
div#dropMenu:before { content: \''+ _("drop:") + '\'}\ div#dropMenu:before { content: \''+ _("drop:") + '\'}\
div#village.noHuts:before { content: \'' + _("forest") + '\'}\ div#village.noHuts:before { content: \'' + _("forest") + '\'}\
div#village:before { content: \'' + _("village") + '\'}\ div#village:before { content: \'' + _("village") + '\'}\
').appendTo($('head')); ').appendTo($('head'));
})(); })();
+7 -8
View File
@@ -219,8 +219,8 @@ var Outside = {
schedulePopIncrease: function() { schedulePopIncrease: function() {
var nextIncrease = Math.floor(Math.random()*(Outside._POP_DELAY[1] - Outside._POP_DELAY[0])) + Outside._POP_DELAY[0]; 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'); Engine.log('next population increase scheduled in ' + nextIncrease + ' minutes');
Outside._popTimeout = setTimeout(Outside.increasePopulation, nextIncrease * 60 * 1000); Outside._popTimeout = setTimeout(Outside.increasePopulation, nextIncrease * 60 * 1000);
}, },
updateWorkersView: function() { updateWorkersView: function() {
@@ -322,7 +322,7 @@ var Outside = {
$('<span>').text(num).appendTo(val); $('<span>').text(num).appendTo(val);
if(key != 'gatherer') { if(key != 'gatherer') {
$('<div>').addClass('upManyBtn').appendTo(val).click([10], Outside.increaseWorker); $('<div>').addClass('upManyBtn').appendTo(val).click([10], Outside.increaseWorker);
$('<div>').addClass('upBtn').appendTo(val).click([1], Outside.increaseWorker); $('<div>').addClass('upBtn').appendTo(val).click([1], Outside.increaseWorker);
$('<div>').addClass('dnBtn').appendTo(val).click([1], Outside.decreaseWorker); $('<div>').addClass('dnBtn').appendTo(val).click([1], Outside.decreaseWorker);
$('<div>').addClass('dnManyBtn').appendTo(val).click([10], Outside.decreaseWorker); $('<div>').addClass('dnManyBtn').appendTo(val).click([10], Outside.decreaseWorker);
@@ -345,7 +345,7 @@ var Outside = {
increaseWorker: function(btn) { increaseWorker: function(btn) {
var worker = $(this).closest('.workerRow').attr('key'); var worker = $(this).closest('.workerRow').attr('key');
if(Outside.getNumGatherers() > 0) { if(Outside.getNumGatherers() > 0) {
var increaseAmt = Math.min(Outside.getNumGatherers(), btn.data); var increaseAmt = Math.min(Outside.getNumGatherers(), btn.data);
Engine.log('increasing ' + worker + ' by ' + increaseAmt); Engine.log('increasing ' + worker + ' by ' + increaseAmt);
$SM.add('game.workers["'+worker+'"]', increaseAmt); $SM.add('game.workers["'+worker+'"]', increaseAmt);
} }
@@ -354,7 +354,7 @@ var Outside = {
decreaseWorker: function(btn) { decreaseWorker: function(btn) {
var worker = $(this).closest('.workerRow').attr('key'); var worker = $(this).closest('.workerRow').attr('key');
if($SM.get('game.workers["'+worker+'"]') > 0) { if($SM.get('game.workers["'+worker+'"]') > 0) {
var decreaseAmt = Math.min($SM.get('game.workers["'+worker+'"]') || 0, btn.data); var decreaseAmt = Math.min($SM.get('game.workers["'+worker+'"]') || 0, btn.data);
Engine.log('decreasing ' + worker + ' by ' + decreaseAmt); Engine.log('decreasing ' + worker + ' by ' + decreaseAmt);
$SM.add('game.workers["'+worker+'"]', decreaseAmt * -1); $SM.add('game.workers["'+worker+'"]', decreaseAmt * -1);
} }
@@ -604,11 +604,10 @@ var Outside = {
handleStateUpdates: function(e){ handleStateUpdates: function(e){
if(e.category == 'stores'){ if(e.category == 'stores'){
Outside.updateVillage(); Outside.updateVillage();
} else if(e.stateName.indexOf('game.workers') == 0 } else if(e.stateName.indexOf('game.workers') == 0 || e.stateName.indexOf('game.population') == 0){
|| e.stateName.indexOf('game.population') == 0){
Outside.updateVillage(); Outside.updateVillage();
Outside.updateWorkersView(); Outside.updateWorkersView();
Outside.updateVillageIncome(); Outside.updateVillageIncome();
}; };
} }
}; };
+4 -4
View File
@@ -258,15 +258,15 @@ var Path = {
return row; return row;
}, },
increaseSupply: function(btn) { increaseSupply: function(btn) {
var supply = $(this).closest('.outfitRow').attr('key'); var supply = $(this).closest('.outfitRow').attr('key');
Engine.log('increasing ' + supply + ' by up to ' + btn.data); Engine.log('increasing ' + supply + ' by up to ' + btn.data);
var cur = Path.outfit[supply]; var cur = Path.outfit[supply];
cur = typeof cur == 'number' ? cur : 0; cur = typeof cur == 'number' ? cur : 0;
if(Path.getFreeSpace() >= Path.getWeight(supply) && cur < $SM.get('stores["'+supply+'"]', true)) { if(Path.getFreeSpace() >= Path.getWeight(supply) && cur < $SM.get('stores["'+supply+'"]', true)) {
var maxExtraByWeight = Math.floor(Path.getFreeSpace() / Path.getWeight(supply)); var maxExtraByWeight = Math.floor(Path.getFreeSpace() / Path.getWeight(supply));
var maxExtraByStore = $SM.get('stores["'+supply+'"]', true) - cur; var maxExtraByStore = $SM.get('stores["'+supply+'"]', true) - cur;
var maxExtraByBtn = btn.data; var maxExtraByBtn = btn.data;
Path.outfit[supply] = cur + Math.min(maxExtraByBtn, Math.min(maxExtraByWeight, maxExtraByStore)); Path.outfit[supply] = cur + Math.min(maxExtraByBtn, Math.min(maxExtraByWeight, maxExtraByStore));
Path.updateOutfitting(); Path.updateOutfitting();
} }
+4 -4
View File
@@ -450,9 +450,9 @@ var Room = {
}, },
MiscItems: { MiscItems: {
'laser rifle': { 'laser rifle': {
type: 'weapon' type: 'weapon'
} }
}, },
name: _("Room"), name: _("Room"),
@@ -770,7 +770,7 @@ var Room = {
} else if(Room.TradeGoods[k]) { } else if(Room.TradeGoods[k]) {
type = Room.TradeGoods[k].type; type = Room.TradeGoods[k].type;
} else if (Room.MiscItems[k]) { } else if (Room.MiscItems[k]) {
type = Room.MiscItems[k].type; type = Room.MiscItems[k].type;
} }
var location; var location;
+32 -33
View File
@@ -409,39 +409,38 @@ var Space = {
}, },
complete: function() { complete: function() {
Engine.GAME_OVER = true; Engine.GAME_OVER = true;
Score.save();
Score.save(); Prestige.save();
Prestige.save();
$('<center>')
$('<center>') .addClass('centerCont')
.addClass('centerCont') .appendTo('body');
.appendTo('body'); $('<span>')
$('<span>') .addClass('endGame')
.addClass('endGame') .text(_('score for this game: {0}', Score.calculateScore()))
.text(_('score for this game: {0}', Score.calculateScore())) .appendTo('.centerCont')
.appendTo('.centerCont') .animate({opacity:1},1500);
.animate({opacity:1},1500); $('<br />')
$('<br />') .appendTo('.centerCont');
.appendTo('.centerCont'); $('<span>')
$('<span>') .addClass('endGame')
.addClass('endGame') .text(_('total score: {0}', Prestige.get().score))
.text(_('total score: {0}', Prestige.get().score)) .appendTo('.centerCont')
.appendTo('.centerCont') .animate({opacity:1},1500);
.animate({opacity:1},1500); $('<br />')
$('<br />') .appendTo('.centerCont');
.appendTo('.centerCont'); $('<br />')
$('<br />') .appendTo('.centerCont');
.appendTo('.centerCont'); $('#starsContainer').remove();
$('#starsContainer').remove(); $('#content, #notifications').remove();
$('#content, #notifications').remove(); $('<span>')
$('<span>') .addClass('endGame endGameRestart')
.addClass('endGame endGameRestart') .text(_('restart.'))
.text(_('restart.')) .click(Engine.confirmDelete)
.click(Engine.confirmDelete) .appendTo('.centerCont')
.appendTo('.centerCont') .animate({opacity:1},1500);
.animate({opacity:1},1500); Engine.options = {};
Engine.options = {}; Engine.deleteSave(true);
Engine.deleteSave(true);
} }
}); });
}, 2000); }, 2000);
+2 -2
View File
@@ -51,7 +51,7 @@ var StateManager = {
var words = stateName.split(/[.\[\]'"]+/); var words = stateName.split(/[.\[\]'"]+/);
//for some reason there are sometimes empty strings //for some reason there are sometimes empty strings
for (var i = 0; i < words.length; i++) { for (var i = 0; i < words.length; i++) {
if (words[i] == '') { if (words[i] == '') {
words.splice(i, 1); words.splice(i, 1);
i--; i--;
} }
@@ -402,4 +402,4 @@ var StateManager = {
}; };
//alias //alias
var $SM = StateManager; var $SM = StateManager;
+2 -2
View File
@@ -20,7 +20,7 @@ var World = {
BOREHOLE: 'B', BOREHOLE: 'B',
BATTLEFIELD: 'F', BATTLEFIELD: 'F',
SWAMP: 'M', SWAMP: 'M',
CACHE: 'U' CACHE: 'U'
}, },
TILE_PROBS: {}, TILE_PROBS: {},
LANDMARKS: {}, LANDMARKS: {},
@@ -131,7 +131,7 @@ var World = {
// Only add the cache if there is prestige data // Only add the cache if there is prestige data
if($SM.get('previous.stores')) { if($SM.get('previous.stores')) {
World.LANDMARKS[World.TILE.CACHE] = { num: 1, minRadius: 10, maxRadius: World.RADIUS * 1.5, scene: 'cache', label: _('A&nbsp;Destroyed&nbsp;Village')}; World.LANDMARKS[World.TILE.CACHE] = { num: 1, minRadius: 10, maxRadius: World.RADIUS * 1.5, scene: 'cache', label: _('A&nbsp;Destroyed&nbsp;Village')};
} }
if(typeof $SM.get('features.location.world') == 'undefined') { if(typeof $SM.get('features.location.world') == 'undefined') {