From 6ccb3c4d0ba221efa7989c9caf2b54cdc557b6c7 Mon Sep 17 00:00:00 2001 From: Eric Fredricksen Date: Tue, 6 Jul 2010 12:28:56 -0700 Subject: [PATCH] Fix progbar on Prologue --- config.js | 3 ++- main.js | 63 ++++++++++++++++++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/config.js b/config.js index e180be4..e75f5cf 100644 --- a/config.js +++ b/config.js @@ -23,7 +23,8 @@ function template(tmpl, data) { } return null; }); - return dict || ''; + if (dict === undefined) dict = ''; + return dict; }); return brag; } diff --git a/main.js b/main.js index 39f2254..c64032e 100644 --- a/main.js +++ b/main.js @@ -3,7 +3,6 @@ // TODO: Test use of seed as DNA // TODO: Layout newguy and main better // TODO: fix Prologue plot bar -// TODO: limit number of Acts // TODO: get first quest // revs: @@ -535,7 +534,34 @@ var Kill; var AllBars, AllLists; -function GoButtonClick() { +function InitializeCharacter(sheet) { + game = sheet; + + Put(Traits, 'Name', sheet.name); + Put(Traits, 'Level', 1); + Put(Traits, 'Race', sheet.race); + Put(Traits, 'Class', sheet['class']); + + Put(Stats, 'STR', sheet.STR); + Put(Stats, 'CON', sheet.CON); + Put(Stats, 'DEX', sheet.DEX); + Put(Stats, 'INT', sheet.INT); + Put(Stats, 'WIS', sheet.WIS); + Put(Stats, 'CHA', sheet.CHA); + Put(Stats, 'HP Max', Random(8) + sheet.CON.div(6)); + Put(Stats, 'MP Max', Random(8) + sheet.INT.div(6)); + + game.Equips = {best: 'Sharp Stick'}; + Put(Equips, 'Weapon', game.Equips.best); + + Put(Inventory,'Gold',0); + + SaveGame(); + + ClearAllSelections(); + + // GoButtonClick(); + ExpBar.reset(LevelUpTime(1)); game.task = ''; @@ -551,13 +577,13 @@ function GoButtonClick() { PlotBar.reset(26); Plots.Add('Prologue'); + game.act = 0; + //debugger; QuestBar.reset(1); EncumBar.reset(GetI(Stats, "STR") + 10); - Put(Inventory, "Gold", 0); - Put(Equips, "Hauberk", "-3 Burlap"); ClearAllSelections(); @@ -793,8 +819,11 @@ function toArabic(s) { function CompleteAct() { Plots.rows().find("input:checkbox").attr("checked", "true"); - PlotBar.reset(60 * 60 * (1 + 5 * Plots.length())); // 1 hr + 5/act - Plots.Add('Act ' + toRoman(Plots.length())); + game.act += 1; + PlotBar.reset(60 * 60 * (1 + 5 * game.act)); // 1 hr + 5/act + while (Plots.length() > 99) + Plots.remove(0); + Plots.Add('Act ' + toRoman(game.act)); WinItem(); WinEquip(); @@ -924,7 +953,7 @@ function Timer1Timer() { } // advance plot - if (gain) { + if (gain || !game.act) { if (PlotBar.done()) InterplotCinematic(); else @@ -982,25 +1011,7 @@ function LoadCharacter() { if (!sheet.Traits) { // New game - game = sheet; - Put(Traits, 'Name', sheet.name); - Put(Traits, 'Level', 1); - Put(Traits, 'Race', sheet.race); - Put(Traits, 'Class', sheet['class']); - Put(Stats, 'STR', sheet.STR); - Put(Stats, 'CON', sheet.CON); - Put(Stats, 'DEX', sheet.DEX); - Put(Stats, 'INT', sheet.INT); - Put(Stats, 'WIS', sheet.WIS); - Put(Stats, 'CHA', sheet.CHA); - Put(Stats, 'HP Max', Random(8) + sheet.CON.div(6)); - Put(Stats, 'MP Max', Random(8) + sheet.INT.div(6)); - game.Equips = {best: 'Sharp Stick'}; - Put(Equips, 'Weapon', game.Equips.best); - Put(Inventory,'Gold',0); - SaveGame(); - ClearAllSelections(); - GoButtonClick(); + InitializeCharacter(sheet); } else { LoadGame(sheet); }