Fixed some display and other bugs

This commit is contained in:
Eric Fredricksen
2010-07-12 13:13:41 -07:00
parent 3de4e51bf5
commit e5a506d5e9
2 changed files with 52 additions and 29 deletions
+37 -14
View File
@@ -138,7 +138,7 @@ function InterplotCinematic() {
var nemesis = NamedMonster(GetI(Traits,'Level')+3); var nemesis = NamedMonster(GetI(Traits,'Level')+3);
Q('task|4|A desperate struggle commences with ' + nemesis); Q('task|4|A desperate struggle commences with ' + nemesis);
var s = Random(3); var s = Random(3);
for (var i = 1; i <= Random(1 + Plots.length()); ++i) { for (var i = 1; i <= Random(1 + game.act + 1); ++i) {
s += 1 + Random(2); s += 1 + Random(2);
switch (s % 3) { switch (s % 3) {
case 0: Q('task|2|Locked in grim combat with ' + nemesis); break; case 0: Q('task|2|Locked in grim combat with ' + nemesis); break;
@@ -351,7 +351,7 @@ function Dequeue() {
function Put(list, key, value) { function Put(list, key, value) {
if (typeof key === typeof 1) if (typeof key === typeof 1)
key = list.fixedkeys ? list.fixedkeys[key] : game[list.id][key][0]; key = list.label(key);
if (list.fixedkeys) { if (list.fixedkeys) {
game[list.id][key] = value; game[list.id][key] = value;
@@ -459,7 +459,6 @@ function ListBox(id, columns, fixedkeys) {
}; };
this.item = function (key) { this.item = function (key) {
if (typeof key == typeof 'string') {
var result = this.rows().filter(function (index) { var result = this.rows().filter(function (index) {
return Key(this) === key; return Key(this) === key;
}); });
@@ -468,9 +467,6 @@ function ListBox(id, columns, fixedkeys) {
this.box.append(result); this.box.append(result);
} }
return result; return result;
} else {
return this.box.find("tr").eq(key);
}
}; };
this.last = function () { this.last = function () {
@@ -486,7 +482,7 @@ function ListBox(id, columns, fixedkeys) {
}; };
this.length = function () { this.length = function () {
return this.rows().length; return (this.fixedkeys || game[this.id]).length;
}; };
this.remove0 = function (n) { this.remove0 = function (n) {
@@ -522,7 +518,7 @@ function ListBox(id, columns, fixedkeys) {
this.label = function (n) { this.label = function (n) {
return Key(this.item(n)); return this.fixedkeys ? this.fixedkeys[n] : game[this.id][n][0];
}; };
} }
@@ -639,8 +635,8 @@ function WinItem() {
} }
function CompleteQuest() { function CompleteQuest() {
QuestBar.reset(50 + Random(1000)); QuestBar.reset(50 + RandomLow(1000));
if (Quests.last().length) { if (Quests.length()) {
Log('Quest completed: ' + Quests.last().text()); Log('Quest completed: ' + Quests.last().text());
Quests.rows().find("input:checkbox").attr("checked", "true"); Quests.rows().find("input:checkbox").attr("checked", "true");
[WinSpell,WinEquip,WinStat,WinItem][Random(4)](); [WinSpell,WinEquip,WinStat,WinItem][Random(4)]();
@@ -762,8 +758,6 @@ function CompleteAct() {
Plots.rows().find("input:checkbox").attr("checked", "true"); Plots.rows().find("input:checkbox").attr("checked", "true");
game.act += 1; game.act += 1;
PlotBar.reset(60 * 60 * (1 + 5 * game.act)); // 1 hr + 5/act PlotBar.reset(60 * 60 * (1 + 5 * game.act)); // 1 hr + 5/act
while (Plots.length() > 99)
Plots.remove0();
Plots.AddUI((game.bestplot = 'Act ' + toRoman(game.act))); Plots.AddUI((game.bestplot = 'Act ' + toRoman(game.act)));
if (game.act > 1) { if (game.act > 1) {
@@ -809,8 +803,22 @@ function AddR(list, key, value) {
} }
function Get(list, key) { function Get(list, key) {
var item = list.item(key); if (list.fixedkeys) {
return Value(item); if (typeof key === typeof 1)
key = list.fixedkeys[key];
return game[list.id][key];
} else if (typeof key === typeof 1) {
if (key < game[list.id].length)
return game[list.id][key][1];
else
return "";
} else {
for (var i = 0; i < game[list.id].length; ++i) {
if (game[list.id][i][0] === key)
return game[list.id][i][1];
}
return "";
}
} }
function GetI(list, key) { function GetI(list, key) {
@@ -1049,6 +1057,7 @@ function Cheats() {
function HotOrNot() { function HotOrNot() {
// Figure out which spell is best // Figure out which spell is best
if (Spells.length()) {
var flat = 1; // Flattening constant var flat = 1; // Flattening constant
var best = 0, i; var best = 0, i;
for (i = 1; i < Spells.length(); ++i) { for (i = 1; i < Spells.length(); ++i) {
@@ -1057,6 +1066,9 @@ function HotOrNot() {
best = i; best = i;
} }
game.bestspell = Spells.label(best) + ' ' + Get(Spells, best); game.bestspell = Spells.label(best) + ' ' + Get(Spells, best);
} else {
game.bestspell = '';
}
/// And which stat is best? /// And which stat is best?
best = 0; best = 0;
@@ -1138,6 +1150,17 @@ function FormKeyDown(e) {
Brag("guild"); Brag("guild");
} }
if (e.which == 16) { // ^P
if (timerid)
StopTimer();
else
StartTimer();
}
if (e.which == 17) { // ^Q
quit();
}
} }
function Navigate(url) { function Navigate(url) {
+1 -1
View File
@@ -126,7 +126,7 @@ Testing:
<td><a class="icon go">&#x2694;</a></td> <td><a class="icon go">&#x2694;</a></td>
<td> <td>
<div> <div>
<a class="go"><b>$Traits.Name</b></a> the $Trace.Race ($bestplot) <a class="go"><b>$Traits.Name</b></a> the $Traits.Race ($bestplot)
</div> </div>
<div class="rc">Level $Traits.Level $Traits.Class</div> <div class="rc">Level $Traits.Level $Traits.Class</div>
<div class="bs">$bestequip / $bestspell / $beststat</div> <div class="bs">$bestequip / $bestspell / $beststat</div>