From 4a0bc0c4fb157503f9b5cc0e80515b4657fa3c5d Mon Sep 17 00:00:00 2001 From: rustushki Date: Mon, 6 Nov 2006 03:42:09 +0000 Subject: [PATCH] Some more debuging mostly. Got it to where you can play several battles in a row, gaining experience and building levels. Most aptly several bugs were fixed: 1. Save/Load path name stripping. There was a newline at the end of each pathname that is entered by user. 2. When a new random battle is created, the time of move is reinitialized for each playable fighter. 3. When a new random battle is created, the current battle time is reset to zero 4. Job class statistic changes weren't being initialized properly. Bad xpath query. --- consolecontroller.py | 28 ++++++++++++++++++++++------ fighter.py | 10 +++++++++- utilities.py | 7 ++++--- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/consolecontroller.py b/consolecontroller.py index 9c79164..84540ea 100644 --- a/consolecontroller.py +++ b/consolecontroller.py @@ -85,8 +85,6 @@ class ConsoleController: self.loadStaticData(False) while True: - - choice = 0 while choice != 4: choice = self.getMenuCommand() @@ -94,24 +92,30 @@ class ConsoleController: if choice == 1: self.unloadStaticData() self.loadStaticData(True) + print "loaded..." else: if choice == 2: print "Path to Save File: ", path = sys.stdin.readline() - self.load("" + path + "") + self.load("" + path.strip() + "") print "loaded..." print "=============================================================" elif choice == 3: print "Path to Save File: ", path = sys.stdin.readline() - self.save("" + path + "") + self.save("" + path.strip() + "") print "saved..." print "=============================================================" elif choice == 4: - self.createRandomBattle() - print "=============================================================" + + if self.__battle.getParty1().sizeOfParty() == 0: + print "No game loaded." + choice = 0 + else: + self.createRandomBattle() + print "=============================================================" else: sys.exit() @@ -146,6 +150,10 @@ class ConsoleController: else: print "Game Over. Asgard mourns." + + # clear out the hero party - they're dead! + self.__battle.setParty1(None) + def load(self,savefile): #clear party1 and it's fighters @@ -203,6 +211,14 @@ class ConsoleController: monster = copy.deepcopy(self.__battle.getMonsters()[monstI]) self.__battle.getParty2().addFighter(monster) + + for f in self.__battle.getParty1().getFighters(): + spd = f.getStat("spd").getCurrent() + tom = round((1/float(spd)*100)) + f.getStat("tom").setCurrent(tom) + f.getStat("tom").setMax(tom) + + self.__battle.setCurrentTime(0) diff --git a/fighter.py b/fighter.py index 3ff1f89..7df10b6 100644 --- a/fighter.py +++ b/fighter.py @@ -75,7 +75,7 @@ class Fighter: current = max (plus,chance,growthRate) = jobStatQuery(jTree, sname) - + stat = Statistic(sname,current,max,afterBattle,plus,chance,growthRate) self.__stats.append(stat) @@ -286,8 +286,14 @@ class Fighter: exptnl_s = self.getStat("exptnl") exptnl_s.setCurrent(exptnl_s.getCurrent() - exp) + print self.getStat("level").getCurrent() + print exp + print self.getStat("exptnl").getCurrent() + print self.getStat("exptnl").getMax() + # Level up? while exptnl_s.getCurrent() <= 0: + print "hello!" # Increase level number level_s = self.getStat("level") level_s.setCurrent(level_s.getCurrent() + 1) @@ -297,7 +303,9 @@ class Fighter: # Increase hp? x = randint(1,100) hp = self.getStat("hp") + print hp.getChance() * 100 if x <= hp.getChance() * 100: + print "test1" hp.setMax(hp.getMax() + hp.getPlus()) # Increase strength? diff --git a/utilities.py b/utilities.py index f153c52..8acdf5d 100644 --- a/utilities.py +++ b/utilities.py @@ -48,8 +48,8 @@ def jobStatQuery(jTree,sname): growthRate = 0.0 chance = 0.0 - jStatQuery = jTree.xpathEval("/stat[@name='" + sname + "']") - + jStatQuery = jTree.xpathEval("//stat[@name='" + sname + "']") + if jStatQuery != []: jStatElem = jStatQuery[0] @@ -60,6 +60,7 @@ def jobStatQuery(jTree,sname): growthRate = float(jStatElem.prop("growthRate")) if jStatElem.prop("chance") != None: - growthRate = float(jStatElem.prop("chance")) + chance = float(jStatElem.prop("chance")) + return (plus,chance,growthRate) -- 2.11.4.GIT