Commits

Anonymous committed 5778897

FIX: get_experience broke when the char didn’t improve.

  • Participants
  • Parent commits cfdee3e
  • Branches py3

Comments (0)

Files changed (2)

File rpg_lib/anyrpg.py

 
         # Info text for each char.
         for char in chars:
-            for i in range(amount): 
-                result = char.incremental_upgrade(amount=1)
-                if result: 
-                    text += result 
+            result = char.incremental_upgrade(amount=amount)
+            if result: 
+                text += result 
             
         # Dialog footer. 
         text += self.get_experience_footer(chars, amount=amount)
     def incremental_upgrade(self, amount=0): 
         # Upgrade in single point steps, so the experience gets spread a bit. 
         # if it's less than two points, use it completely. 
-        if amount <= 2: 
+        if amount < 2: 
             text = self.upgrade_info(self, amount)
         # If it's more than one point, spread all but one in single points 
         # and at last improve by 1 plus the remaining fraction. 
         else: 
             text = ""
             for j in range(int(amount) -1): 
-                text += self.upgrade_info(self, 1)
-            text += self.upgrade_info(self, amount - int(amount) + 1)
+                res =  self.upgrade_info(self, 1)
+                if res:
+                    text += res
+            res = self.upgrade_info(self, amount - int(amount) + 1)
+            if res:
+                text += res
         return text
     
     def battle(self, other): 

File rpg_lib/textrpg.py

     """Give one char experience and advance him/her with the exp."""
     return story_helper.give_exp(char, amount, *args, **kwds)
 
+def get_experience(chars, amount, *args, **kwds): 
+    """Give one char experience and advance him/her with the exp."""
+    return story(story_helper.get_experience(chars, amount, *args, **kwds))
+
 def save(chars=[], *args, **kwds): 
     """Save each passed char."""
     return story_helper.save(chars=chars, *args, **kwds)