Skip to content

Commit

Permalink
prestige system now absolutely complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Vermilingua committed Oct 16, 2013
1 parent f952b4d commit 83bf266
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 39 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<meta itemprop="name" property="og:title" content="A Dark Room" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="image_src" href="img/adr.png" />
<!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> -->
<script src="lib/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<!-- <script src="lib/jquery.min.js"></script> -->
<script src="lib/jquery.color-2.1.2.min.js"></script>
<script src="lib/jquery.event.move.js"></script>
<script src="lib/jquery.event.swipe.js"></script>
Expand Down
11 changes: 6 additions & 5 deletions script/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var Engine = {
VERSION: 1.3,
MAX_STORE: 99999999999999,
SAVE_DISPLAY: 30 * 1000,
GAME_OVER: false,

//object event types
topics: {},
Expand Down Expand Up @@ -206,12 +207,12 @@ var Engine = {
},

deleteSave: function() {
//var carriedPrestige = $SM.get('previous.stores');
if(typeof Storage != 'undefined' && localStorage) {
localStorage.clear();
}
if (!Engine.GAME_OVER) {
if(typeof Storage != 'undefined' && localStorage) {
localStorage.clear();
}
}
location.reload();
//$SM.set('previous.stores',carriedPrestige);
},

share: function() {
Expand Down
69 changes: 41 additions & 28 deletions script/prestige.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,48 @@ var Prestige = {

save: function() {
var prevStores = [ //g = goods, w = weapons, a = ammo
$SM.get('stores["wood"]'),
$SM.get('stores["fur"]'),
$SM.get('stores["meat"]'),
$SM.get('stores["iron"]'),
$SM.get('stores["coal"]'),
$SM.get('stores["sulphur"]'),
$SM.get('stores["steel"]'),
$SM.get('stores["cured meat"]'),
$SM.get('stores["scales"]'),
$SM.get('stores["teeth"]'),
$SM.get('stores["leather"]'),
$SM.get('stores["bait"]'),
$SM.get('stores["torch"]'),
$SM.get('stores["cloth"]'),
$SM.get('stores["bone spear"]'),
$SM.get('stores["iron sword"]'),
$SM.get('stores["steel sword"]'),
$SM.get('stores["bayonet"]'),
$SM.get('stores["rifle"]'),
$SM.get('stores["laser rifle"]'),
$SM.get('stores["bullets"]'),
$SM.get('stores["energy cell"]'),
$SM.get('stores["grenade"]'),
$SM.get('stores["bolas"]')
Math.floor($SM.get('stores["wood"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["fur"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["meat"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["iron"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["coal"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["sulphur"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["steel"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["cured meat"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["scales"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["teeth"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["leather"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["bait"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["torch"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["cloth"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["bone spear"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["iron sword"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["steel sword"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["bayonet"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["rifle"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["laser rifle"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["bullets"]') / Prestige.randGen('a')),
Math.floor($SM.get('stores["energy cell"]') / Prestige.randGen('a')),
Math.floor($SM.get('stores["grenade"]') / Prestige.randGen('a')),
Math.floor($SM.get('stores["bolas"]') / Prestige.randGen('a'))
];
for (var n = 0;n<=23;n++) {
if (isNaN(prevStores[n])) {prevStores[n] = 0};
}
$SM.set('previous.stores', prevStores);
return prevStores;
},

populateNewSave: function(newstate) {
State = {
previous: {
stores: newstate
}
};
Engine.init({state: State});
return State;
},

load: function() {
var prevStores = $SM.get('previous.stores');
$SM.add('stores["wood"]',prevStores[0]),
Expand Down Expand Up @@ -68,23 +81,23 @@ var Prestige = {
$SM.add('stores["grenade"]',prevStores[22]),
$SM.add('stores["bolas"]',prevStores[23])
return prevStores;
}
},

/*randGen: function(storeType) {
randGen: function(storeType) {
if (storeType == 'g') {
divisor = Math.floor(Math.random()*10)
}
else if (storeType == 'w') {
divisor = Math.floor(Math.floor(Math.random()*10)/2)
}
else if (storeType == 'a') {
divisor = Math.floor(Math.random()*10*Math.floor(Math.random()*10/5))
divisor = Math.ceil(Math.random()*10*Math.ceil(Math.random()*10))
}
else { divisor = 1 };
if (divisor === 0) {
divisor = 1
};
return divisor;
}*/
}

}
12 changes: 9 additions & 3 deletions script/space.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,18 @@ var Space = {
$('#notifyGradient').attr('style', 'background-color:'+cur+';background:-webkit-' + s + ';background:' + s);
},
complete: function() {
//Prestige.save();
$('#starsContainer').remove();
Engine.GAME_OVER = true;
var backup;
$('#starsContainer').remove();
if(typeof Storage != 'undefined' && localStorage) {
localStorage.clear();
backup = Prestige.save();
localStorage.clear();
}
delete window.State;
$('.deleteSave, .share').remove();
Prestige.populateNewSave(backup);
$('#content, #notifications').remove();
$('.deleteSave, .share').attr('style', 'color: white;');
Engine.options = {};
}
});
Expand Down
2 changes: 1 addition & 1 deletion script/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ var World = {
World.LANDMARKS[World.TILE.BOREHOLE] = { num: 10, minRadius: 15, maxRadius: World.RADIUS * 1.5, scene: 'borehole', label: 'A&nbsp;Borehole'};
World.LANDMARKS[World.TILE.BATTLEFIELD] = { num: 5, minRadius: 18, maxRadius: World.RADIUS * 1.5, scene: 'battlefield', label: 'A&nbsp;Battlefield'};
World.LANDMARKS[World.TILE.SWAMP] = { num: 1, minRadius: 15, maxRadius: World.RADIUS * 1.5, scene: 'swamp', label: 'A&nbsp;Murky&nbsp;Swamp'};
World.LANDMARKS[World.TILE.CACHE] = { num: 1, minRadius: 10, maxRadius: World.RADIUS * 1.5, scene: 'cache', label: 'An&nbsp;Underground&nbsp;Cache'};
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') {
$SM.set('features.location.world', true);
Expand Down

0 comments on commit 83bf266

Please sign in to comment.