From ead5a61dc75d22dadbe0b27e9d76cd05ac7560b8 Mon Sep 17 00:00:00 2001 From: Eric Fredricksen Date: Fri, 2 Dec 2011 14:36:17 -0800 Subject: [PATCH] Make character load if exists in sim.js --- main.js | 4 ++-- sim.js | 26 +++++++++++++++----------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/main.js b/main.js index d21ac97..fa0a1b1 100644 --- a/main.js +++ b/main.js @@ -996,7 +996,7 @@ function pause(msec) { function quit() { $(window).unbind('unload'); - SaveGame(function () { window.location = "roster.html"; }); + SaveGame(function () { window.location.href = "roster.html"; }); } @@ -1037,7 +1037,7 @@ function SaveGame(callback) { function LoadGame(sheet) { if (!sheet) { alert("Error loading game"); - window.location = "roster.html"; + window.location.href = "roster.html"; return; } diff --git a/sim.js b/sim.js index ae325a0..52fcb5d 100644 --- a/sim.js +++ b/sim.js @@ -11,6 +11,9 @@ // It's not realtime - simulation runs at maximum speed and the // virtual time elapsed is displayed at each level-up. +var CHARACTER = "Shienzid"; +//var guy = window.location.href.split("#")[1]; + var window = { location: {href: "#Woogle"}, @@ -117,21 +120,12 @@ var cs = 0; storage.loadRoster(function (cs) { for (var c in cs) cs++; }); print(cs, "characters"); -load("newguy.js"); -NewGuyFormLoad(); -traits.Name = "Shienzid"; -sold(); - -write("local.storage", JSON.stringify(window.localStorage.items)); - -var guy = window.location.href.split("#")[1]; - -load("main.js"); var timeGetTime = global.timeGetTime = function () { return now; } +load("main.js"); FormCreate(); function charsheet(game) { @@ -151,8 +145,18 @@ for (var j = 1, t = 0; j < 1001; ++j) { } var tmpl = read("charsheet.txt"); -storage.loadSheet("Shienzid", function (sheet) { +storage.loadSheet(CHARACTER, function (sheet) { + if (!sheet) { + load("newguy.js"); + NewGuyFormLoad(); + traits.Name = CHARACTER; + sold(); + sheet = storage.games[CHARACTER]; + } + //write("local.storage", JSON.stringify(window.localStorage.items)); + game = sheet; + LoadGame(game); print(template(''+tmpl, sheet)); var l = 0;