Merge anubisthejackle:issue115

Closes #115
Closes #224
This commit is contained in:
Blake Grotewold
2015-02-14 17:14:22 -05:00
23 changed files with 6030 additions and 5928 deletions
+17 -17
View File
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>A Dark Room</name> <name>A Dark Room</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name> <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature> <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>
+42 -42
View File
@@ -1,43 +1,43 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<title>A Dark Room</title> <title>A Dark Room</title>
<style> <style>
body { body {
background-color: #000000; background-color: #000000;
color: #FFFFFF; color: #FFFFFF;
} }
a { a {
color: #FFFFFF; color: #FFFFFF;
} }
div { div {
width: 960px; width: 960px;
margin: auto; margin: auto;
text-align: center; text-align: center;
margin-top: 20px; margin-top: 20px;
} }
.browser { .browser {
width:102.4px; width:102.4px;
height:102.4px; height:102.4px;
} }
</style> </style>
</head> </head>
<body> <body>
<center> <center>
<img src="img/Logo1.jpg" /> <img src="img/Logo1.jpg" />
<div> <div>
<strong> <strong>
A Dark Room makes use of HTML5 and CSS3, which your current browser does not appear to support.<br/> A Dark Room makes use of HTML5 and CSS3, which your current browser does not appear to support.<br/>
Please <a href="http://browsehappy.com">update your browser</a> for the best experience:<br/> Please <a href="http://browsehappy.com">update your browser</a> for the best experience:<br/>
</strong> </strong>
<a href='http://www.mozilla.org/en-US/firefox/new/'><img class="browser" src='img/firefox.png' alt='Firefox' title='Firefox' /></a> <a href='http://www.mozilla.org/en-US/firefox/new/'><img class="browser" src='img/firefox.png' alt='Firefox' title='Firefox' /></a>
<a href='https://www.google.com/intl/en/chrome/browser/'><img class="browser" src='img/chrome.png' alt='Chrome' title='Chrome' /></a> <a href='https://www.google.com/intl/en/chrome/browser/'><img class="browser" src='img/chrome.png' alt='Chrome' title='Chrome' /></a>
<a href='http://windows.microsoft.com/en-CA/internet-explorer/download-ie'><img class="browser" src='img/ie.png' alt='Internet Explorer' title='Internet Explorer' /></a> <a href='http://windows.microsoft.com/en-CA/internet-explorer/download-ie'><img class="browser" src='img/ie.png' alt='Internet Explorer' title='Internet Explorer' /></a>
<a href='http://www.opera.com/computer'><img class="browser" src='img/opera.png' alt='Opera' title='Opera' /></a> <a href='http://www.opera.com/computer'><img class="browser" src='img/opera.png' alt='Opera' title='Opera' /></a>
<a href='http://www.apple.com/safari/'><img class="browser" src='img/safari.png' alt='Safari' title='Safari' /></a> <a href='http://www.apple.com/safari/'><img class="browser" src='img/safari.png' alt='Safari' title='Safari' /></a>
<br/><br/> <br/><br/>
Or you can <a href='index.html?ignorebrowser=true'>play anyway</a>, but it probably won't work! Or you can <a href='index.html?ignorebrowser=true'>play anyway</a>, but it probably won't work!
</div> </div>
</center> </center>
</body> </body>
</html> </html>
+584 -584
View File
File diff suppressed because it is too large Load Diff
+63 -63
View File
@@ -1,64 +1,64 @@
div#village { div#village {
position: absolute; position: absolute;
top: 0px; top: 0px;
right: 0px; right: 0px;
border: 1px solid black; border: 1px solid black;
cursor: default; cursor: default;
padding: 5px 10px; padding: 5px 10px;
width: 200px; width: 200px;
} }
div#population { div#population {
position: absolute; position: absolute;
top: -13px; top: -13px;
right: 10px; right: 10px;
background-color: white; background-color: white;
} }
.noHuts #population { .noHuts #population {
display: none; display: none;
} }
div#village:before { div#village:before {
position: absolute; position: absolute;
background: white; background: white;
content: "village"; content: "village";
left: 8px; left: 8px;
top: -13px; top: -13px;
} }
div#village.noHuts:before { div#village.noHuts:before {
content: "forest"; content: "forest";
} }
div#workers { div#workers {
position:absolute; position:absolute;
top: -4px; top: -4px;
left: 160px; left: 160px;
width: 150px; width: 150px;
} }
.workerRow > .row_val { .workerRow > .row_val {
position: relative; position: relative;
padding-right: 20px; padding-right: 20px;
-webkit-touch-callout: none; -webkit-touch-callout: none;
-webkit-user-select: none; -webkit-user-select: none;
-khtml-user-select: none; -khtml-user-select: none;
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
} }
.workerRow { .workerRow {
position: relative; position: relative;
margin: 10px 0px; margin: 10px 0px;
cursor: default; cursor: default;
} }
.workerRow .tooltip { .workerRow .tooltip {
width: 150px; width: 150px;
} }
div.storeRow div.tooltip { div.storeRow div.tooltip {
width: 160px; width: 160px;
} }
+65 -65
View File
@@ -1,66 +1,66 @@
#outfitting { #outfitting {
position: relative; position: relative;
border: 1px solid black; border: 1px solid black;
width: 200px; width: 200px;
margin-bottom: 20px; margin-bottom: 20px;
padding: 5px 10px; padding: 5px 10px;
} }
div#outfitting:before { div#outfitting:before {
position: absolute; position: absolute;
content: "supplies"; content: "supplies";
top: -13px; top: -13px;
background-color: white; background-color: white;
} }
div.outfitRow { div.outfitRow {
position: relative; position: relative;
cursor: default; cursor: default;
margin: 10px -30px 10px 0px; margin: 10px -30px 10px 0px;
} }
div.outfitRow > .row_val { div.outfitRow > .row_val {
padding-right: 30px; padding-right: 30px;
-webkit-touch-callout: none; -webkit-touch-callout: none;
-webkit-user-select: none; -webkit-user-select: none;
-khtml-user-select: none; -khtml-user-select: none;
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
} }
div.outfitRow .tooltip { div.outfitRow .tooltip {
width: 150px; width: 150px;
} }
div#bagspace { div#bagspace {
background-color: white; background-color: white;
position: absolute; position: absolute;
top:-13px; top:-13px;
right: 10px; right: 10px;
} }
div#perks { div#perks {
position: absolute; position: absolute;
top: 0px; top: 0px;
right: 0px; right: 0px;
border: 1px solid black; border: 1px solid black;
cursor: default; cursor: default;
padding: 5px 10px; padding: 5px 10px;
width: 200px; width: 200px;
} }
div#perks:before { div#perks:before {
position: absolute; position: absolute;
content: "perks"; content: "perks";
top: -13px; top: -13px;
background-color: white; background-color: white;
} }
div.perkRow { div.perkRow {
position: relative; position: relative;
} }
div.perkRow .row_key { div.perkRow .row_key {
float: none; float: none;
} }
+78 -78
View File
@@ -1,79 +1,79 @@
div#buildBtns { div#buildBtns {
position: absolute; position: absolute;
top: 50px; top: 50px;
left: 0px; left: 0px;
} }
div#buildBtns:before { div#buildBtns:before {
content: "build:"; content: "build:";
position: relative; position: relative;
top: -5px; top: -5px;
} }
div#craftBtns { div#craftBtns {
position: absolute; position: absolute;
top: 50px; top: 50px;
left: 150px; left: 150px;
} }
div#craftBtns:before { div#craftBtns:before {
content: "craft:"; content: "craft:";
position: relative; position: relative;
top: -5px; top: -5px;
} }
div#buyBtns { div#buyBtns {
position: absolute; position: absolute;
top: 50px; top: 50px;
left: 300px; left: 300px;
} }
div#buyBtns:before { div#buyBtns:before {
content: "buy:"; content: "buy:";
position: relative; position: relative;
top: -5px; top: -5px;
} }
div#storesContainer { div#storesContainer {
position: absolute; position: absolute;
top: 0px; top: 0px;
right: 0px; right: 0px;
} }
div#stores { div#stores {
position: relative; position: relative;
border: 1px solid black; border: 1px solid black;
cursor: default; cursor: default;
padding: 5px 10px; padding: 5px 10px;
width: 200px; width: 200px;
} }
div.storeRow { div.storeRow {
position: relative; position: relative;
} }
div#stores:before { div#stores:before {
position: absolute; position: absolute;
background: white; background: white;
content: "stores"; content: "stores";
left: 8px; left: 8px;
top: -13px; top: -13px;
} }
div#weapons { div#weapons {
margin-top: 15px; margin-top: 15px;
position: relative; position: relative;
right: 0px; right: 0px;
border: 1px solid black; border: 1px solid black;
cursor: default; cursor: default;
padding: 5px 10px; padding: 5px 10px;
width: 200px; width: 200px;
} }
div#weapons:before { div#weapons:before {
position: absolute; position: absolute;
background: white; background: white;
content: "weapons"; content: "weapons";
left: 8px; left: 8px;
top: -13px; top: -13px;
} }
+8 -8
View File
@@ -1,8 +1,8 @@
div#hullRow { div#hullRow {
width: 70px; width: 70px;
} }
div#engineRow { div#engineRow {
width: 70px; width: 70px;
margin-bottom: 20px; margin-bottom: 20px;
} }
+154 -154
View File
@@ -1,154 +1,154 @@
@-ms-keyframes spin { @-ms-keyframes spin {
0% { 0% {
-ms-transform: rotate(0deg); -ms-transform: rotate(0deg);
-webkit-transform: rotate(0deg); -webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg); -moz-transform: rotate(0deg);
transform:rotate(0deg); transform:rotate(0deg);
} }
100% { 100% {
-ms-transform: rotate(360deg); -ms-transform: rotate(360deg);
-webkit-transform: rotate(360deg); -webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg); -moz-transform: rotate(360deg);
transform:rotate(360deg); transform:rotate(360deg);
} }
} }
@-webkit-keyframes spin { @-webkit-keyframes spin {
0% { 0% {
-ms-transform: rotate(0deg); -ms-transform: rotate(0deg);
-webkit-transform: rotate(0deg); -webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg); -moz-transform: rotate(0deg);
transform:rotate(0deg); transform:rotate(0deg);
} }
100% { 100% {
-ms-transform: rotate(360deg); -ms-transform: rotate(360deg);
-webkit-transform: rotate(360deg); -webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg); -moz-transform: rotate(360deg);
transform:rotate(360deg); transform:rotate(360deg);
} }
} }
@-moz-keyframes spin { @-moz-keyframes spin {
0% { 0% {
-ms-transform: rotate(0deg); -ms-transform: rotate(0deg);
-webkit-transform: rotate(0deg); -webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg); -moz-transform: rotate(0deg);
transform:rotate(0deg); transform:rotate(0deg);
} }
100% { 100% {
-ms-transform: rotate(360deg); -ms-transform: rotate(360deg);
-webkit-transform: rotate(360deg); -webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg); -moz-transform: rotate(360deg);
transform:rotate(360deg); transform:rotate(360deg);
} }
} }
@keyframes spin { @keyframes spin {
0% { 0% {
-ms-transform: rotate(0deg); -ms-transform: rotate(0deg);
-webkit-transform: rotate(0deg); -webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg); -moz-transform: rotate(0deg);
transform:rotate(0deg); transform:rotate(0deg);
} }
100% { 100% {
-ms-transform: rotate(360deg); -ms-transform: rotate(360deg);
-webkit-transform: rotate(360deg); -webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg); -moz-transform: rotate(360deg);
transform:rotate(360deg); transform:rotate(360deg);
} }
} }
#spacePanel { #spacePanel {
float: none !important; float: none !important;
position: absolute !important; position: absolute !important;
top: -700px; top: -700px;
left: 0px; left: 0px;
} }
#starsContainer { #starsContainer {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: absolute; position: absolute;
top: 0px; top: 0px;
left: 0px; left: 0px;
overflow: hidden; overflow: hidden;
} }
#stars, #starsBack { #stars, #starsBack {
position: absolute; position: absolute;
z-index: -1; z-index: -1;
left: 0px; left: 0px;
} }
#stars > div, #starsBack > div { #stars > div, #starsBack > div {
position: relative; position: relative;
height: 3000px; height: 3000px;
width: 3000px; width: 3000px;
color: white; color: white;
} }
#starsBack { #starsBack {
opacity: 0.5; opacity: 0.5;
} }
.star { .star {
position: absolute; position: absolute;
} }
#ship { #ship {
cursor: default; cursor: default;
position: absolute; position: absolute;
margin-top: -10px; margin-top: -10px;
margin-left: -7.5px; margin-left: -7.5px;
} }
#theEnd { #theEnd {
position: relative; position: relative;
cursor: default; cursor: default;
top: 200px; top: 200px;
margin-left: -220px; margin-left: -220px;
text-align: center; text-align: center;
font-size: 24px; font-size: 24px;
font-weight: bold; font-weight: bold;
opacity: 0; opacity: 0;
color: white; color: white;
} }
.asteroid { .asteroid {
cursor: default; cursor: default;
position: absolute; position: absolute;
top: -40px; top: -40px;
left: 350px; left: 350px;
-webkit-animation: 1s linear 0s normal none infinite spin; -webkit-animation: 1s linear 0s normal none infinite spin;
-moz-animation: 1s linear 0s normal none infinite spin; -moz-animation: 1s linear 0s normal none infinite spin;
-ms-animation: 1s linear 0s normal none infinite spin; -ms-animation: 1s linear 0s normal none infinite spin;
animation: 1s linear 0s normal none infinite spin; animation: 1s linear 0s normal none infinite spin;
font-size: 32px; font-size: 32px;
} }
#hullRemaining { #hullRemaining {
width: 70px; width: 70px;
position: absolute; position: absolute;
top: 0px; top: 0px;
left: 0px; left: 0px;
} }
.centerCont { .centerCont {
padding-top:10%; padding-top:10%;
} }
.endGame { .endGame {
font-size:48px; font-size:48px;
color:#FFFFFF; color:#FFFFFF;
opacity:0; opacity:0;
position:relative; position:relative;
} }
.endGameRestart { .endGameRestart {
font-size: 32px; font-size: 32px;
cursor: pointer; cursor: pointer;
} }
.endGameRestart:hover { .endGameRestart:hover {
text-decoration: underline; text-decoration: underline;
} }
+73 -73
View File
@@ -1,74 +1,74 @@
#worldOuter { #worldOuter {
position: relative; position: relative;
display: inline-block; display: inline-block;
} }
#map { #map {
position: relative; position: relative;
font-family: "Courier New", Courier, monospace; font-family: "Courier New", Courier, monospace;
border: 1px solid black; border: 1px solid black;
overflow: hidden; overflow: hidden;
display: inline-block; display: inline-block;
line-height: 10px; line-height: 10px;
letter-spacing: 1px; letter-spacing: 1px;
color: #999; color: #999;
cursor: default; cursor: default;
-webkit-touch-callout: none; -webkit-touch-callout: none;
-webkit-user-select: none; -webkit-user-select: none;
-khtml-user-select: none; -khtml-user-select: none;
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
} }
#map .landmark { #map .landmark {
position: relative; position: relative;
font-weight: bold; font-weight: bold;
color: black; color: black;
line-height: 0px; /* Hack to prevent the boldness from increasing the row's line-height. I hope it works in all browsers... */ line-height: 0px; /* Hack to prevent the boldness from increasing the row's line-height. I hope it works in all browsers... */
} }
#bagspace-world { #bagspace-world {
border: 1px solid black; border: 1px solid black;
height: 62px; height: 62px;
margin-bottom: 5px; margin-bottom: 5px;
margin-top: 13px; margin-top: 13px;
overflow: hidden; overflow: hidden;
} }
#bagspace-world > div { #bagspace-world > div {
padding: 6px 4px; padding: 6px 4px;
} }
#backpackTitle { #backpackTitle {
position: absolute; position: absolute;
top: 0px; top: 0px;
left: 10px; left: 10px;
background-color: white; background-color: white;
z-index: 1; z-index: 1;
} }
#backpackSpace { #backpackSpace {
position: absolute; position: absolute;
top: 0px; top: 0px;
right: 10px; right: 10px;
background-color: white; background-color: white;
z-index: 1; z-index: 1;
} }
#healthCounter { #healthCounter {
position: absolute; position: absolute;
top: 0px; top: 0px;
left: 80px; left: 80px;
background-color: white; background-color: white;
z-index: 1; z-index: 1;
} }
div.supplyItem { div.supplyItem {
display: inline-block; display: inline-block;
border: 1px solid #999; border: 1px solid #999;
float: left; float: left;
margin: 0px 5px 6px 0px; margin: 0px 5px 6px 0px;
padding: 0 5px; padding: 0 5px;
cursor: default; cursor: default;
} }
+4 -4
View File
@@ -1,5 +1,5 @@
Radius Enemy DPS Player DPS Enemy HP Player HP Radius Enemy DPS Player DPS Enemy HP Player HP
===================================================================== =====================================================================
< 10 1 1 5 10 < 10 1 1 5 10
< 20 3 3 10 15-20 < 20 3 3 10 15-20
< 30 6 4 20 30-40 < 30 6 4 20 30-40
+112 -112
View File
@@ -1,112 +1,112 @@
<!DOCTYPE html> <!DOCTYPE html>
<html itemscope itemtype="http://schema.org/CreativeWork"> <html itemscope itemtype="http://schema.org/CreativeWork">
<head> <head>
<meta charset="UTF-8"/> <meta charset="UTF-8"/>
<!-- <!--
A Dark Room (v1.4) A Dark Room (v1.4)
================== ==================
A minimalist text adventure by Michael Townsend and all his friends. A minimalist text adventure by Michael Townsend and all his friends.
Inspired by Candy Box (http://candies.aniwey.net/) Inspired by Candy Box (http://candies.aniwey.net/)
Contribute on GitHub! (https://github.com/Continuities/adarkroom/) Contribute on GitHub! (https://github.com/Continuities/adarkroom/)
--> -->
<title>A Dark Room</title> <title>A Dark Room</title>
<meta itemprop="description" name="description" property="og:description" content="A minimalist text adventure"> <meta itemprop="description" name="description" property="og:description" content="A minimalist text adventure">
<meta itemprop="image" property="og:image" content="img/adr.png" /> <meta itemprop="image" property="og:image" content="img/adr.png" />
<meta itemprop="name" property="og:title" content="A Dark Room" /> <meta itemprop="name" property="og:title" content="A Dark Room" />
<link rel="shortcut icon" href="favicon.ico" /> <link rel="shortcut icon" href="favicon.ico" />
<link rel="image_src" href="img/adr.png" /> <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="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="https://www.dropbox.com/static/api/dropbox-datastores-1.1-latest.js" type="text/javascript"></script> <script src="https://www.dropbox.com/static/api/dropbox-datastores-1.1-latest.js" type="text/javascript"></script>
<script> <script>
if(!window.jQuery) { if(!window.jQuery) {
document.write('<script src="lib/jquery.min.js"><\/script>') document.write('<script src="lib/jquery.min.js"><\/script>')
} }
</script> </script>
<script src="lib/jquery.color-2.1.2.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.move.js"></script>
<script src="lib/jquery.event.swipe.js"></script> <script src="lib/jquery.event.swipe.js"></script>
<script src="lib/base64.js"></script> <script src="lib/base64.js"></script>
<script src="lib/translate.js"></script> <script src="lib/translate.js"></script>
<script src="lang/langs.js"></script> <script src="lang/langs.js"></script>
<script> <script>
// try to read "lang" param's from url // try to read "lang" param's from url
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 no language requested, try to read it from local storage // if no language requested, try to read it from local storage
if(!lang){ if(!lang){
try { try {
lang = localStorage.lang; lang = localStorage.lang;
} catch(e) {} } catch(e) {}
} }
// if a language different than english requested, load all translations // if a language different than english requested, load all translations
if(lang && lang != 'en'){ if(lang && lang != 'en'){
document.write('<script src="lang/'+lang+'/strings.js"><\/script>'); document.write('<script src="lang/'+lang+'/strings.js"><\/script>');
document.write('<link rel="stylesheet" type="text/css" href="lang/'+lang+'/main.css" \/>'); document.write('<link rel="stylesheet" type="text/css" href="lang/'+lang+'/main.css" \/>');
} }
</script> </script>
<script src="script/Button.js"></script> <script src="script/Button.js"></script>
<script src="script/engine.js"></script> <script src="script/engine.js"></script>
<script src="script/state_manager.js"></script> <script src="script/state_manager.js"></script>
<script src="script/header.js"></script> <script src="script/header.js"></script>
<script src="script/notifications.js"></script> <script src="script/notifications.js"></script>
<script src="script/events.js"></script> <script src="script/events.js"></script>
<script src="script/dropbox.js"></script> <script src="script/dropbox.js"></script>
<script src="script/room.js"></script> <script src="script/room.js"></script>
<script src="script/outside.js"></script> <script src="script/outside.js"></script>
<script src="script/world.js"></script> <script src="script/world.js"></script>
<script src="script/path.js"></script> <script src="script/path.js"></script>
<script src="script/ship.js"></script> <script src="script/ship.js"></script>
<script src="script/space.js"></script> <script src="script/space.js"></script>
<script src="script/prestige.js"></script> <script src="script/prestige.js"></script>
<script src="script/scoring.js"></script> <script src="script/scoring.js"></script>
<!-- Event modules --> <!-- Event modules -->
<script src="script/events/global.js"></script> <script src="script/events/global.js"></script>
<script src="script/events/room.js"></script> <script src="script/events/room.js"></script>
<script src="script/events/outside.js"></script> <script src="script/events/outside.js"></script>
<script src="script/events/encounters.js"></script> <script src="script/events/encounters.js"></script>
<script src="script/events/setpieces.js"></script> <script src="script/events/setpieces.js"></script>
<script type='text/javascript'> <script type='text/javascript'>
var oldIE = false; var oldIE = false;
</script> </script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script type="text/javascript">oldIE = true;</script> <script type="text/javascript">oldIE = true;</script>
<![endif]--> <![endif]-->
<link rel="stylesheet" type="text/css" href="css/main.css" /> <link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="css/room.css" /> <link rel="stylesheet" type="text/css" href="css/room.css" />
<link rel="stylesheet" type="text/css" href="css/outside.css" /> <link rel="stylesheet" type="text/css" href="css/outside.css" />
<link rel="stylesheet" type="text/css" href="css/path.css" /> <link rel="stylesheet" type="text/css" href="css/path.css" />
<link rel="stylesheet" type="text/css" href="css/world.css" /> <link rel="stylesheet" type="text/css" href="css/world.css" />
<link rel="stylesheet" type="text/css" href="css/ship.css" /> <link rel="stylesheet" type="text/css" href="css/ship.css" />
<link rel="stylesheet" type="text/css" href="css/space.css" /> <link rel="stylesheet" type="text/css" href="css/space.css" />
<script src="script/localization.js"></script> <script src="script/localization.js"></script>
<!-- Google Analytics --> <!-- Google Analytics -->
<script> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','http://www.google-analytics.com/analytics.js','ga'); })(window,document,'script','http://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-41314886-1', 'doublespeakgames.com'); ga('create', 'UA-41314886-1', 'doublespeakgames.com');
ga('send', 'pageview'); ga('send', 'pageview');
</script> </script>
</head> </head>
<body> <body>
<div id="wrapper"> <div id="wrapper">
<div id="saveNotify"><script>document.write(_("saved."));</script></div> <div id="saveNotify"><script>document.write(_("saved."));</script></div>
<div id="content"> <div id="content">
<div id="outerSlider"> <div id="outerSlider">
<div id="main"> <div id="main">
<div id="header"></div> <div id="header"></div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</body> </body>
</html> </html>
+1 -1
View File
File diff suppressed because one or more lines are too long
+34 -34
View File
@@ -1,34 +1,34 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<title>A Dark Room</title> <title>A Dark Room</title>
<style> <style>
body { body {
background-color: #000000; background-color: #000000;
color: #FFFFFF; color: #FFFFFF;
} }
a { a {
color: #FFFFFF; color: #FFFFFF;
} }
div { div {
width: 960px; width: 960px;
margin: auto; margin: auto;
text-align: center; text-align: center;
margin-top: 20px; margin-top: 20px;
} }
</style> </style>
</head> </head>
<body> <body>
<center> <center>
<img src="img/Logo1.jpg" /> <img src="img/Logo1.jpg" />
<div> <div>
<strong> <strong>
A Dark Room isn't really mobile-friendly, and it requires arrow keys.<br/> A Dark Room isn't really mobile-friendly, and it requires arrow keys.<br/>
Sorry about that!<br/> Sorry about that!<br/>
</strong><br/> </strong><br/>
Of course you can <a href='index.html?ignorebrowser=true'>play anyway</a>, but it probably won't work!<br/><br/> Of course you can <a href='index.html?ignorebrowser=true'>play anyway</a>, but it probably won't work!<br/><br/>
A Dark Room is now native on iOS! Get it on the <a href="https://itunes.apple.com/us/app/a-dark-room/id736683061?mt=8">App Store</a>. A Dark Room is now native on iOS! Get it on the <a href="https://itunes.apple.com/us/app/a-dark-room/id736683061?mt=8">App Store</a>.
</div> </div>
</center> </center>
</body> </body>
</html> </html>
+85 -85
View File
@@ -1,86 +1,86 @@
var Button = { var Button = {
Button: function(options) { Button: function(options) {
if(typeof options.cooldown == 'number') { if(typeof options.cooldown == 'number') {
this.data_cooldown = options.cooldown; this.data_cooldown = options.cooldown;
} }
this.data_remaining = 0; this.data_remaining = 0;
if(typeof options.click == 'function') { if(typeof options.click == 'function') {
this.data_handler = options.click; this.data_handler = options.click;
} }
var el = $('<div>') var el = $('<div>')
.attr('id', typeof(options.id) != 'undefined' ? options.id : "BTN_" + Engine.getGuid()) .attr('id', typeof(options.id) != 'undefined' ? options.id : "BTN_" + Engine.getGuid())
.addClass('button') .addClass('button')
.text(typeof(options.text) != 'undefined' ? options.text : "button") .text(typeof(options.text) != 'undefined' ? options.text : "button")
.click(function() { .click(function() {
if(!$(this).hasClass('disabled')) { if(!$(this).hasClass('disabled')) {
Button.cooldown($(this)); Button.cooldown($(this));
$(this).data("handler")($(this)); $(this).data("handler")($(this));
} }
}) })
.data("handler", typeof options.click == 'function' ? options.click : function() { Engine.log("click"); }) .data("handler", typeof options.click == 'function' ? options.click : function() { Engine.log("click"); })
.data("remaining", 0) .data("remaining", 0)
.data("cooldown", typeof options.cooldown == 'number' ? options.cooldown : 0); .data("cooldown", typeof options.cooldown == 'number' ? options.cooldown : 0);
el.append($("<div>").addClass('cooldown')); el.append($("<div>").addClass('cooldown'));
if(options.cost) { if(options.cost) {
var ttPos = options.ttPos ? options.ttPos : "bottom right"; var ttPos = options.ttPos ? options.ttPos : "bottom right";
var costTooltip = $('<div>').addClass('tooltip ' + ttPos); var costTooltip = $('<div>').addClass('tooltip ' + ttPos);
for(var k in options.cost) { for(var k in options.cost) {
$("<div>").addClass('row_key').text(_(k)).appendTo(costTooltip); $("<div>").addClass('row_key').text(_(k)).appendTo(costTooltip);
$("<div>").addClass('row_val').text(options.cost[k]).appendTo(costTooltip); $("<div>").addClass('row_val').text(options.cost[k]).appendTo(costTooltip);
} }
if(costTooltip.children().length > 0) { if(costTooltip.children().length > 0) {
costTooltip.appendTo(el); costTooltip.appendTo(el);
} }
} }
if(options.width) { if(options.width) {
el.css('width', options.width); el.css('width', options.width);
} }
return el; return el;
}, },
setDisabled: function(btn, disabled) { setDisabled: function(btn, disabled) {
if(btn) { if(btn) {
if(!disabled && !btn.data('onCooldown')) { if(!disabled && !btn.data('onCooldown')) {
btn.removeClass('disabled'); btn.removeClass('disabled');
} else if(disabled) { } else if(disabled) {
btn.addClass('disabled'); btn.addClass('disabled');
} }
btn.data('disabled', disabled); btn.data('disabled', disabled);
} }
}, },
isDisabled: function(btn) { isDisabled: function(btn) {
if(btn) { if(btn) {
return btn.data('disabled') === true; return btn.data('disabled') === true;
} }
return false; return false;
}, },
cooldown: function(btn) { cooldown: function(btn) {
var cd = btn.data("cooldown"); var cd = btn.data("cooldown");
if(cd > 0) { if(cd > 0) {
$('div.cooldown', btn).stop(true, true).width("100%").animate({width: '0%'}, cd * 1000, 'linear', function() { $('div.cooldown', btn).stop(true, true).width("100%").animate({width: '0%'}, cd * 1000, 'linear', function() {
var b = $(this).closest('.button'); var b = $(this).closest('.button');
b.data('onCooldown', false); b.data('onCooldown', false);
if(!b.data('disabled')) { if(!b.data('disabled')) {
b.removeClass('disabled'); b.removeClass('disabled');
} }
}); });
btn.addClass('disabled'); btn.addClass('disabled');
btn.data('onCooldown', true); btn.data('onCooldown', true);
} }
}, },
clearCooldown: function(btn) { clearCooldown: function(btn) {
$('div.cooldown', btn).stop(true, true); $('div.cooldown', btn).stop(true, true);
btn.data('onCooldown', false); btn.data('onCooldown', false);
if(!btn.data('disabled')) { if(!btn.data('disabled')) {
btn.removeClass('disabled'); btn.removeClass('disabled');
} }
} }
}; };
+361 -361
View File
@@ -1,362 +1,362 @@
(function (Engine, Events, Dropbox, $) { (function (Engine, Events, Dropbox, $) {
/** /**
* Module that enables a save of the gamestate to the dropbox datastore * Module that enables a save of the gamestate to the dropbox datastore
* @see https://www.dropbox.com/developers/datastore * @see https://www.dropbox.com/developers/datastore
* *
* The dropbox datastore (dbds) connector lets you save your data to your own dropbox datastore * The dropbox datastore (dbds) connector lets you save your data to your own dropbox datastore
* without jamming files to it. * without jamming files to it.
* *
* This connector uses the game engines own base64 encoder. * This connector uses the game engines own base64 encoder.
*/ */
'use strict'; 'use strict';
if (!Engine) { return false; } // Game Engine not available if (!Engine) { return false; } // Game Engine not available
if (!Dropbox) { return false; } // Dropbox Connector not available if (!Dropbox) { return false; } // Dropbox Connector not available
var DropboxConnector = { var DropboxConnector = {
options: { options: {
log: false, log: false,
key: 'q7vyvfsakyfmp3o', key: 'q7vyvfsakyfmp3o',
table: 'adarkroom' table: 'adarkroom'
}, },
client: false, client: false,
table: false, table: false,
dropboxAccount: false, dropboxAccount: false,
savegameKey: false, savegameKey: false,
savegames: {0: null, 1: null, 2: null, 3: null, 4: null}, savegames: {0: null, 1: null, 2: null, 3: null, 4: null},
init: function (options) { init: function (options) {
this.options = $.extend( this.options = $.extend(
this.options, this.options,
options options
); );
this._log = this.options.log; this._log = this.options.log;
this.client = new Dropbox.Client({key: DropboxConnector.options.key}); this.client = new Dropbox.Client({key: DropboxConnector.options.key});
this.connectToDropbox(false); this.connectToDropbox(false);
return this; return this;
}, },
startDropbox: function () { startDropbox: function () {
if (!DropboxConnector.client || !DropboxConnector.table) { if (!DropboxConnector.client || !DropboxConnector.table) {
DropboxConnector.startDropboxConnectEvent(); DropboxConnector.startDropboxConnectEvent();
} else { } else {
DropboxConnector.startDropboxImportEvent(); DropboxConnector.startDropboxImportEvent();
} }
}, },
/** /**
* ****** * ******
* Events * Events
* ****** * ******
*/ */
startDropboxConnectEvent: function () { startDropboxConnectEvent: function () {
Events.startEvent({ Events.startEvent({
title: _('Dropbox connection'), title: _('Dropbox connection'),
scenes: { scenes: {
start: { start: {
text: [_('connect game to dropbox local storage')], text: [_('connect game to dropbox local storage')],
buttons: { buttons: {
'connect': { 'connect': {
text: _('connect'), text: _('connect'),
nextScene: 'end', nextScene: 'end',
onChoose: function () { onChoose: function () {
DropboxConnector.connectToDropbox(DropboxConnector.startDropboxImportEvent); DropboxConnector.connectToDropbox(DropboxConnector.startDropboxImportEvent);
} }
}, },
'cancel': { 'cancel': {
text: _('cancel'), text: _('cancel'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}); });
}, },
startDropboxImportEvent: function () { startDropboxImportEvent: function () {
Events.startEvent({ Events.startEvent({
title: _('Dropbox Export / Import'), title: _('Dropbox Export / Import'),
scenes: { scenes: {
start: { start: {
text: [_('export or import save data to dropbox datastorage'), text: [_('export or import save data to dropbox datastorage'),
_('your are connected to dropbox with account / email ') + DropboxConnector.dropboxAccount], _('your are connected to dropbox with account / email ') + DropboxConnector.dropboxAccount],
buttons: { buttons: {
'save': { 'save': {
text: _('save'), text: _('save'),
nextScene: {1: 'saveToSlot'} nextScene: {1: 'saveToSlot'}
}, },
'load': { 'load': {
text: _('load'), text: _('load'),
nextScene: {1: 'loadFromSlot'}, nextScene: {1: 'loadFromSlot'},
onChoose: DropboxConnector.loadGamesFromDropbox onChoose: DropboxConnector.loadGamesFromDropbox
}, },
'signout': { 'signout': {
text: _('signout'), text: _('signout'),
nextScene: 'end', nextScene: 'end',
onChoose: DropboxConnector.signout onChoose: DropboxConnector.signout
}, },
'cancel': { 'cancel': {
text: _('cancel'), text: _('cancel'),
nextScene: 'end' nextScene: 'end'
} }
} }
}, },
saveToSlot: { saveToSlot: {
text: [_('choose one slot to save to')], text: [_('choose one slot to save to')],
buttons: (function () { buttons: (function () {
var buttons = {}; var buttons = {};
$.each(DropboxConnector.savegames, function (n, savegame) { $.each(DropboxConnector.savegames, function (n, savegame) {
buttons['savegame' + n] = { buttons['savegame' + n] = {
text: _('save to slot') + n + ' ' + (savegame ? DropboxConnector.prepareSaveDate(savegame.get('timestamp')) : 'empty'), text: _('save to slot') + n + ' ' + (savegame ? DropboxConnector.prepareSaveDate(savegame.get('timestamp')) : 'empty'),
nextScene: 'end', nextScene: 'end',
onChoose: function () { onChoose: function () {
DropboxConnector.log('Save to slot ' + n + ' initiated'); DropboxConnector.log('Save to slot ' + n + ' initiated');
// timeout prevents error due to fade out animation of the previous event // timeout prevents error due to fade out animation of the previous event
window.setTimeout(function () { window.setTimeout(function () {
DropboxConnector.log('Save to slot ' + n); DropboxConnector.log('Save to slot ' + n);
DropboxConnector.saveGameToDropbox(n, DropboxConnector.savedtoDropboxEvent); DropboxConnector.saveGameToDropbox(n, DropboxConnector.savedtoDropboxEvent);
}, 1000); }, 1000);
} }
}; };
}); });
buttons.cancel = { buttons.cancel = {
text: _('cancel'), text: _('cancel'),
nextScene: 'end' nextScene: 'end'
}; };
return buttons; return buttons;
}()) }())
}, },
loadFromSlot: { loadFromSlot: {
text: [_('choose one slot to load from')], text: [_('choose one slot to load from')],
buttons: (function () { buttons: (function () {
var buttons = {}; var buttons = {};
$.each(DropboxConnector.savegames, function (n, savegame) { $.each(DropboxConnector.savegames, function (n, savegame) {
if (savegame) { if (savegame) {
buttons['savegame' + n] = { buttons['savegame' + n] = {
text: _('load from slot') + n + ' ' + DropboxConnector.prepareSaveDate(savegame.get('timestamp')), text: _('load from slot') + n + ' ' + DropboxConnector.prepareSaveDate(savegame.get('timestamp')),
nextScene: 'end', nextScene: 'end',
onChoose: function () { onChoose: function () {
DropboxConnector.log('Load from slot ' + n + ' initiated'); DropboxConnector.log('Load from slot ' + n + ' initiated');
// timeout prevents error due to fade out animation of the previous event // timeout prevents error due to fade out animation of the previous event
window.setTimeout(function () { window.setTimeout(function () {
DropboxConnector.log('Load from slot ' + n); DropboxConnector.log('Load from slot ' + n);
DropboxConnector.loadGameFromDropbox(n); DropboxConnector.loadGameFromDropbox(n);
}, 1000); }, 1000);
} }
}; };
} }
}); });
buttons.cancel = { buttons.cancel = {
text: _('cancel'), text: _('cancel'),
nextScene: 'end' nextScene: 'end'
}; };
return buttons; return buttons;
}()) }())
} }
} }
}); });
}, },
savedtoDropboxEvent: function (success) { savedtoDropboxEvent: function (success) {
Events.startEvent({ Events.startEvent({
title: _('Dropbox Export / Import'), title: _('Dropbox Export / Import'),
scenes: { scenes: {
start: { start: {
text: success ? [_('successfully saved to dropbox datastorage')] : text: success ? [_('successfully saved to dropbox datastorage')] :
[_('error while saving to dropbox datastorage')], [_('error while saving to dropbox datastorage')],
buttons: { buttons: {
'ok': { 'ok': {
text: _('ok'), text: _('ok'),
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}); });
}, },
/** /**
* *************** * ***************
* functional code * functional code
* *************** * ***************
*/ */
/** /**
* Initiate dropbox connection * Initiate dropbox connection
* *
* @param interactive * @param interactive
* @param callback * @param callback
*/ */
connectToDropbox: function (interactive, callback) { connectToDropbox: function (interactive, callback) {
DropboxConnector.log('start dropbox'); DropboxConnector.log('start dropbox');
var client = this.client; var client = this.client;
client.authenticate({interactive: interactive}, function (error) { client.authenticate({interactive: interactive}, function (error) {
if (error) { if (error) {
DropboxConnector.log('Dropbox Authentication error: ' + error); DropboxConnector.log('Dropbox Authentication error: ' + error);
} }
}); });
if (client.isAuthenticated()) { if (client.isAuthenticated()) {
var datastoreManager = client.getDatastoreManager(); var datastoreManager = client.getDatastoreManager();
datastoreManager.openDefaultDatastore(function (error, datastore) { datastoreManager.openDefaultDatastore(function (error, datastore) {
if (error) { if (error) {
DropboxConnector.log('Error opening default datastore: ' + error); DropboxConnector.log('Error opening default datastore: ' + error);
} else { } else {
DropboxConnector.table = datastore.getTable(DropboxConnector.options.table); DropboxConnector.table = datastore.getTable(DropboxConnector.options.table);
DropboxConnector.loadGamesFromDropbox(); DropboxConnector.loadGamesFromDropbox();
DropboxConnector.log(DropboxConnector.client.credentials()); DropboxConnector.log(DropboxConnector.client.credentials());
DropboxConnector.client.getAccountInfo({}, function (error, info) { DropboxConnector.client.getAccountInfo({}, function (error, info) {
if (!error) { if (!error) {
DropboxConnector.dropboxAccount = info.email; DropboxConnector.dropboxAccount = info.email;
} }
}); });
DropboxConnector.log("Got savegames", DropboxConnector.savegames); DropboxConnector.log("Got savegames", DropboxConnector.savegames);
if (typeof callback === "function") { if (typeof callback === "function") {
callback.call(DropboxConnector.table); callback.call(DropboxConnector.table);
} }
} }
}); });
} else { } else {
DropboxConnector.log('Not connected to dropbox.'); DropboxConnector.log('Not connected to dropbox.');
} }
}, },
/** /**
* Requests your savegames fom dbds * Requests your savegames fom dbds
* *
* @returns {*} * @returns {*}
*/ */
loadGamesFromDropbox: function () { loadGamesFromDropbox: function () {
var savegames = DropboxConnector.savegames; var savegames = DropboxConnector.savegames;
$.each(savegames, function (n) { $.each(savegames, function (n) {
var results = DropboxConnector.table.query({savegameId: DropboxConnector.prepareSavegameID(n)}); var results = DropboxConnector.table.query({savegameId: DropboxConnector.prepareSavegameID(n)});
savegames[n] = results[0]; savegames[n] = results[0];
}); });
return savegames; return savegames;
}, },
/** /**
* Imports a gamestate of a given slotnumber to your game * Imports a gamestate of a given slotnumber to your game
* *
* @param slotnumber * @param slotnumber
*/ */
loadGameFromDropbox: function (slotnumber) { loadGameFromDropbox: function (slotnumber) {
var table = DropboxConnector.table; var table = DropboxConnector.table;
var id = DropboxConnector.prepareSavegameID(slotnumber); var id = DropboxConnector.prepareSavegameID(slotnumber);
var results = table.query({savegameId: id}); var results = table.query({savegameId: id});
var record = results[0]; var record = results[0];
if (record && record.get('gameState')) { if (record && record.get('gameState')) {
Engine.import64(record.get('gameState')); Engine.import64(record.get('gameState'));
} }
}, },
/** /**
* Saves a gamestate to a given slot in dbds * Saves a gamestate to a given slot in dbds
* *
* @param slotnumber * @param slotnumber
* @param callback * @param callback
*/ */
saveGameToDropbox: function (slotnumber, callback) { saveGameToDropbox: function (slotnumber, callback) {
var table = DropboxConnector.table; var table = DropboxConnector.table;
var record = null; var record = null;
var success = false; var success = false;
var id = DropboxConnector.prepareSavegameID(slotnumber); var id = DropboxConnector.prepareSavegameID(slotnumber);
var saveGame = { var saveGame = {
gameState: Engine.generateExport64(), gameState: Engine.generateExport64(),
timestamp: new Date().getTime() timestamp: new Date().getTime()
}; };
if (DropboxConnector.savegames[slotnumber]) { // slot aleady used -> overwrite if (DropboxConnector.savegames[slotnumber]) { // slot aleady used -> overwrite
record = DropboxConnector.savegames[slotnumber]; record = DropboxConnector.savegames[slotnumber];
try { try {
record.update(saveGame); record.update(saveGame);
DropboxConnector.log("Updated savegame ", slotnumber); DropboxConnector.log("Updated savegame ", slotnumber);
success = true; success = true;
} catch (e) { } catch (e) {
success = false; success = false;
} }
} else { } else {
saveGame.savegameId = id; saveGame.savegameId = id;
try { try {
record = table.insert(saveGame); record = table.insert(saveGame);
DropboxConnector.log("Inserted savegame ", record.getId()); DropboxConnector.log("Inserted savegame ", record.getId());
success = true; success = true;
} catch (e) { } catch (e) {
success = false; success = false;
} }
} }
if (typeof callback === "function") { if (typeof callback === "function") {
callback(success); callback(success);
} }
}, },
/** /**
* Terminates the connection to your db account * Terminates the connection to your db account
*/ */
signout: function () { signout: function () {
DropboxConnector.client.signOut({}, function (error) { DropboxConnector.client.signOut({}, function (error) {
if (error) { if (error) {
alert('Error while logout from dropbox'); alert('Error while logout from dropbox');
} else { } else {
alert('Successfully signed out.'); alert('Successfully signed out.');
DropboxConnector.client = null; DropboxConnector.client = null;
DropboxConnector.savegames = null; DropboxConnector.savegames = null;
DropboxConnector.dropboxAccount = null; DropboxConnector.dropboxAccount = null;
} }
}); });
}, },
/** /**
* ************** * **************
* Helper methods * Helper methods
* ************** * **************
*/ */
prepareSavegameID: function (slotnumber) { prepareSavegameID: function (slotnumber) {
return 'adarkroom_savegame_' + slotnumber; return 'adarkroom_savegame_' + slotnumber;
}, },
prepareSaveDate: function (timestamp) { prepareSaveDate: function (timestamp) {
var date = new Date(timestamp); var date = new Date(timestamp);
return date.toLocaleDateString() + ' ' + date.toLocaleTimeString(); return date.toLocaleDateString() + ' ' + date.toLocaleTimeString();
}, },
log: function () { log: function () {
if (this._log) { if (this._log) {
console.log(arguments); console.log(arguments);
} }
} }
}; };
Engine.Dropbox = DropboxConnector; Engine.Dropbox = DropboxConnector;
})(Engine, Events, Dropbox, jQuery); })(Engine, Events, Dropbox, jQuery);
+43 -4
View File
@@ -605,30 +605,42 @@
switch(e.which) { switch(e.which) {
case 38: // Up case 38: // Up
case 87: case 87:
if(Engine.activeModule == Outside || Engine.activeModule == Path) {
Engine.activeModule.scrollSidebar('up');
}
Engine.log('up'); Engine.log('up');
break; break;
case 40: // Down case 40: // Down
case 83: case 83:
if (Engine.activeModule == Outside || Engine.activeModule == Path) {
Engine.activeModule.scrollSidebar('down');
}
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.activeModule.scrollSidebar('left', true);
Engine.travelTo(Outside); Engine.travelTo(Outside);
else if(Engine.activeModule == Outside && Room.tab) }else if(Engine.activeModule == Outside && Room.tab){
Engine.activeModule.scrollSidebar('left', true);
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.activeModule.scrollSidebar('right', true);
Engine.travelTo(Path); Engine.travelTo(Path);
else if(Engine.activeModule == Path && Ship.tab) }else if(Engine.activeModule == Path && Ship.tab){
Engine.activeModule.scrollSidebar('right', true);
Engine.travelTo(Ship); Engine.travelTo(Ship);
}
Engine.log('right'); Engine.log('right');
break; break;
} }
@@ -718,6 +730,33 @@
})(); })();
function inView(dir, elem){
var scTop = $('#main').offset().top;
var scBot = scTop + $('#main').height();
var elTop = elem.offset().top;
var elBot = elTop + elem.height();
if( dir == 'up' ){
// STOP MOVING IF BOTTOM OF ELEMENT IS VISIBLE IN SCREEN
return ( elBot < scBot );
}else if( dir == 'down' ){
return ( elTop > scTop );
}else{
return ( ( elBot <= scBot ) && ( elTop >= scTop ) );
}
}
function scrollByX(elem, x){
var elTop = parseInt( elem.css('top'), 10 );
elem.css( 'top', ( elTop + x ) + "px" );
}
//create jQuery Callbacks() to handle object events //create jQuery Callbacks() to handle object events
$.Dispatch = function( id ) { $.Dispatch = function( id ) {
var callbacks, topic = id && Engine.topics[ id ]; var callbacks, topic = id && Engine.topics[ id ];
+400 -400
View File
@@ -1,400 +1,400 @@
/** /**
* Events that can occur when wandering around the world * Events that can occur when wandering around the world
**/ **/
Events.Encounters = [ 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')
} }
} }
} }
]; ];
+66 -66
View File
@@ -1,66 +1,66 @@
/** /**
* Events that can occur when any module is active (Except World. It's special.) * Events that can occur when any module is active (Except World. It's special.)
**/ **/
Events.Global = [ Events.Global = [
{ /* The Thief */ { /* The Thief */
title: _('The Thief'), title: _('The Thief'),
isAvailable: function() { isAvailable: function() {
return (Engine.activeModule == Room || Engine.activeModule == Outside) && $SM.get('game.thieves') == 1; return (Engine.activeModule == Room || Engine.activeModule == Outside) && $SM.get('game.thieves') == 1;
}, },
scenes: { scenes: {
'start': { 'start': {
text: [ text: [
_('the villagers haul a filthy man out of the store room.'), _('the villagers haul a filthy man out of the store room.'),
_("say his folk have been skimming the supplies."), _("say his folk have been skimming the supplies."),
_('say he should be strung up as an example.') _('say he should be strung up as an example.')
], ],
notification: _('a thief is caught'), notification: _('a thief is caught'),
blink: true, blink: true,
buttons: { buttons: {
'kill': { 'kill': {
text: _('hang him'), text: _('hang him'),
nextScene: {1: 'hang'} nextScene: {1: 'hang'}
}, },
'spare': { 'spare': {
text: _('spare him'), text: _('spare him'),
nextScene: {1: 'spare'} nextScene: {1: 'spare'}
} }
} }
}, },
'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'
} }
} }
}, },
'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'
} }
} }
} }
} }
} }
]; ];
+3574 -3574
View File
File diff suppressed because it is too large Load Diff
+27 -27
View File
@@ -1,28 +1,28 @@
/** /**
* Module that takes care of header buttons * Module that takes care of header buttons
*/ */
var Header = { var Header = {
init: function(options) { init: function(options) {
this.options = $.extend( this.options = $.extend(
this.options, this.options,
options options
); );
}, },
options: {}, // Nothing for now options: {}, // Nothing for now
canTravel: function() { canTravel: function() {
return $('div#header div.headerButton').length > 1; return $('div#header div.headerButton').length > 1;
}, },
addLocation: function(text, id, module) { addLocation: function(text, id, module) {
return $('<div>').attr('id', "location_" + id) return $('<div>').attr('id', "location_" + id)
.addClass('headerButton') .addClass('headerButton')
.text(text).click(function() { .text(text).click(function() {
if(Header.canTravel()) { if(Header.canTravel()) {
Engine.travelTo(module); Engine.travelTo(module);
} }
}).appendTo($('div#header')); }).appendTo($('div#header'));
} }
}; };
+34 -1
View File
@@ -4,6 +4,7 @@
var Outside = { var Outside = {
name: _("Outside"), name: _("Outside"),
_STORES_OFFSET: 0,
_GATHER_DELAY: 60, _GATHER_DELAY: 60,
_TRAPS_DELAY: 90, _TRAPS_DELAY: 90,
_POP_DELAY: [0.5, 3], _POP_DELAY: [0.5, 3],
@@ -439,7 +440,7 @@ var Outside = {
this.setTitle(); this.setTitle();
if(!ignoreStores && Engine.activeModule === Outside && village.children().length > 1) { if(!ignoreStores && Engine.activeModule === Outside && village.children().length > 1) {
$('#storesContainer').css({top: village.height() + 26 + 'px'}); $('#storesContainer').css({top: village.height() + 26 + Outside._STORES_OFFSET + 'px'});
} }
}, },
@@ -610,6 +611,38 @@ var Outside = {
Outside.updateVillage(); Outside.updateVillage();
Outside.updateWorkersView(); Outside.updateWorkersView();
Outside.updateVillageIncome(); Outside.updateVillageIncome();
};
},
scrollSidebar: function(direction, reset) {
if( typeof reset != "undefined" ){
$('#village').css('top', '0px');
$('#storesContainer').css('top', '224px');
Outside._STORES_OFFSET = 0;
return false;
} }
var momentum = 10;
// If they hit up, we scroll everything down
if( direction == 'up' )
momentum = momentum * -1;
/* Let's stop scrolling if the top or bottom bound is in the viewport, based on direction */
if( direction == 'down' && inView( direction, $('#village') ) ){
return false;
}else if( direction == 'up' && inView( direction, $('#storesContainer') ) ){
return false;
}
scrollByX( $('#village'), momentum );
scrollByX( $('#storesContainer'), momentum );
Outside._STORES_OFFSET += momentum;
} }
}; };
+32 -2
View File
@@ -1,7 +1,7 @@
var Path = { var Path = {
DEFAULT_BAG_SPACE: 10, DEFAULT_BAG_SPACE: 10,
_STORES_OFFSET: 0,
// Everything not in this list weighs 1 // Everything not in this list weighs 1
Weight: { Weight: {
'bone spear': 2, 'bone spear': 2,
@@ -116,7 +116,7 @@ var Path = {
} }
if(!ignoreStores && Engine.activeModule === Path) { if(!ignoreStores && Engine.activeModule === Path) {
$('#storesContainer').css({top: perks.height() + 26 + 'px'}); $('#storesContainer').css({top: perks.height() + 26 + Path._STORES_OFFSET + 'px'});
} }
} }
}, },
@@ -312,6 +312,36 @@ var Path = {
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();
};
},
scrollSidebar: function(direction, reset){
if( typeof reset != "undefined" ){
$('#perks').css('top', '0px');
$('#storesContainer').css('top', '206px');
Path._STORES_OFFSET = 0;
return;
} }
var momentum = 10;
if( direction == 'up' )
momentum = momentum * -1
if( direction == 'down' && inView( direction, $('#perks') ) ){
return false;
}else if( direction == 'up' && inView( direction, $('#storesContainer') ) ){
return false;
}
scrollByX( $('#perks'), momentum );
scrollByX( $('#storesContainer'), momentum );
Path._STORES_OFFSET += momentum;
} }
}; };
+173 -173
View File
@@ -1,174 +1,174 @@
/** /**
* Module that registers the starship! * Module that registers the starship!
*/ */
var Ship = { var Ship = {
LIFTOFF_COOLDOWN: 120, LIFTOFF_COOLDOWN: 120,
ALLOY_PER_HULL: 1, ALLOY_PER_HULL: 1,
ALLOY_PER_THRUSTER: 1, ALLOY_PER_THRUSTER: 1,
BASE_HULL: 0, BASE_HULL: 0,
BASE_THRUSTERS: 1, BASE_THRUSTERS: 1,
name: _("Ship"), name: _("Ship"),
init: function(options) { init: function(options) {
this.options = $.extend( this.options = $.extend(
this.options, this.options,
options options
); );
if(!$SM.get('features.location.spaceShip')) { if(!$SM.get('features.location.spaceShip')) {
$SM.set('features.location.spaceShip', true); $SM.set('features.location.spaceShip', true);
$SM.setM('game.spaceShip', { $SM.setM('game.spaceShip', {
hull: Ship.BASE_HULL, hull: Ship.BASE_HULL,
thrusters: Ship.BASE_THRUSTERS thrusters: Ship.BASE_THRUSTERS
}); });
} }
// Create the Ship tab // Create the Ship tab
this.tab = Header.addLocation(_("An Old Starship"), "ship", Ship); this.tab = Header.addLocation(_("An Old Starship"), "ship", Ship);
// Create the Ship panel // Create the Ship panel
this.panel = $('<div>').attr('id', "shipPanel") this.panel = $('<div>').attr('id', "shipPanel")
.addClass('location') .addClass('location')
.appendTo('div#locationSlider'); .appendTo('div#locationSlider');
Engine.updateSlider(); Engine.updateSlider();
// Draw the hull label // Draw the hull label
var hullRow = $('<div>').attr('id', 'hullRow').appendTo('div#shipPanel'); var hullRow = $('<div>').attr('id', 'hullRow').appendTo('div#shipPanel');
$('<div>').addClass('row_key').text(_('hull:')).appendTo(hullRow); $('<div>').addClass('row_key').text(_('hull:')).appendTo(hullRow);
$('<div>').addClass('row_val').text($SM.get('game.spaceShip.hull')).appendTo(hullRow); $('<div>').addClass('row_val').text($SM.get('game.spaceShip.hull')).appendTo(hullRow);
$('<div>').addClass('clear').appendTo(hullRow); $('<div>').addClass('clear').appendTo(hullRow);
// Draw the thrusters label // Draw the thrusters label
var engineRow = $('<div>').attr('id', 'engineRow').appendTo('div#shipPanel'); var engineRow = $('<div>').attr('id', 'engineRow').appendTo('div#shipPanel');
$('<div>').addClass('row_key').text(_('engine:')).appendTo(engineRow); $('<div>').addClass('row_key').text(_('engine:')).appendTo(engineRow);
$('<div>').addClass('row_val').text($SM.get('game.spaceShip.thrusters')).appendTo(engineRow); $('<div>').addClass('row_val').text($SM.get('game.spaceShip.thrusters')).appendTo(engineRow);
$('<div>').addClass('clear').appendTo(engineRow); $('<div>').addClass('clear').appendTo(engineRow);
// Draw the reinforce button // Draw the reinforce button
new Button.Button({ new Button.Button({
id: 'reinforceButton', id: 'reinforceButton',
text: _('reinforce hull'), text: _('reinforce hull'),
click: Ship.reinforceHull, click: Ship.reinforceHull,
width: '100px', width: '100px',
cost: {'alien alloy': Ship.ALLOY_PER_HULL} cost: {'alien alloy': Ship.ALLOY_PER_HULL}
}).appendTo('div#shipPanel'); }).appendTo('div#shipPanel');
// Draw the engine button // Draw the engine button
new Button.Button({ new Button.Button({
id: 'engineButton', id: 'engineButton',
text: _('upgrade engine'), text: _('upgrade engine'),
click: Ship.upgradeEngine, click: Ship.upgradeEngine,
width: '100px', width: '100px',
cost: {'alien alloy': Ship.ALLOY_PER_THRUSTER} cost: {'alien alloy': Ship.ALLOY_PER_THRUSTER}
}).appendTo('div#shipPanel'); }).appendTo('div#shipPanel');
// Draw the lift off button // Draw the lift off button
var b = new Button.Button({ var b = new Button.Button({
id: 'liftoffButton', id: 'liftoffButton',
text: _('lift off'), text: _('lift off'),
click: Ship.checkLiftOff, click: Ship.checkLiftOff,
width: '100px', width: '100px',
cooldown: Ship.LIFTOFF_COOLDOWN cooldown: Ship.LIFTOFF_COOLDOWN
}).appendTo('div#shipPanel'); }).appendTo('div#shipPanel');
if($SM.get('game.spaceShip.hull') <= 0) { if($SM.get('game.spaceShip.hull') <= 0) {
Button.setDisabled(b, true); Button.setDisabled(b, true);
} }
// Init Space // Init Space
Space.init(); Space.init();
//subscribe to stateUpdates //subscribe to stateUpdates
$.Dispatch('stateUpdate').subscribe(Ship.handleStateUpdates); $.Dispatch('stateUpdate').subscribe(Ship.handleStateUpdates);
}, },
options: {}, // Nothing for now options: {}, // Nothing for now
onArrival: function(transition_diff) { onArrival: function(transition_diff) {
Ship.setTitle(); Ship.setTitle();
if(!$SM.get('game.spaceShip.seenShip')) { if(!$SM.get('game.spaceShip.seenShip')) {
Notifications.notify(Ship, _('somewhere above the debris cloud, the wanderer fleet hovers. been on this rock too long.')); Notifications.notify(Ship, _('somewhere above the debris cloud, the wanderer fleet hovers. been on this rock too long.'));
$SM.set('game.spaceShip.seenShip', true); $SM.set('game.spaceShip.seenShip', true);
} }
Engine.moveStoresView(null, transition_diff); Engine.moveStoresView(null, transition_diff);
}, },
setTitle: function() { setTitle: function() {
if(Engine.activeModule == this) { if(Engine.activeModule == this) {
document.title = "An Old Starship"; document.title = "An Old Starship";
} }
}, },
reinforceHull: function() { reinforceHull: function() {
if($SM.get('stores["alien alloy"]', true) < Ship.ALLOY_PER_HULL) { if($SM.get('stores["alien alloy"]', true) < Ship.ALLOY_PER_HULL) {
Notifications.notify(Ship, _("not enough alien alloy")); Notifications.notify(Ship, _("not enough alien alloy"));
return false; return false;
} }
$SM.add('stores["alien alloy"]', -Ship.ALLOY_PER_HULL); $SM.add('stores["alien alloy"]', -Ship.ALLOY_PER_HULL);
$SM.add('game.spaceShip.hull', 1); $SM.add('game.spaceShip.hull', 1);
if($SM.get('game.spaceShip.hull') > 0) { if($SM.get('game.spaceShip.hull') > 0) {
Button.setDisabled($('#liftoffButton', Ship.panel), false); Button.setDisabled($('#liftoffButton', Ship.panel), false);
} }
$('#hullRow .row_val', Ship.panel).text($SM.get('game.spaceShip.hull')); $('#hullRow .row_val', Ship.panel).text($SM.get('game.spaceShip.hull'));
}, },
upgradeEngine: function() { upgradeEngine: function() {
if($SM.get('stores["alien alloy"]', true) < Ship.ALLOY_PER_THRUSTER) { if($SM.get('stores["alien alloy"]', true) < Ship.ALLOY_PER_THRUSTER) {
Notifications.notify(Ship, _("not enough alien alloy")); Notifications.notify(Ship, _("not enough alien alloy"));
return false; return false;
} }
$SM.add('stores["alien alloy"]', -Ship.ALLOY_PER_THRUSTER); $SM.add('stores["alien alloy"]', -Ship.ALLOY_PER_THRUSTER);
$SM.add('game.spaceShip.thrusters', 1); $SM.add('game.spaceShip.thrusters', 1);
$('#engineRow .row_val', Ship.panel).text($SM.get('game.spaceShip.thrusters')); $('#engineRow .row_val', Ship.panel).text($SM.get('game.spaceShip.thrusters'));
}, },
getMaxHull: function() { getMaxHull: function() {
return $SM.get('game.spaceShip.hull'); return $SM.get('game.spaceShip.hull');
}, },
checkLiftOff: function() { checkLiftOff: function() {
if(!$SM.get('game.spaceShip.seenWarning')) { if(!$SM.get('game.spaceShip.seenWarning')) {
Events.startEvent({ Events.startEvent({
title: _('Ready to Leave?'), title: _('Ready to Leave?'),
scenes: { scenes: {
'start': { 'start': {
text: [ text: [
_("time to get out of this place. won't be coming back.") _("time to get out of this place. won't be coming back.")
], ],
buttons: { buttons: {
'fly': { 'fly': {
text: _('lift off'), text: _('lift off'),
onChoose: function() { onChoose: function() {
$SM.set('game.spaceShip.seenWarning', true); $SM.set('game.spaceShip.seenWarning', true);
Ship.liftOff(); Ship.liftOff();
}, },
nextScene: 'end' nextScene: 'end'
}, },
'wait': { 'wait': {
text: _('linger'), text: _('linger'),
onChoose: function() { onChoose: function() {
Button.clearCooldown($('#liftoffButton')); Button.clearCooldown($('#liftoffButton'));
}, },
nextScene: 'end' nextScene: 'end'
} }
} }
} }
} }
}); });
} else { } else {
Ship.liftOff(); Ship.liftOff();
} }
}, },
liftOff: function () { liftOff: function () {
$('#outerSlider').animate({top: '700px'}, 300); $('#outerSlider').animate({top: '700px'}, 300);
Space.onArrival(); Space.onArrival();
Engine.activeModule = Space; Engine.activeModule = Space;
}, },
handleStateUpdates: function(e){ handleStateUpdates: function(e){
} }
}; };