Fixed various logic bugs

This commit is contained in:
Eric Fredricksen
2010-06-26 15:54:45 -07:00
parent a848e97d2c
commit 0e79521c2f
2 changed files with 21 additions and 17 deletions
+1 -1
View File
@@ -570,7 +570,7 @@ K.Monsters = [
"Unicorn|4|blood", "Unicorn|4|blood",
"Vampire|8|pancreas", "Vampire|8|pancreas",
"Wight|4|lung", "Wight|4|lung",
"Will-o-the-Wisp|9|wisp", "Will-o'-the-Wisp|9|wisp",
"Wraith|5|finger", "Wraith|5|finger",
"Wyvern|7|wing", "Wyvern|7|wing",
"Xorn|7|jaw", "Xorn|7|jaw",
+19 -15
View File
@@ -78,7 +78,7 @@ function PickLow(s) {
} }
function Copy(s, b, l) { function Copy(s, b, l) {
return s.substr(b, l); return s.substr(b-1, l);
} }
function Length(s) { function Length(s) {
@@ -318,22 +318,23 @@ function Dequeue() {
if (Split(game.task,3) == '*') { if (Split(game.task,3) == '*') {
WinItem(); WinItem();
} else if (Split(game.task,3) != '') { } else if (Split(game.task,3) != '') {
Add(Inventory,LowerCase(Split(game.task,1) + ' ' + ProperCase(Split(game.task,3))),1); Add(Inventory,LowerCase(Split(game.task,1) + ' ' +
ProperCase(Split(game.task,3))),1);
} }
} else if (game.task == 'buying') { } else if (game.task == 'buying') {
// buy some equipment // buy some equipment
Add(Inventory,'Gold',-EquipPrice()); Add(Inventory,'Gold',-EquipPrice());
WinEquip(); WinEquip();
} else if ((game.task == 'market') || (game.task == 'sell')) { } else if ((game.task == 'market') || (game.task == 'sell')) {
if (game.task = 'sell') { if (game.task == 'sell') {
var amt = GetI(Inventory, 1) * GetI(Traits,'Level'); var amt = GetI(Inventory, 1) * GetI(Traits,'Level');
if (Pos(' of ', Inventory.label(1) > 0)) if (Pos(' of ', Inventory.label(1)) > 0)
amt *= (1+RandomLow(10)) * (1+RandomLow(GetI(Traits,'Level'))); amt *= (1+RandomLow(10)) * (1+RandomLow(GetI(Traits,'Level')));
Inventory.scrollToTop(); Inventory.scrollToTop();
Inventory.poptop(); Inventory.remove(1);
Add(Inventory, 'Gold', amt); Add(Inventory, 'Gold', amt);
} }
if (Items.length() > 1) { if (Inventory.length() > 1) {
Task('Selling ' + Indefinite(Inventory.label(1), GetI(Inventory,1)), Task('Selling ' + Indefinite(Inventory.label(1), GetI(Inventory,1)),
1 * 1000); 1 * 1000);
game.task = 'sell'; game.task = 'sell';
@@ -484,8 +485,8 @@ function ListBox(id) {
return this.rows().length; return this.rows().length;
} }
this.poptop = function () { this.remove = function (n) {
this.box.find("tr").first().remove(); this.box.find("tr").eq(n).remove();
} }
this.save = function (game) { this.save = function (game) {
@@ -500,6 +501,10 @@ function ListBox(id) {
for (var i = 0; i < game[this.id].length; ++i) for (var i = 0; i < game[this.id].length; ++i)
this.box.appeand(game[this.id][i]); this.box.appeand(game[this.id][i]);
} }
this.label = function (n) {
return this.item(n).children().first().text();
}
}; };
@@ -655,8 +660,8 @@ function CompleteQuest() {
/*$ENDIF*/ /*$ENDIF*/
Quests.last().wrap("<s/>"); Quests.last().wrap("<s/>");
[WinSpell,WinEquip,WinStat,WinItem][Random(4)](); [WinSpell,WinEquip,WinStat,WinItem][Random(4)]();
while (Quest.box.children().length > 99) while (Quests.length() > 99)
Quest.poptop(); Quests.remove(0);
game.questmonster = ''; game.questmonster = '';
var caption; var caption;
@@ -701,14 +706,13 @@ function CompleteQuest() {
game.questmonster = ''; // We're trying to placate them, after all game.questmonster = ''; // We're trying to placate them, after all
break; break;
} }
Quest.Add(caption); Quests.Add(caption);
/*$IFDEF LOGGING*/ /*$IFDEF LOGGING*/
Log('Commencing quest: ' + caption); Log('Commencing quest: ' + caption);
/*$ENDIF*/ /*$ENDIF*/
Quests.scrollToBottom(); Quests.scrollToBottom();
} }
Quest.Width = Quest.Width - 1; // trigger a column resize
SaveGame(); SaveGame();
} }
@@ -839,8 +843,8 @@ function TMainForm_CharSheet() {
WrLn( ' ' + LeftStr(Equips[i].Caption + ' ', 12) + Get(Equips,i)); WrLn( ' ' + LeftStr(Equips[i].Caption + ' ', 12) + Get(Equips,i));
WrLn(); WrLn();
WrLn( 'Spell Book:'); WrLn( 'Spell Book:');
for (var i = 1; i <= Items.length()-1; ++i) for (var i = 0; i < Spells.length(); ++i)
WrLn( ' ' + Spells[i].Caption + ' ' + Get(Spells,i)); WrLn(' ' + Spells.label(i) + ' ' + Get(Spells,i));
WrLn(); WrLn();
WrLn( 'Inventory (' + EncumBar.Hint + '):'); WrLn( 'Inventory (' + EncumBar.Hint + '):');
WrLn( ' ' + Indefinite('gold piece', GetI(Inventory, 'Gold'))); WrLn( ' ' + Indefinite('gold piece', GetI(Inventory, 'Gold')));
@@ -944,7 +948,7 @@ function RoughTime(s) {
else return s.div(3600 * 24) + ' days'; else return s.div(3600 * 24) + ' days';
} }
function Pos(haystack, needle) { function Pos(needle, haystack) {
return haystack.indexOf(needle) + 1; return haystack.indexOf(needle) + 1;
} }