Merging updates

This commit is contained in:
Travis Weston
2015-02-11 18:55:27 -05:00
parent 7c978f4f15
commit 6ee6470972
10 changed files with 6063 additions and 6063 deletions
+740 -740
View File
File diff suppressed because it is too large Load Diff
+850 -850
View File
File diff suppressed because it is too large Load Diff
+282 -282
View File
@@ -1,282 +1,282 @@
/** /**
* 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;
}, },
scenes: { scenes: {
'start': { 'start': {
text: [ text: [
_('some of the traps have been torn apart.'), _('some of the traps have been torn apart.'),
_('large prints lead away, into the forest.') _('large prints lead away, into the forest.')
], ],
onLoad: function() { onLoad: function() {
var numWrecked = Math.floor(Math.random() * $SM.get('game.buildings["trap"]', true)) + 1; var numWrecked = Math.floor(Math.random() * $SM.get('game.buildings["trap"]', true)) + 1;
$SM.add('game.buildings["trap"]', -numWrecked); $SM.add('game.buildings["trap"]', -numWrecked);
Outside.updateVillage(); Outside.updateVillage();
Outside.updateTrapButton(); Outside.updateTrapButton();
}, },
notification: _('some traps have been destroyed'), notification: _('some traps have been destroyed'),
blink: true, blink: true,
buttons: { buttons: {
'track': { 'track': {
text: _('track them'), text: _('track them'),
nextScene: {0.5: 'nothing', 1: 'catch'} nextScene: {0.5: 'nothing', 1: 'catch'}
}, },
'ignore': { 'ignore': {
text: _('ignore them'), text: _('ignore them'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
'nothing': { 'nothing': {
text: [ text: [
_('the tracks disappear after just a few minutes.'), _('the tracks disappear after just a few minutes.'),
_('the forest is silent.') _('the forest is silent.')
], ],
buttons: { buttons: {
'end': { 'end': {
text: _('go home'), text: _('go home'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
'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,
teeth: 10 teeth: 10
}, },
buttons: { buttons: {
'end': { 'end': {
text: _('go home'), text: _('go home'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}, },
{ {
title: _('Fire'), title: _('Fire'),
isAvailable: function() { isAvailable: function() {
return Engine.activeModule == Outside && $SM.get('game.buildings["hut"]', true) > 0 && $SM.get('game.population', true) > 5; return Engine.activeModule == Outside && $SM.get('game.buildings["hut"]', true) > 0 && $SM.get('game.population', true) > 5;
}, },
scenes: { scenes: {
'start': { 'start': {
text: [ text: [
_('a fire rampages through one of the huts, destroying it.'), _('a fire rampages through one of the huts, destroying it.'),
_('all residents in the hut perished in the fire.') _('all residents in the hut perished in the fire.')
], ],
notification: _('a fire has started'), notification: _('a fire has started'),
blink: true, blink: true,
onLoad: function() { onLoad: function() {
var population = $SM.get('game.population', true); var population = $SM.get('game.population', true);
var huts = $SM.get('game.buildings["hut"]', true); var huts = $SM.get('game.buildings["hut"]', true);
$SM.set('game.buildings["hut"]', (huts - 1)); $SM.set('game.buildings["hut"]', (huts - 1));
$SM.set('game.population', (population - 4)); $SM.set('game.population', (population - 4));
}, },
buttons: { buttons: {
'mourn': { 'mourn': {
text: _('mourn'), text: _('mourn'),
notification: _('some villagers have died'), notification: _('some villagers have died'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}, },
{ /* Sickness */ { /* Sickness */
title: _('Sickness'), title: _('Sickness'),
isAvailable: function() { isAvailable: function() {
return Engine.activeModule == Outside && $SM.get('game.population', true) > 10 && $SM.get('game.population', true) < 50 && $SM.get('stores.medicine', true) > 0; return Engine.activeModule == Outside && $SM.get('game.population', true) > 10 && $SM.get('game.population', true) < 50 && $SM.get('stores.medicine', true) > 0;
}, },
scenes: { scenes: {
'start': { 'start': {
text: [ text: [
_('a sickness is spreading through the village.'), _('a sickness is spreading through the village.'),
_('medicine is needed immediately.') _('medicine is needed immediately.')
], ],
blink: true, blink: true,
buttons: { buttons: {
'heal': { 'heal': {
text: _('1 medicine'), text: _('1 medicine'),
cost: { 'medicine' : 1 }, cost: { 'medicine' : 1 },
nextScene: {1: 'healed'} nextScene: {1: 'healed'}
}, },
'ignore': { 'ignore': {
text: _('ignore it'), text: _('ignore it'),
nextScene: {1: 'death'} nextScene: {1: 'death'}
} }
} }
}, },
'healed': { 'healed': {
text: [ text: [
_('the sickness is cured in time.') _('the sickness is cured in time.')
], ],
buttons: { buttons: {
'end': { 'end': {
text: _('go home'), text: _('go home'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
'death': { 'death': {
text: [ text: [
_('the sickness spreads through the village.'), _('the sickness spreads through the village.'),
_('the days are spent with burials.'), _('the days are spent with burials.'),
_('the nights are rent with screams.') _('the nights are rent with screams.')
], ],
onLoad: function() { onLoad: function() {
var numKilled = Math.floor(Math.random() * 20) + 1; var numKilled = Math.floor(Math.random() * 20) + 1;
Outside.killVillagers(numKilled); Outside.killVillagers(numKilled);
}, },
buttons: { buttons: {
'end': { 'end': {
text: _('go home'), text: _('go home'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}, },
{ /* Plague */ { /* Plague */
title: _('Plague'), title: _('Plague'),
isAvailable: function() { isAvailable: function() {
return Engine.activeModule == Outside && $SM.get('game.population', true) > 50 && $SM.get('stores.medicine', true) > 0; return Engine.activeModule == Outside && $SM.get('game.population', true) > 50 && $SM.get('stores.medicine', true) > 0;
}, },
scenes: { scenes: {
'start': { 'start': {
text: [ text: [
_('a terrible plague is fast spreading through the village.'), _('a terrible plague is fast spreading through the village.'),
_('medicine is needed immediately.') _('medicine is needed immediately.')
], ],
blink: true, blink: true,
buttons: { buttons: {
/* Because there is a serious need for medicine, the price is raised. */ /* Because there is a serious need for medicine, the price is raised. */
'buyMedicine': { 'buyMedicine': {
text: _('buy medicine'), text: _('buy medicine'),
cost: { 'scales': 70, cost: { 'scales': 70,
'teeth': 50 }, 'teeth': 50 },
reward: { 'medicine': 1 } reward: { 'medicine': 1 }
}, },
'heal': { 'heal': {
text: _('5 medicine'), text: _('5 medicine'),
cost: { 'medicine' : 5 }, cost: { 'medicine' : 5 },
nextScene: {1: 'healed'} nextScene: {1: 'healed'}
}, },
'ignore': { 'ignore': {
text: _('do nothing'), text: _('do nothing'),
nextScene: {1: 'death'} nextScene: {1: 'death'}
} }
} }
}, },
'healed': { 'healed': {
text: [ text: [
_('the plague is kept from spreading.'), _('the plague is kept from spreading.'),
_('only a few die.'), _('only a few die.'),
_('the rest bury them.') _('the rest bury them.')
], ],
onLoad: function() { onLoad: function() {
var numKilled = Math.floor(Math.random() * 5) + 2; var numKilled = Math.floor(Math.random() * 5) + 2;
Outside.killVillagers(numKilled); Outside.killVillagers(numKilled);
}, },
buttons: { buttons: {
'end': { 'end': {
text: _('go home'), text: _('go home'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
'death': { 'death': {
text: [ text: [
_('the plague rips through the village.'), _('the plague rips through the village.'),
_('the nights are rent with screams.'), _('the nights are rent with screams.'),
_('the only hope is a quick death.') _('the only hope is a quick death.')
], ],
onLoad: function() { onLoad: function() {
var numKilled = Math.floor(Math.random() * 80) + 10; var numKilled = Math.floor(Math.random() * 80) + 10;
Outside.killVillagers(numKilled); Outside.killVillagers(numKilled);
}, },
buttons: { buttons: {
'end': { 'end': {
text: _('go home'), text: _('go home'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}, },
{ /* Beast attack */ { /* Beast attack */
title: _('A 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
}, },
blink: true, blink: true,
buttons: { buttons: {
'end': { 'end': {
text: _('go home'), text: _('go home'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}, },
{ /* 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
}, },
blink: true, blink: true,
buttons: { buttons: {
'end': { 'end': {
text: _('go home'), text: _('go home'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
} }
]; ];
+603 -603
View File
File diff suppressed because it is too large Load Diff
+78 -78
View File
@@ -1,78 +1,78 @@
/** /**
* Module that registers the notification box and handles messages * Module that registers the notification box and handles messages
*/ */
var Notifications = { var Notifications = {
init: function(options) { init: function(options) {
this.options = $.extend( this.options = $.extend(
this.options, this.options,
options options
); );
// Create the notifications box // Create the notifications box
elem = $('<div>').attr({ elem = $('<div>').attr({
id: 'notifications', id: 'notifications',
className: 'notifications' className: 'notifications'
}); });
// Create the transparency gradient // Create the transparency gradient
$('<div>').attr('id', 'notifyGradient').appendTo(elem); $('<div>').attr('id', 'notifyGradient').appendTo(elem);
elem.appendTo('div#wrapper'); elem.appendTo('div#wrapper');
}, },
options: {}, // Nothing for now options: {}, // Nothing for now
elem: null, elem: null,
notifyQueue: {}, notifyQueue: {},
// Allow notification to the player // Allow notification to the player
notify: function(module, text, noQueue) { notify: function(module, text, noQueue) {
if(typeof text == 'undefined') return; if(typeof text == 'undefined') return;
if(text.slice(-1) != ".") text += "."; if(text.slice(-1) != ".") text += ".";
if(module != null && Engine.activeModule != module) { if(module != null && Engine.activeModule != module) {
if(!noQueue) { if(!noQueue) {
if(typeof this.notifyQueue[module] == 'undefined') { if(typeof this.notifyQueue[module] == 'undefined') {
this.notifyQueue[module] = []; this.notifyQueue[module] = [];
} }
this.notifyQueue[module].push(text); this.notifyQueue[module].push(text);
} }
} else { } else {
Notifications.printMessage(text); Notifications.printMessage(text);
} }
Engine.saveGame(); Engine.saveGame();
}, },
clearHidden: function() { clearHidden: function() {
// To fix some memory usage issues, we clear notifications that have been hidden. // To fix some memory usage issues, we clear notifications that have been hidden.
// We use position().top here, because we know that the parent will be the same, so the position will be the same. // We use position().top here, because we know that the parent will be the same, so the position will be the same.
var bottom = $('#notifyGradient').position().top + $('#notifyGradient').outerHeight(true); var bottom = $('#notifyGradient').position().top + $('#notifyGradient').outerHeight(true);
$('.notification').each(function() { $('.notification').each(function() {
if($(this).position().top > bottom){ if($(this).position().top > bottom){
$(this).remove(); $(this).remove();
} }
}); });
}, },
printMessage: function(t) { printMessage: function(t) {
var text = $('<div>').addClass('notification').css('opacity', '0').text(t).prependTo('div#notifications'); var text = $('<div>').addClass('notification').css('opacity', '0').text(t).prependTo('div#notifications');
text.animate({opacity: 1}, 500, 'linear', function() { text.animate({opacity: 1}, 500, 'linear', function() {
// Do this every time we add a new message, this way we never have a large backlog to iterate through. Keeps things faster. // Do this every time we add a new message, this way we never have a large backlog to iterate through. Keeps things faster.
Notifications.clearHidden(); Notifications.clearHidden();
}); });
}, },
printQueue: function(module) { printQueue: function(module) {
if(typeof this.notifyQueue[module] != 'undefined') { if(typeof this.notifyQueue[module] != 'undefined') {
while(this.notifyQueue[module].length > 0) { while(this.notifyQueue[module].length > 0) {
Notifications.printMessage(this.notifyQueue[module].shift()); Notifications.printMessage(this.notifyQueue[module].shift());
} }
} }
} }
}; };
+615 -615
View File
File diff suppressed because it is too large Load Diff
+317 -317
View File
@@ -1,317 +1,317 @@
var Path = { var Path = {
DEFAULT_BAG_SPACE: 10, DEFAULT_BAG_SPACE: 10,
// Everything not in this list weighs 1 // Everything not in this list weighs 1
Weight: { Weight: {
'bone spear': 2, 'bone spear': 2,
'iron sword': 3, 'iron sword': 3,
'steel sword': 5, 'steel sword': 5,
'rifle': 5, 'rifle': 5,
'bullets': 0.1, 'bullets': 0.1,
'energy cell': 0.2, 'energy cell': 0.2,
'laser rifle': 5, 'laser rifle': 5,
'bolas': 0.5 'bolas': 0.5
}, },
name: 'Path', name: 'Path',
options: {}, // Nuthin' options: {}, // Nuthin'
init: function(options) { init: function(options) {
this.options = $.extend( this.options = $.extend(
this.options, this.options,
options options
); );
// Init the World // Init the World
World.init(); World.init();
// Create the path tab // Create the path tab
this.tab = Header.addLocation(_("A Dusty Path"), "path", Path); this.tab = Header.addLocation(_("A Dusty Path"), "path", Path);
// Create the Path panel // Create the Path panel
this.panel = $('<div>').attr('id', "pathPanel") this.panel = $('<div>').attr('id', "pathPanel")
.addClass('location') .addClass('location')
.appendTo('div#locationSlider'); .appendTo('div#locationSlider');
// Add the outfitting area // Add the outfitting area
var outfitting = $('<div>').attr('id', 'outfitting').appendTo(this.panel); var outfitting = $('<div>').attr('id', 'outfitting').appendTo(this.panel);
$('<div>').attr('id', 'bagspace').appendTo(outfitting); $('<div>').attr('id', 'bagspace').appendTo(outfitting);
// Add the embark button // Add the embark button
new Button.Button({ new Button.Button({
id: 'embarkButton', id: 'embarkButton',
text: _("embark"), text: _("embark"),
click: Path.embark, click: Path.embark,
width: '80px', width: '80px',
cooldown: World.DEATH_COOLDOWN cooldown: World.DEATH_COOLDOWN
}).appendTo(this.panel); }).appendTo(this.panel);
Path.outfit = $SM.get('outfit'); Path.outfit = $SM.get('outfit');
Engine.updateSlider(); Engine.updateSlider();
//subscribe to stateUpdates //subscribe to stateUpdates
$.Dispatch('stateUpdate').subscribe(Path.handleStateUpdates); $.Dispatch('stateUpdate').subscribe(Path.handleStateUpdates);
}, },
openPath: function() { openPath: function() {
Path.init(); Path.init();
Engine.event('progress', 'path'); Engine.event('progress', 'path');
Notifications.notify(Room, _('the compass points ' + World.dir)); Notifications.notify(Room, _('the compass points ' + World.dir));
}, },
getWeight: function(thing) { getWeight: function(thing) {
var w = Path.Weight[thing]; var w = Path.Weight[thing];
if(typeof w != 'number') w = 1; if(typeof w != 'number') w = 1;
return w; return w;
}, },
getCapacity: function() { getCapacity: function() {
if($SM.get('stores.convoy', true) > 0) { if($SM.get('stores.convoy', true) > 0) {
return Path.DEFAULT_BAG_SPACE + 60; return Path.DEFAULT_BAG_SPACE + 60;
} else if($SM.get('stores.wagon', true) > 0) { } else if($SM.get('stores.wagon', true) > 0) {
return Path.DEFAULT_BAG_SPACE + 30; return Path.DEFAULT_BAG_SPACE + 30;
} else if($SM.get('stores.rucksack', true) > 0) { } else if($SM.get('stores.rucksack', true) > 0) {
return Path.DEFAULT_BAG_SPACE + 10; return Path.DEFAULT_BAG_SPACE + 10;
} }
return Path.DEFAULT_BAG_SPACE; return Path.DEFAULT_BAG_SPACE;
}, },
getFreeSpace: function() { getFreeSpace: function() {
var num = 0; var num = 0;
if(Path.outfit) { if(Path.outfit) {
for(var k in Path.outfit) { for(var k in Path.outfit) {
var n = Path.outfit[k]; var n = Path.outfit[k];
if(isNaN(n)) { if(isNaN(n)) {
// No idea how this happens, but I will fix it here! // No idea how this happens, but I will fix it here!
Path.outfit[k] = n = 0; Path.outfit[k] = n = 0;
} }
num += n * Path.getWeight(k); num += n * Path.getWeight(k);
} }
} }
return Path.getCapacity() - num; return Path.getCapacity() - num;
}, },
updatePerks: function(ignoreStores) { updatePerks: function(ignoreStores) {
if($SM.get('character.perks')) { if($SM.get('character.perks')) {
var perks = $('#perks'); var perks = $('#perks');
var needsAppend = false; var needsAppend = false;
if(perks.length === 0) { if(perks.length === 0) {
needsAppend = true; needsAppend = true;
perks = $('<div>').attr('id', 'perks'); perks = $('<div>').attr('id', 'perks');
} }
for(var k in $SM.get('character.perks')) { for(var k in $SM.get('character.perks')) {
var id = 'perk_' + k.replace(' ', '-'); var id = 'perk_' + k.replace(' ', '-');
var r = $('#' + id); var r = $('#' + id);
if($SM.get('character.perks["'+k+'"]') && r.length === 0) { if($SM.get('character.perks["'+k+'"]') && r.length === 0) {
r = $('<div>').attr('id', id).addClass('perkRow').appendTo(perks); r = $('<div>').attr('id', id).addClass('perkRow').appendTo(perks);
$('<div>').addClass('row_key').text(_(k)).appendTo(r); $('<div>').addClass('row_key').text(_(k)).appendTo(r);
$('<div>').addClass('tooltip bottom right').text(Engine.Perks[k].desc).appendTo(r); $('<div>').addClass('tooltip bottom right').text(Engine.Perks[k].desc).appendTo(r);
} }
} }
if(needsAppend && perks.children().length > 0) { if(needsAppend && perks.children().length > 0) {
perks.appendTo(Path.panel); perks.appendTo(Path.panel);
} }
if(!ignoreStores && Engine.activeModule === Path) { if(!ignoreStores && Engine.activeModule === Path) {
$('#storesContainer').css({top: perks.height() + 26 + 'px'}); $('#storesContainer').css({top: perks.height() + 26 + 'px'});
} }
} }
}, },
updateOutfitting: function() { updateOutfitting: function() {
var outfit = $('div#outfitting'); var outfit = $('div#outfitting');
if(!Path.outfit) { if(!Path.outfit) {
Path.outfit = {}; Path.outfit = {};
} }
// Add the armour row // Add the armour row
var armour = _("none"); var armour = _("none");
if($SM.get('stores["s armour"]', true) > 0) if($SM.get('stores["s armour"]', true) > 0)
armour = _("steel"); armour = _("steel");
else if($SM.get('stores["i armour"]', true) > 0) else if($SM.get('stores["i armour"]', true) > 0)
armour = _("iron"); armour = _("iron");
else if($SM.get('stores["l armour"]', true) > 0) else if($SM.get('stores["l armour"]', true) > 0)
armour = _("leather"); armour = _("leather");
var aRow = $('#armourRow'); var aRow = $('#armourRow');
if(aRow.length === 0) { if(aRow.length === 0) {
aRow = $('<div>').attr('id', 'armourRow').addClass('outfitRow').prependTo(outfit); aRow = $('<div>').attr('id', 'armourRow').addClass('outfitRow').prependTo(outfit);
$('<div>').addClass('row_key').text(_('armour')).appendTo(aRow); $('<div>').addClass('row_key').text(_('armour')).appendTo(aRow);
$('<div>').addClass('row_val').text(armour).appendTo(aRow); $('<div>').addClass('row_val').text(armour).appendTo(aRow);
$('<div>').addClass('clear').appendTo(aRow); $('<div>').addClass('clear').appendTo(aRow);
} else { } else {
$('.row_val', aRow).text(armour); $('.row_val', aRow).text(armour);
} }
// Add the water row // Add the water row
var wRow = $('#waterRow'); var wRow = $('#waterRow');
if(wRow.length === 0) { if(wRow.length === 0) {
wRow = $('<div>').attr('id', 'waterRow').addClass('outfitRow').insertAfter(aRow); wRow = $('<div>').attr('id', 'waterRow').addClass('outfitRow').insertAfter(aRow);
$('<div>').addClass('row_key').text(_('water')).appendTo(wRow); $('<div>').addClass('row_key').text(_('water')).appendTo(wRow);
$('<div>').addClass('row_val').text(World.getMaxWater()).appendTo(wRow); $('<div>').addClass('row_val').text(World.getMaxWater()).appendTo(wRow);
$('<div>').addClass('clear').appendTo(wRow); $('<div>').addClass('clear').appendTo(wRow);
} else { } else {
$('.row_val', wRow).text(World.getMaxWater()); $('.row_val', wRow).text(World.getMaxWater());
} }
var space = Path.getFreeSpace(); var space = Path.getFreeSpace();
var total = 0; var total = 0;
// Add the non-craftables to the craftables // Add the non-craftables to the craftables
var carryable = $.extend({ var carryable = $.extend({
'cured meat': { type: 'tool' }, 'cured meat': { type: 'tool' },
'bullets': { type: 'tool' }, 'bullets': { type: 'tool' },
'grenade': {type: 'weapon' }, 'grenade': {type: 'weapon' },
'bolas': {type: 'weapon' }, 'bolas': {type: 'weapon' },
'laser rifle': {type: 'weapon' }, 'laser rifle': {type: 'weapon' },
'energy cell': {type: 'tool' }, 'energy cell': {type: 'tool' },
'bayonet': {type: 'weapon' }, 'bayonet': {type: 'weapon' },
'charm': {type: 'tool'}, 'charm': {type: 'tool'},
'medicine': {type: 'tool'} 'medicine': {type: 'tool'}
}, Room.Craftables); }, Room.Craftables);
for(var k in carryable) { for(var k in carryable) {
var store = carryable[k]; var store = carryable[k];
var have = $SM.get('stores["'+k+'"]'); var have = $SM.get('stores["'+k+'"]');
var num = Path.outfit[k]; var num = Path.outfit[k];
num = typeof num == 'number' ? num : 0; num = typeof num == 'number' ? num : 0;
if (have < num) { num = have; } if (have < num) { num = have; }
var numAvailable = $SM.get('stores["'+k+'"]', true); var numAvailable = $SM.get('stores["'+k+'"]', true);
var row = $('div#outfit_row_' + k.replace(' ', '-'), outfit); var row = $('div#outfit_row_' + k.replace(' ', '-'), outfit);
if((store.type == 'tool' || store.type == 'weapon') && have > 0) { if((store.type == 'tool' || store.type == 'weapon') && have > 0) {
total += num * Path.getWeight(k); total += num * Path.getWeight(k);
if(row.length === 0) { if(row.length === 0) {
row = Path.createOutfittingRow(k, num, store.name); row = Path.createOutfittingRow(k, num, store.name);
var curPrev = null; var curPrev = null;
outfit.children().each(function(i) { outfit.children().each(function(i) {
var child = $(this); var child = $(this);
if(child.attr('id').indexOf('outfit_row_') === 0) { if(child.attr('id').indexOf('outfit_row_') === 0) {
var cName = child.attr('id').substring(11).replace('-', ' '); var cName = child.attr('id').substring(11).replace('-', ' ');
if(cName < k && (curPrev == null || cName > curPrev)) { if(cName < k && (curPrev == null || cName > curPrev)) {
curPrev = cName; curPrev = cName;
} }
} }
}); });
if(curPrev == null) { if(curPrev == null) {
row.insertAfter(wRow); row.insertAfter(wRow);
} }
else else
{ {
row.insertAfter(outfit.find('#outfit_row_' + curPrev.replace(' ', '-'))); row.insertAfter(outfit.find('#outfit_row_' + curPrev.replace(' ', '-')));
} }
} else { } else {
$('div#' + row.attr('id') + ' > div.row_val > span', outfit).text(num); $('div#' + row.attr('id') + ' > div.row_val > span', outfit).text(num);
$('div#' + row.attr('id') + ' .tooltip .numAvailable', outfit).text(numAvailable - num); $('div#' + row.attr('id') + ' .tooltip .numAvailable', outfit).text(numAvailable - num);
} }
if(num === 0) { if(num === 0) {
$('.dnBtn', row).addClass('disabled'); $('.dnBtn', row).addClass('disabled');
$('.dnManyBtn', row).addClass('disabled'); $('.dnManyBtn', row).addClass('disabled');
} else { } else {
$('.dnBtn', row).removeClass('disabled'); $('.dnBtn', row).removeClass('disabled');
$('.dnManyBtn', row).removeClass('disabled'); $('.dnManyBtn', row).removeClass('disabled');
} }
if(num >= numAvailable || space < Path.getWeight(k)) { if(num >= numAvailable || space < Path.getWeight(k)) {
$('.upBtn', row).addClass('disabled'); $('.upBtn', row).addClass('disabled');
$('.upManyBtn', row).addClass('disabled'); $('.upManyBtn', row).addClass('disabled');
} else if(space >= Path.getWeight(k)) { } else if(space >= Path.getWeight(k)) {
$('.upBtn', row).removeClass('disabled'); $('.upBtn', row).removeClass('disabled');
$('.upManyBtn', row).removeClass('disabled'); $('.upManyBtn', row).removeClass('disabled');
} }
} else if(have === 0 && row.length > 0) { } else if(have === 0 && row.length > 0) {
row.remove(); row.remove();
} }
} }
// Update bagspace // Update bagspace
$('#bagspace').text(_('free {0}/{1}', Math.floor(Path.getCapacity() - total) , Path.getCapacity())); $('#bagspace').text(_('free {0}/{1}', Math.floor(Path.getCapacity() - total) , Path.getCapacity()));
if(Path.outfit['cured meat'] > 0) { if(Path.outfit['cured meat'] > 0) {
Button.setDisabled($('#embarkButton'), false); Button.setDisabled($('#embarkButton'), false);
} else { } else {
Button.setDisabled($('#embarkButton'), true); Button.setDisabled($('#embarkButton'), true);
} }
}, },
createOutfittingRow: function(key, num, name) { createOutfittingRow: function(key, num, name) {
if(!name) name = _(key); if(!name) name = _(key);
var row = $('<div>').attr('id', 'outfit_row_' + key.replace(' ', '-')).addClass('outfitRow').attr('key',key); var row = $('<div>').attr('id', 'outfit_row_' + key.replace(' ', '-')).addClass('outfitRow').attr('key',key);
$('<div>').addClass('row_key').text(name).appendTo(row); $('<div>').addClass('row_key').text(name).appendTo(row);
var val = $('<div>').addClass('row_val').appendTo(row); var val = $('<div>').addClass('row_val').appendTo(row);
$('<span>').text(num).appendTo(val); $('<span>').text(num).appendTo(val);
$('<div>').addClass('upBtn').appendTo(val).click([1], Path.increaseSupply); $('<div>').addClass('upBtn').appendTo(val).click([1], Path.increaseSupply);
$('<div>').addClass('dnBtn').appendTo(val).click([1], Path.decreaseSupply); $('<div>').addClass('dnBtn').appendTo(val).click([1], Path.decreaseSupply);
$('<div>').addClass('upManyBtn').appendTo(val).click([10], Path.increaseSupply); $('<div>').addClass('upManyBtn').appendTo(val).click([10], Path.increaseSupply);
$('<div>').addClass('dnManyBtn').appendTo(val).click([10], Path.decreaseSupply); $('<div>').addClass('dnManyBtn').appendTo(val).click([10], Path.decreaseSupply);
$('<div>').addClass('clear').appendTo(row); $('<div>').addClass('clear').appendTo(row);
var numAvailable = $SM.get('stores["'+key+'"]', true); var numAvailable = $SM.get('stores["'+key+'"]', true);
var tt = $('<div>').addClass('tooltip bottom right').appendTo(row); var tt = $('<div>').addClass('tooltip bottom right').appendTo(row);
$('<div>').addClass('row_key').text(_('weight')).appendTo(tt); $('<div>').addClass('row_key').text(_('weight')).appendTo(tt);
$('<div>').addClass('row_val').text(Path.getWeight(key)).appendTo(tt); $('<div>').addClass('row_val').text(Path.getWeight(key)).appendTo(tt);
$('<div>').addClass('row_key').text(_('available')).appendTo(tt); $('<div>').addClass('row_key').text(_('available')).appendTo(tt);
$('<div>').addClass('row_val').addClass('numAvailable').text(numAvailable).appendTo(tt); $('<div>').addClass('row_val').addClass('numAvailable').text(numAvailable).appendTo(tt);
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));
$SM.set('outfit['+supply+']', Path.outfit[supply]); $SM.set('outfit['+supply+']', Path.outfit[supply]);
Path.updateOutfitting(); Path.updateOutfitting();
} }
}, },
decreaseSupply: function(btn) { decreaseSupply: function(btn) {
var supply = $(this).closest('.outfitRow').attr('key'); var supply = $(this).closest('.outfitRow').attr('key');
Engine.log('decreasing ' + supply + ' by up to ' + btn.data); Engine.log('decreasing ' + 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(cur > 0) { if(cur > 0) {
Path.outfit[supply] = Math.max(0, cur - btn.data); Path.outfit[supply] = Math.max(0, cur - btn.data);
$SM.set('outfit['+supply+']', Path.outfit[supply]); $SM.set('outfit['+supply+']', Path.outfit[supply]);
Path.updateOutfitting(); Path.updateOutfitting();
} }
}, },
onArrival: function(transition_diff) { onArrival: function(transition_diff) {
Path.setTitle(); Path.setTitle();
Path.updateOutfitting(); Path.updateOutfitting();
Path.updatePerks(true); Path.updatePerks(true);
$SM.set('outfit', Path.outfit); $SM.set('outfit', Path.outfit);
Engine.moveStoresView($('#perks'), transition_diff); Engine.moveStoresView($('#perks'), transition_diff);
}, },
setTitle: function() { setTitle: function() {
document.title = _('A Dusty Path'); document.title = _('A Dusty Path');
}, },
embark: function() { embark: function() {
for(var k in Path.outfit) { for(var k in Path.outfit) {
$SM.add('stores["'+k+'"]', -Path.outfit[k]); $SM.add('stores["'+k+'"]', -Path.outfit[k]);
} }
$SM.remove('outfit'); $SM.remove('outfit');
World.onArrival(); World.onArrival();
$('#outerSlider').animate({left: '-700px'}, 300); $('#outerSlider').animate({left: '-700px'}, 300);
Engine.activeModule = World; Engine.activeModule = World;
}, },
handleStateUpdates: function(e){ handleStateUpdates: function(e){
if(e.category == 'character' && e.stateName.indexOf('character.perks') === 0 && Engine.activeModule == Path){ if(e.category == 'character' && e.stateName.indexOf('character.perks') === 0 && Engine.activeModule == Path){
Path.updatePerks(); Path.updatePerks();
} }
} }
}; };
+1120 -1120
View File
File diff suppressed because it is too large Load Diff
+509 -509
View File
File diff suppressed because it is too large Load Diff
+949 -949
View File
File diff suppressed because it is too large Load Diff