Most of the main hull of navigation working

This commit is contained in:
Eric Fredricksen
2010-07-02 21:39:26 -07:00
parent 1d4908bfb1
commit 9e7bb12434
7 changed files with 38 additions and 12 deletions
+4 -4
View File
@@ -128,10 +128,8 @@ function loadRoster() {
try { try {
r = JSON.parse(r); r = JSON.parse(r);
} catch (err) { } catch (err) {
r = []; r = {};
} }
//if (!$.isArray(roster))
// roster = [];
return r; return r;
} }
} }
@@ -141,7 +139,9 @@ function storeRoster(roster) {
} }
function addToRoster(newguy) { function addToRoster(newguy) {
storeRoster(loadRoster().concat([newguy])); var r = loadRoster();
r[newguy.name] = newguy;
storeRoster(r);
} }
var K = {}; var K = {};
+2 -1
View File
@@ -123,4 +123,5 @@
# #
+process config.js +process config.js
+process main.js +process main.js
+process newguy.js +process newguy.js
+process roster.js
+1
View File
@@ -10,6 +10,7 @@
<div id="titlebar"> <div id="titlebar">
<img src="swords.gif"> <img src="swords.gif">
<span>Progress Quest/web v8.0</span> <span>Progress Quest/web v8.0</span>
<button style="float:right;color:red" id="quit">X</button>
</div> </div>
<script src="jquery.js"></script> <script src="jquery.js"></script>
+5
View File
@@ -1019,6 +1019,11 @@ function FormCreate() {
ExpBar.reposition(0); ExpBar.reposition(0);
EncumBar.reposition(0); EncumBar.reposition(0);
$("#quit").click(function () {
window.location = "roster.html";
// TODO: save
});
LoadCharacter(); LoadCharacter();
} }
+8 -3
View File
@@ -38,11 +38,12 @@ function RollEm() {
(stats.total < (3 * 18)) ? 'silver' : (stats.total < (3 * 18)) ? 'silver' :
'white'; 'white';
Total.css("background-color", color); Total.css("background-color", color);
$("#Unroll").attr("disabled", !stats.history.length);
} }
function RerollClick() { function RerollClick() {
stats.history.push(stats.seed); stats.history.push(stats.seed);
$("#Unroll").attr("disabled", false);
RollEm(); RollEm();
} }
@@ -76,12 +77,12 @@ $(document).ready(function () {
$("#Name")[0].select(); $("#Name")[0].select();
} }
$('#Sold').click(sold); $('#Sold').click(sold);
$('#Cancel').click(cancel);
}); });
function UnrollClick() { function UnrollClick() {
randseed(stats.history.pop()); randseed(stats.history.pop());
$("#Unroll").attr("disabled", !stats.history.length);
RollEm(); RollEm();
} }
@@ -144,8 +145,12 @@ function sold() {
$.each('STR,CON,DEX,INT,WIS,CHA'.split(','), function (index,value) { $.each('STR,CON,DEX,INT,WIS,CHA'.split(','), function (index,value) {
newguy[value] = stats[value]; newguy[value] = stats[value];
}); });
alert(JSON.stringify(newguy));
addToRoster(newguy); addToRoster(newguy);
window.location = "main.html#" + newguy.name;
}
function cancel() {
window.location = "roster.html";
} }
function GenClick() { function GenClick() {
+1
View File
@@ -11,6 +11,7 @@
Here it goes Here it goes
</dl> </dl>
<button id=roll>Roll One Up</button>
<button id=test>Test</button> <button id=test>Test</button>
<button id=clear>Clear</button> <button id=clear>Clear</button>
</body> </body>
+17 -4
View File
@@ -12,13 +12,21 @@ $(document).ready(function () {
roster.text("Err...no local storage"); roster.text("Err...no local storage");
return; return;
} }
$.each(games, function (index, c) { $.each(games, function (key, c) {
var p = $("<dt/>"); var p = $("<dt/>");
p.appendTo(roster); p.appendTo(roster);
p.text(c.name);
var a = $("<a/>", {href: "main.html#" + c.name}) var a = $("<a/>", {href: "main.html#" + c.name})
a.text(c.name); a.text(c.name);
a.appendTo(p); a.appendTo(p);
var rm = $("<button/>");
rm.text("X");
rm.css("color", "red");
rm.appendTo(p);
rm.click(function () {
delete games[c.name];
storeRoster(games);
load();
});
p = $("<dd/>"); p = $("<dd/>");
p.appendTo(roster); p.appendTo(roster);
p.text("Level " + (c.level || 1) + " " + c.race + " " + c['class']); p.text("Level " + (c.level || 1) + " " + c.race + " " + c['class']);
@@ -27,14 +35,19 @@ $(document).ready(function () {
load(); load();
$("#roll").click(function () {
window.location = "newguy.html";
});
$("#test").click(function () { $("#test").click(function () {
games.push({testy:"cul", "name":"betsy"}); var n = GenerateName();
games[n] = {level: -10,name:n,race:GenerateName(),"class":GenerateName()};
storeRoster(games); storeRoster(games);
load(); load();
}); });
$("#clear").click(function () { $("#clear").click(function () {
storeRoster([]); storeRoster({});
load(); load();
}); });
}); });