Commits

Anonymous committed ed4ac64

replaced \n with linesep for cross-platform compatibility.

Comments (0)

Files changed (1)

rpg_lib/anyrpg.py

 	sys.stdout.write(" " * len(_("...press enter to read on...")))
 	#sys.stdout.flush()
 	sys.stdout.write('\033[' + str(position_in_line) + 'G')
-	sys.stdout.write("\n")
+	sys.stdout.write(linesep)
 	sys.stdout.flush()
 	#sleep(special_wait["linesep"])
     
 	if end_with_linebreak: 
 	    # Move back after the last char on the last line. 
 	    sleep(special_wait.get(linesep, 0))
-	    sys.stdout.write("\n")
+	    sys.stdout.write(linesep)
             sys.stdout.flush()
 
 	if wait_for_input: 
         """@return: The header line of the experience dialog."""
         scribble = ""
         if len(chars) == 1: 
-            scribble += "\n***experience of " + chars[0].name + "***\n"
+            scribble += linesep+"***experience of " + chars[0].name + "***"+linesep
             scribble += chars[0].name + " got " + str(amount) + " experience."
         else: 
-            scribble += "\n***experience***\n"
+            scribble += linesep+"***experience***"+linesep
             scribble += "The characters got " + str(amount) + " experience."
         return scribble
     
     def get_experience_footer(self, chars, amount=0):
         """@return: The header line of the experience dialog."""
-        return "***/experience***\n"
+        return "***/experience***"+linesep
     
     
     def upgrade_info(self, char, amount): 
         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) + "\n"
+            return char.name + " raised " + item_name + " from " + str(old_value) + " to " + str(new_value) + linesep
         else: 
             return False
 
 	    data = _(data)
 	if len(data.splitlines()) > 1: 
 	    # First say the first part of the question. 
-	    self.say("\n".join(data.splitlines()[:-1]), localize=False, *args, **kwds)
+	    self.say(linesep.join(data.splitlines()[:-1]), localize=False, *args, **kwds)
 	# Then ask the last line
         return super(Char, self).ask(' ' * indent + data.splitlines()[-1], localize = False, *args, **kwds)
     
             \033[0GMins walks away.
         """
         data = _(data)
-        for i in data.split("\n"): 
+        for i in data.splitlines(): 
             self.split_diag(self.name + ' ' + i, localize=False, *args, **kwds)
         
     def compete_skill(self, other, skill_name, self_mods=[], other_mods=[]): 
         """Status information about a battle.
         
         @return: Completely formatted String to display. """
-        return "\n" + me.battle_stats() + "\n\n" + other.battle_stats() + "\n"
+        return linesep + me.battle_stats() + linesep+linesep + other.battle_stats() + linesep
     
     def battle_round_result(self, me, other, won, injuries_self, injuries_other): 
         """Return the result of one round of battle. Called with the battle results (won, injuries_self, injuries_other)."""
         if won: 
-            scribble = _("\nYou won this round.")
+            scribble = linesep + _("You won this round.")
             if injuries_other[2] != 0: 
-                scribble += "\n" + other.name + _(" took ") + str(injuries_other[2]) + _(" points of damage")
+                scribble += linesep + other.name + _(" took ") + str(injuries_other[2]) + _(" points of damage")
                 if injuries_other[0] == 1: 
                     scribble += _(" and a deep wound.") # You never get more than one wound per enemy in one round in the 1d6 rpg. 
                 elif injuries_other[1] == 1: 
                     scribble += _(" and a critical wound.") # You never get more than one wound per enemy in one round in the 1d6 rpg. 
                 else: scribble += "."
         else: 
-            scribble = _("\nYou didn't win this round.")
+            scribble = linesep + _("You didn't win this round.")
             if injuries_self[2] != 0: 
-                scribble += "\n" + _("and you took ") + str(injuries_self[2]) + _(" points of damage")
+                scribble += linesep + _("and you took ") + str(injuries_self[2]) + _(" points of damage")
                 if injuries_self[0] == 1: 
                     scribble += _(" and a deep wound.") # You never get more than one wound per enemy in one round in the 1d6 rpg. 
                 elif injuries_self[1] == 1: 
     def battle_stats(self):
         """@return: A string with battle status information, formatted as battle stats"""
         scrib = _("---battle-stats for ") + _(self.name) + _("---")
-        scrib += _('\nLife: ') + str(self.TP) + _(" of ") + str(self.bTP)
-        scrib += _('\nWounds: ') + str(self.wounds[0]) + _(" - crippling wounds: ") + str(self.wounds[1])
-        scrib += _("\nSkill: ") + str(self.attack)
-        scrib += _("\nWeapon: ") + str(self.weapon)
-        scrib += _("\nArmor: ") + str(self.armor)
-        scrib += _("\n---/battle-stats---")
+        scrib += linesep + _('Life: ') + str(self.TP) + _(" of ") + str(self.bTP)
+        scrib += linesep + _('Wounds: ') + str(self.wounds[0]) + _(" - crippling wounds: ") + str(self.wounds[1])
+        scrib += linesep + _("Skill: ") + str(self.attack)
+        scrib += linesep + _("Weapon: ") + str(self.weapon)
+        scrib += linesep + _("Armor: ") + str(self.armor)
+        scrib += linesep + _("---/battle-stats---")
         return scrib
     
     def fight_round(self,  other, styles_self=[], styles_other=[]):
             return "The function " + str(self.func) + " must be implemented by every rpg scripting module to allow for easy changing of function behaviour."
         else: 
             return "The function " + str(self.func) + " must be implemented by every rpg scripting module to allow for easy changing of function behaviour." \
-                    + "\nThe simplest way is to just add the following lines to your script: " \
-                    + "\n\nstory_helper = Story()\n" \
+                    + linesep + "The simplest way is to just add the following lines to your script: " \
+                    + linesep + linesep + "story_helper = Story()" + linesep \
                     + self.implementation