Logo and get best stats showing on roster

This commit is contained in:
Eric Fredricksen
2010-07-04 00:10:03 -07:00
parent 1f5b6fc4d5
commit d71fb597da
6 changed files with 61 additions and 37 deletions
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

+3
View File
@@ -5,6 +5,9 @@
</head> </head>
<body> <body>
<img src="logo.png" alt="Progress Quest">
<div class="vbox window"> <div class="vbox window">
<div id="titlebar"> <div id="titlebar">
+36 -15
View File
@@ -12,16 +12,16 @@
var RevString = '&rev=6'; var RevString = '&rev=6';
var game = {}; // queue: [] }; var game = {}; // queue: [] };
var lasttick, timerid;
function timeGetTime() { function timeGetTime() {
return new Date().getTime(); return new Date().getTime();
} }
function StartTimer() { function StartTimer() {
if (!game.timerid) { if (!timerid) {
game.lasttick = timeGetTime(); lasttick = timeGetTime();
game.timerid = setInterval(Timer1Timer, 100); timerid = setInterval(Timer1Timer, 100);
} }
// BS location for this, but... // BS location for this, but...
// MainForm.Caption = 'ProgressQuest - ' + ChangeFileExt(ExtractFileName(MainForm.GameSaveName()), ''); // MainForm.Caption = 'ProgressQuest - ' + ChangeFileExt(ExtractFileName(MainForm.GameSaveName()), '');
@@ -449,6 +449,7 @@ function ListBox(id, columns, fixedkeys) {
var tr = $("<tr><td>" + caption + "</td></tr>"); var tr = $("<tr><td>" + caption + "</td></tr>");
tr.appendTo(this.box); tr.appendTo(this.box);
tr.each(function () {this.scrollIntoView();}); tr.each(function () {this.scrollIntoView();});
game[this.id].last = caption;
return tr; return tr;
}; };
@@ -492,14 +493,16 @@ function ListBox(id, columns, fixedkeys) {
}; };
this.save = function (game) { this.save = function (game) {
var dict = {html: this.box.html()}; if (!game[this.id])
game[this.id] = {};
var dict = game[this.id];
dict.html = this.box.html();
if (this.columns == 2) { if (this.columns == 2) {
this.rows().each(function (index) { this.rows().each(function (index) {
dict[$(this).children().first().text()] = dict[$(this).children().first().text()] =
$(this).children().last().text(); $(this).children().last().text();
}); });
} }
game[this.id] = dict;
}; };
this.load = function (game) { this.load = function (game) {
@@ -565,6 +568,16 @@ $(document).ready(FormCreate);
function WinSpell() { function WinSpell() {
AddR(Spells, K.Spells[RandomLow(Min(GetI(Stats,'WIS')+GetI(Traits,'Level'), AddR(Spells, K.Spells[RandomLow(Min(GetI(Stats,'WIS')+GetI(Traits,'Level'),
K.Spells.length))], 1); K.Spells.length))], 1);
// Now figure out which spell is best
// TODO: really only need to check the one we just ++'d
var flat = 1; // Flattening constant
var best = 0;
for (var i = 1; i < Spells.length(); ++i)
if ((i+flat) * toArabic(Get(Spells,i)) >
(best+flat) * toArabic(Get(Spells,best)))
best = i;
game.Spells.best = Spells.label(best) + ' ' + Get(Spells, best);
} }
function LPick(list, goal) { function LPick(list, goal) {
@@ -585,7 +598,7 @@ function Abs(x) {
function WinEquip() { function WinEquip() {
var posn = Random(Equips.length()); var posn = Random(Equips.length());
game.bestequip = posn; // remember as the "best item"
if (!posn) { if (!posn) {
stuff = K.Weapons; stuff = K.Weapons;
better = K.OffenseAttrib; better = K.OffenseAttrib;
@@ -615,6 +628,8 @@ function WinEquip() {
if (plus > 0) name = '+' + name; if (plus > 0) name = '+' + name;
Put(Equips, posn, name); Put(Equips, posn, name);
game.Equips.best = name;
if (posn > 1) game.Equips.best += ' ' + Equips.label(posn);
} }
@@ -638,6 +653,13 @@ function WinStat() {
}); });
} }
Add(Stats, $(i).find("td").first().text(), 1); Add(Stats, $(i).find("td").first().text(), 1);
var best = 0;
for (var i = 1; i <= 5; ++i) {
if (GetI(Stats,i) > GetI(Stats,best))
best = i;
}
game.Stats.best = Stats.label(best) + ' ' + GetI(Stats, best);
} }
function SpecialItem() { function SpecialItem() {
@@ -993,12 +1015,12 @@ function Timer1Timer() {
Dequeue(); Dequeue();
} else { } else {
var elapsed = timeGetTime() - game.lasttick; var elapsed = timeGetTime() - lasttick;
if (elapsed > 100) elapsed = 100; if (elapsed > 100) elapsed = 100;
if (elapsed < 0) elapsed = 0; if (elapsed < 0) elapsed = 0;
TaskBar.increment(elapsed); TaskBar.increment(elapsed);
} }
game.lasttick = timeGetTime(); lasttick = timeGetTime();
} }
function FormCreate() { function FormCreate() {
@@ -1065,7 +1087,7 @@ function LoadCharacter() {
function FormShow() { function FormShow() {
if (game.timerid) return; if (timerid) return;
var done = false; var done = false;
var exportandexit = false; var exportandexit = false;
@@ -1125,9 +1147,9 @@ $(function() {
}); });
cheat("Pause", function () { cheat("Pause", function () {
if (game.timerid) { if (timerid) {
clearTimeout(game.timerid); clearTimeout(timerid);
game.timerid = null; timerid = null;
} else { } else {
StartTimer(); StartTimer();
} }
@@ -1245,8 +1267,7 @@ function Brag(trigger) {
with (Traits) for (i = 0; i <= Items.length()-1; ++i) with (Traits) for (i = 0; i <= Items.length()-1; ++i)
url = url + '&' + LowerCase(Items[i].Caption[1]) + '=' + UrlEncode(Items[i].Subitems[0]); url = url + '&' + LowerCase(Items[i].Caption[1]) + '=' + UrlEncode(Items[i].Subitems[0]);
url = url + '&x=' + IntToStr(ExpBar.Position); url = url + '&x=' + IntToStr(ExpBar.Position);
url = url + '&i=' + UrlEncode(Get(Equips, game.bestequip)); url = url + '&i=' + UrlEncode(game.Equips.best);
if (game.bestequip > 1) url = url + '+' + Equips[game.bestequip].Caption;
var best = 0; var best = 0;
if (Spells.length() > 0) with (Spells) { if (Spells.length() > 0) with (Spells) {
for (i = 1; i <= Items.length()-1; ++i) for (i = 1; i <= Items.length()-1; ++i)
+3
View File
@@ -12,6 +12,9 @@ input, button { display: inline; }
</head> </head>
<body> <body>
<img src="logo.png" alt="Progress Quest">
<div class="vbox window"> <div class="vbox window">
<div id="titlebar"> <div id="titlebar">
+10 -2
View File
@@ -16,13 +16,20 @@ div.rc {
font: 8pt Verdana font: 8pt Verdana
} }
div.best { div.bs {
font: 7pt Verdana font: 7pt Verdana
} }
td.brag button {
color: red;
}
</style> </style>
</head> </head>
<body> <body>
<img src="logo.png" alt="Progress Quest">
<dl id=roster> <dl id=roster>
Here it goes Here it goes
</dl> </dl>
@@ -37,7 +44,8 @@ Here it goes
<script id="bumble" type="text/html"> <script id="bumble" type="text/html">
<table><tr><td class="brag"> <table><tr><td class="brag">
<div> <div>
<a><b>$Traits.Name</b></a> of Localhost ($Plots.act) <a><b>$Traits.Name</b></a> of Localhost ($Plots.last)
<button>X</button>
</div> </div>
<div class="rc">Level $Traits.Level $Traits.Race $Traits.Class</div> <div class="rc">Level $Traits.Level $Traits.Race $Traits.Class</div>
<div class="bs">$Equips.best / $Spells.best / $Stats.best</div> <div class="bs">$Equips.best / $Spells.best / $Stats.best</div>
+8 -19
View File
@@ -5,7 +5,6 @@ $(document).ready(function () {
function load() { function load() {
var roster = $("#roster"); var roster = $("#roster");
roster.empty(); roster.empty();
roster.text("Loading...");
games = loadRoster() games = loadRoster()
if (!games) { if (!games) {
@@ -13,31 +12,21 @@ $(document).ready(function () {
return; return;
} }
$.each(games, function (key, c) { $.each(games, function (key, c) {
roster.append(brag(c)); var name = c.Traits.Name;
var p = $("<p/>"); var br = brag(c);
p.appendTo(roster); roster.append(br);
p.text(JSON.stringify(c)); br.find("a").attr("href", "main.html#" + name)
var p = $("<dt/>"); br.find("button").click(function () {
p.appendTo(roster); delete games[name];
var a = $("<a/>", {href: "main.html#" + c.name})
a.text(c.name);
a.appendTo(p);
var rm = $("<button/>");
rm.text("X");
rm.css("color", "red");
rm.appendTo(roster);
rm.click(function () {
delete games[c.name];
storeRoster(games); storeRoster(games);
load(); load();
}); });
p = $("<dd/>"); var p = $("<p style='font:6pt verdana'/>");
p.appendTo(roster); p.appendTo(roster);
p.text("Level " + (c.level || 1) + " " + c.race + " " + c['class']); p.text(JSON.stringify(c));
}); });
} }