Commits

Anonymous committed 09da0e7

Nicer battle output.

Comments (0)

Files changed (2)

 from textrpg import Char, story, ask
 from save import save
 
+
+
 name = ask("What's your name?")
-#identifier = ask("Please give a unique identifier for yourself (your email or a domain name):")
-identifier = "1w6.org"
 
 # First load the chars for better gameflow. 
 char2 = Char(source="tag:1w6.org,2008:Nasfar")
-char1 = Char(source="tag:" + identifier + ",2008:" + name)
+char1 = Char(source="tag:1w6.org,2008:" + name)
 
 story('''
 Where the sun doesn't shine, 
 
 if won:
     char1.say("So much for 'you survive'!")
-    story(char1.upgrade(1))
+    char1.upgrade(1)
 else:
     char2.say("Harr! You won't be the one to kill me!")
 
     
     if raw_input(_('Do you want to attack ' + other.name + '? (Yes, no) ')).lower() in ['Yes', 'y', '']: 
         diag("You attack " + other.name + ".")
-        won = me.fight_round(other)[0]
+        won, injuries_self, injuries_other = me.fight_round(other)
     else:
-        diag("You don't attack, so it's up to " + other.name + " to decide what to do.")
-        diag(other.name + " attack you.")
-        won = not other.fight_round(me)[0]
+        diag("You don't attack, so you can do something else this round.")
+        won = False
+    return won, injuries_self, injuries_other 
     
-    return won
-    
+
+
+def battle_round_result(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 = _("You won this round.")
+        if injuries_other[2] != 0: 
+            scribble += "\n" + other.name + _(" took ") + str(injuries_other[2]) + _(" points of damage")
+            if injuries_other[0] != 0: 
+                scribble += _(" and ") + str(injuries_other[0])
+                if injuries_other[0] == 1: 
+                    scribble += _(" deep wound.")
+                else: 
+                    scribble += _(" deep wounds.")
+            elif injuries_other[1] != 0: 
+                scribble += _(" and ") + str(injuries_other[1])
+                if injuries_other[1] == 1: 
+                    scribble += _(" critical wound.")
+                else: 
+                    scribble += _(" critical wounds.")
+            else: scribble += "."
+    else: 
+        scribble = _("You lost this round.")
+        if injuries_self[2] != 0: 
+            scribble += "\n" + _("and you took ") + str(injuries_self[2]) + _(" points of damage")
+            if injuries_self[0] != 0: 
+                scribble += _(" and ") + str(injuries_self[0]) 
+                if injuries_self[0] == 1: 
+                    scribble += _(" deep wound.")
+                else: 
+                    scribble += _(" deep wounds.")
+            elif injuries_self[1] != 0: 
+                scribble += _(" and ") + str(injuries_self[1])
+                if injuries_self[1] == 1: 
+                    scribble += _(" critical wound.")
+                else: 
+                    scribble += _(" critical wounds.")
+            else: scribble += "."
+    return scribble
+
 
 def battle(me, other): 
     return fight_while_standing(me, other)
     
     # Ask the player which action to take.        
     diag(other.name + ' comes closer.')
-    won = select_battle_action(me, other)
+    won, injuries_self, injuries_other = select_battle_action(me, other)
     
-    if won: 
-        diag("You hit.")
-    else: diag("You got hit.")
+    diag(battle_round_result(me, other, won, injuries_self, injuries_other))
     
     diag(battle_info(me, other))
     
     old_value = upgrade[0].items()[0][1]["Zahlenwert"] 
     new_value = upgrade[1].items()[0][1]["Zahlenwert"]
     if old_value < new_value:
-        diag(char.name + " raised " + item_name + " from " + 
-str(old_value) + " to " + str(new_value))
-    diag("***/experience***\n")
+        diag(char.name + " raised " + item_name + " from " + str(old_value) + " to " + str(new_value))
+        diag("***/experience***\n")
 
 
 if __name__ == "__main__": 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.