Commits

dr...@1w6.org  committed 6ace4a2

Nicer battle output and output, when a skill got raised.

  • Participants
  • Parent commits 76fefca

Comments (0)

Files changed (2)

             for i in self.amov.fertigkeiten.keys(): 
                 # Check if it has a skill key i
                 if obj.has_key(("skill", i)): 
-                    obj = obj[("skill", i)]
-                    val = obj.setdefault("Grundwert",  obj.setdefault("Zahlenwert",  3))
+                    sub_obj = obj[("skill", i)]
+                    val = sub_obj.setdefault("Grundwert",  sub_obj.setdefault("Zahlenwert",  3))
                     # all skills / attributes should have a 'Striche' item
-                    striche_old = obj.setdefault("Striche",  self.value_and_striche_fertigkeiten(val=obj.setdefault("Grundwert",  3))[1])
-                    obj.setdefault("Striche",  striche_old)
+                    striche_old = sub_obj.setdefault("Striche",  self.value_and_striche_fertigkeiten(val=sub_obj.setdefault("Grundwert",  3))[1])
+                    sub_obj.setdefault("Striche",  striche_old)
                     # add xp, if applicable raise skill / attribute
-                    obj['Striche'] += expadd
-                    obj["Grundwert"] = self.value_and_striche_fertigkeiten(striche=obj['Striche'] )[0]
-                    if obj["Zahlenwert"] < obj["Grundwert"] : 
-                        obj["Zahlenwert"] = obj["Grundwert"] #TODO: We need a character method, which gets the Zahlenwert from the Grundwert. 
+                    sub_obj['Striche'] += expadd
+                    sub_obj["Grundwert"] = self.value_and_striche_fertigkeiten(striche=sub_obj['Striche'] )[0]
+                    if sub_obj["Zahlenwert"] < sub_obj["Grundwert"] : 
+                        sub_obj["Zahlenwert"] = sub_obj["Grundwert"] #TODO: We need a character method, which gets the Zahlenwert from the Grundwert. 
     
         # If it's an attribute, get the Zahlenwert. 
         if self.amov.eigenschaften != " ": 
             for i in self.amov.eigenschaften.keys(): 
                 if obj.has_key(("attribute", i)): 
-                    obj = obj[("attribute", i)]
-                    striche_old = obj.setdefault("Striche",  self.value_and_striche_eigenschaften(val=obj.setdefault("Zahlenwert",  12))[1])
-                    obj["Striche"] = striche_old + expadd
-                    obj["Zahlenwert"] = self.value_and_striche_eigenschaften(striche=obj["Striche"])[0]
+                    sub_obj = obj[("attribute", i)]
+                    striche_old = sub_obj.setdefault("Striche",  self.value_and_striche_eigenschaften(val=sub_obj.setdefault("Zahlenwert",  12))[1])
+                    sub_obj["Striche"] = striche_old + expadd
+                    sub_obj["Zahlenwert"] = self.value_and_striche_eigenschaften(striche=sub_obj["Striche"])[0]
         
         if verbose: 
             print "to",  obj # finishing upgrade line of output
 
 def fight_while_standing(me, other):
 	'''Fight as long as both characters are still active.'''
-	diag(me.battle_stats())
-	diag(other.battle_stats())
+
+	diag("\n" + me.battle_stats() + "\n" + other.battle_stats() + "\n")
 
 	if raw_input(_(other.name + ' comes closer. Do you want to attack him? (Yes, no) ')).lower() in ['Yes', 'y', '']: 
 		diag("You attack " + other.name + " before he can reach you.")
 	if won: 
 		diag("You hit.")
 	else: diag("You got hit.")
-	diag(me.battle_stats())
-	diag(other.battle_stats())
-	while me.active and other.active: 
+	diag("\n" + me.battle_stats() + "\n" + other.battle_stats() + "\n")
+	while me.active and other.active:
 		if won: # we won the last round, so we can attack again.
 			won = me.fight_round(other)[0]
 		else: 
 		if won:
 			diag("You hit")
 		else: diag("You got hit")
-		diag(me.battle_stats() + "\n" + other.battle_stats())
+		diag("\n" + me.battle_stats() + "\n" + other.battle_stats() + '\n')
 	if me.active: 
 		return True # We won
 	else: 
 		return False # We lost
 
 def get_experience(char, amount=0):
-	"""Show the exprience the char gets and what the char does with it."""
-	print char.upgrade(amount)
+	"""Show the experience the char gets and what the char does with it."""
+	diag(char.name + " got " + str(amount) + " experience.")
+	upgrade = char.upgrade(amount)
+	item_name = " ".join(upgrade[0].items()[0][0])
+	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))
+
 
 if __name__ == "__main__": 
 	print "...Creating main character..."
 	choss.name = "Hegen"
 	won = fight_while_standing(char, choss)
 	diag("...")
-	get_experience(char, 1)
-	choss.upgrade(1)
+	get_experience(char, 3)
+	choss.upgrade(3)
 	if won: 
-		diag("Well done " + char.name + ". I knew my trust was well placed with you. Now about your father")
+		diag("Well done " + char.name + ". I knew my trust was well placed with you. Now about your father...")
 	else: 
 		diag("I didn't expect you to lose to him. Well, fate is a harsh teacher. Better luck next time!")