diff src/parpg/components/character_statistics.py @ 185:756ce052ac85

Changed CharacterStatistic classes to work with components.
author KarstenBock@gmx.net
date Sat, 05 Nov 2011 14:42:12 +0100
parents 997cc6d182d5
children f612b4638744
line wrap: on
line diff
--- a/src/parpg/components/character_statistics.py	Wed Oct 26 13:01:49 2011 +0200
+++ b/src/parpg/components/character_statistics.py	Sat Nov 05 14:42:12 2011 +0100
@@ -26,4 +26,16 @@
         fields = self.fields.keys()
         fields.remove("primary_stats")
         fields.remove("secondary_stats")
-        return fields
\ No newline at end of file
+        return fields
+    
+def get_statistic(stats, name):
+    """Gets the statistic by its name"""
+    if name in stats.primary_stats:
+        return stats.primary_stats[name]
+    elif name in stats.secondary_stats:
+        return stats.secondary_stats[name]
+    else:
+        for stat in stats.primary_stats:
+            if stat.statistic_type.short_name == name:
+                return stat
+    return None
\ No newline at end of file