Commits

Arne Babenhauserheide  committed a53fd5c

FIX: Experience dialog: Don't interact with the user, just return the data.

  • Participants
  • Parent commits f4b665f

Comments (0)

Files changed (1)

 
 
 class Dialogs(object): 
+    """Basic dialogs. 
+    
+    A dialog never interacts with the user directly, it just provides template for otehr code.
+    
+    If you want a specific interaction, write a function in UserInteraction, or split the dialog."""
     def __init__(self, *args, **kwds): 
         super(Dialogs, self).__init__(*args, **kwds)
     
     def get_experience(self, chars, amount=0):
         """Show the experience the chars get and what they do with it."""
-        for i in self.get_experience_header(chars=chars, amount=amount).splitlines(): 
-            self.diag(i)
+        text = ""
+        print self.get_experience_header(chars=chars, amount=amount)
             
         # Info text for each char. 
         for i in chars: 
-            text = i.incremental_upgrade(amount=1)
-            if text: 
-                for j in text.splitlines():
-                    self.diag(j)
+            result = i.incremental_upgrade(amount=1)
+            if result: 
+                text += result 
             
         # Dialog footer. 
-        for i in self.get_experience_footer(chars, amount=amount).splitlines(): 
-            self.diag(i)
+        text += self.get_experience_footer(chars, amount=amount)
+        return text
     
     def get_experience_header(self, chars, amount=0):
         """@return: The header line of the experience dialog."""
         old_value = upgrade[0].items()[0][1]["Zahlenwert"] 
         new_value = upgrade[1].items()[0][1]["Zahlenwert"]
         if old_value < new_value:
-            return char.name + " raised " + item_name + " from " + str(old_value) + " to " + str(new_value)
+            return char.name + " raised " + item_name + " from " + str(old_value) + " to " + str(new_value) + "\n"
         else: 
             return False
 
     
     def get_exp(self, amount=0): 
         """Get experience and show it."""
-        self.get_experience([self], amount)
+        for i in self.get_experience([self], amount).splitlines(): 
+            self.diag(i)
     
     def incremental_upgrade(self, amount=0): 
         # Upgrade in single point steps, so the experience gets spread a bit. 
     
     def give_exp(self, char, amount=0): 
         """Give experience to only one char."""
-        return self.get_experience([char], amount=amount)
+        for i in self.get_experience([char], amount=amount).splitlines(): 
+            diag(i)
 
 
 class MissingScriptingFunction(Exception):