Trait |
Value |
Name |
|
Race |
|
Class |
|
Level |
1 |
Stat |
Value |
STR | |
CON | |
DEX | |
INT | |
WIS | |
CHA | |
HP Max | |
MP Max | |
Weapon | |
Shield | |
Helm | |
Hauberk | |
Brassairts | |
Vambraces | |
Gauntlets | |
Gambeson | |
Cuisses | |
Greaves | |
Sollerets | |
Encumbrance
PAUSED
`')",
null,
"dialogWidth:0;dialogHeight:0;dialogHide:yes;unadorned:yes;"+
"status:no;scroll:no;center:no;dialogTop:-10000;dialogLeft:-10000");
}
function quit() {
$(window).unbind('unload');
SaveGame(function () { window.location.href = "defrag.html"; });
}
function HotOrNot() {
// Figure out which spell is best
if (Spells.length()) {
var flat = 1; // Flattening constant
var best = 0, i;
for (i = 1; i < Spells.length(); ++i) {
if ((i+flat) * toArabic(Get(Spells,i)) >
(best+flat) * toArabic(Get(Spells,best)))
best = i;
}
game.bestspell = Spells.label(best) + ' ' + Get(Spells, best);
} else {
game.bestspell = '';
}
/// And which stat is best?
best = 0;
for (i = 1; i <= 5; ++i) {
if (GetI(Stats,i) > GetI(Stats,best))
best = i;
}
game.beststat = Stats.label(best) + ' ' + GetI(Stats, best);
}
function SaveGame(callback) {
Log('Saving game: ' + GameSaveName());
HotOrNot();
game.date = ''+new Date();
game.stamp = +new Date();
game.seed = randseed();
storage.addToRoster(game, callback);
}
function LoadGame(sheet) {
if (!sheet) {
window.top.$alert("Error loading game");
window.location.href = "defrag.html";
return;
}
game = sheet;
/*
if (!window.localStorage) {
// Cookies can't hold a whole game save
storage.removeItem("roster");
storage = null;
}
*/
if (document) {
var title = "Progress Quest - " + GameSaveName();
$("#title").text(title);
if (iOS) title = GameSaveName();
document.title = title;
}
randseed(game.seed);
$.each(AllBars.concat(AllLists), function (i, e) { e.load(game); });
if (Kill)
Kill.text(game.kill);
ClearAllSelections();
$.each([Plots,Quests], function () {
this.CheckAll(true);
});
Log('Loaded game: ' + game.Traits.Name);
if (!game.elapsed)
Brag('start');
StartTimer();
}
function GameSaveName() {
if (!game.saveName) {
game.saveName = Get(Traits, 'Name');
if (game.realm)
game.saveName += ' [' + game.realm + ']';
}
return game.saveName;
}
function InputBox(message, def) {
var i = prompt(message, def || '');
return (i !== null) ? i : def;
}
function ToDna(s) {
s = s + "";
var code = {
'0': "AT",
'1': "AG",
'2': "AC",
'3': "TA",
'4': "TG",
'5': "TC",
'6': "GA",
'7': "GT",
'8': "GC",
'9': "CA",
',': "CT",
'.': "CG"
};
var r = "";
for (var i = 0; i < s.length; ++i) {
r += code[s[i]];
if (i && (i % 4) == 0) r += " ";
}
return r;
}
function FormKeyDown(e) {
var key = String.fromCharCode(e.which);
if (key === 'd') {
window.top.$alert("Your character's genome is " + ToDna(game.dna + ""));
}
if (game.isonline) {
if (key === 'b') {
Brag('brag');
//Navigate(GetHostAddr() + 'name=' + UrlEncode(Get(Traits,'Name')));
}
if (key === 'g') {
game.guild = InputBox('Choose a guild.\r\rMake sure you undestand the guild rules before you join one. To learn more about guilds, visit http://progressquest.com/guilds.php', game.guild);
Brag("guild");
}
if (key === 'm') {
game.motto = InputBox('Declare your motto!', game.motto);
Brag('motto');
}
}
if (key === 'p') {
if (timerid) {
$('#paused').css('display', 'block');
StopTimer();
} else {
$('#paused').css('display', '');
StartTimer();
}
}
if (key === 'q') {
quit();
}
if (key === 's') {
SaveGame();
window.top.$alert('Saved (' + JSON.stringify(game).length + ' bytes).');
}
/*
if (key === 't') {
TaskBar.reposition(TaskBar.Max());
}
*/
}
function Navigate(url) {
window.open(url);
}
function LFSR(pt, salt) {
var result = salt;
for (var k = 1; k <= Length(pt); ++k)
result = Ord(pt[k]) ^ (result << 1) ^ (1 && ((result >> 31) ^ (result >> 5)));
for (var kk = 1; kk <= 10; ++kk)
result = (result << 1) ^ (1 && ((result >> 31) ^ (result >> 5)));
}
function Brag(trigger) {
SaveGame();
if (game.isonline) {
game.bragtrigger = trigger;
$.post("webrag.php", game, function (data, textStatus, request) {
if (data.alert)
window.top.$alert(data.alert);
}, "json");
}
}