Commits

Anonymous committed c0ab343

Ferttigkeiten now get increased by related attributes. Which attribute is related must be declared explicitely.

Comments (0)

Files changed (3)

ews/amov/Charakter.py

     Beschreibung: " "
     Herkunft: 
         Sprache: Esperanto
-        Region: ' '
+        Region: " "
     Stimmung: ' '
 - Werte:
     - Eigenschaften: 
         Mensch: 
             Zahlenwert: 9
             Grundwert: 9
-    - Merkmale: " "
+    - Merkmale: {}
 - Ausrüstung: 
     Waffen:
       Waffenlos: &id002
         return self.amov.eigenschaften
     def get_skills(self): 
         """Get the skills for the skill property, so it stays up to date."""
-        return self.amov.fertigkeiten
+        skills = self.amov.fertigkeiten
+        # recalculate the effective value from the base value and related attributes. 
+        for i in skills: 
+            bonus = 0 #: bonus from related attributes. 
+            if _("Passende Eigenschaften") in skills[i]: 
+                for j in skills[i][_("Passende Eigenschaften")]: 
+                    bonus += pmw6.value_to_plusses(j[_("Zahlenwert")])
+                skills[i][_("Zahlenwert")] = skills[i][_("Grundwert")] + bonus
+        return skills
+            
     def get_equipment(self): 
         """Get the skills for the skill property, so it stays up to date."""
         return self.amov.ausruestung
     #: The attributes of the char. 
     attributes = property(fget=get_attributes)
     #: The attributes of the char. 
-    skills = property(fget=get_attributes)
+    skills = property(fget=get_skills)
     #: The equipment of the char. 
-    equipment = property(fget=get_attributes)
+    equipment = property(fget=get_equipment)
     
     
     def save_data_into_char_dict(self): 
     
     def value_and_striche_fertigkeiten(self,  val=None,  striche=None):
         """Return value and striche"""
-        striche_fertigkeiten = [3,  6, 9, 12]
-        # First we do the case, when we get striche and want a value
-        # For a low number of striche, this is quite easy. 
-        if striche is not None and striche <= 3: 
-            val = striche_fertigkeiten[int(striche)]
-            return val,  striche
-        # for higher numbers of strichen, itthe necessary list is a bit longer. 
-        elif striche is not None and striche > 3: 
-            # first create an aggregator
-            necessary_striche = 3
-            striche_per_point = 2
-            effective_value = 12
-            # We raise the value until the necessary_striche is higher of equal to the striche. 
-            # If it's higher, we reduce the value afterwards. 
-            # add all values together, up to the number of strichen. 
-            while necessary_striche < striche: 
-                effective_value += 1
-                necessary_striche += int(striche_per_point + 0.1) # this +0.1 is necessary to avoid some crazy rounding down at 2.0
-                striche_per_point += 1/3.0
-            if necessary_striche > striche: 
-                effective_value -= 1
-                necessary_striche -= int(striche_per_point)
-            return effective_value,  striche
-        
-        # If we have a value, we return the number of necessary_striche, 
-        # If teh value is lower than or equal to 12, it's easy to get the striche 
-        # by inverse searching in the striche_fertigkeiten list. 
-        if val is not None and val <= 12: 
-            necessary_striche = striche_fertigkeiten.index(val)
-            return val,  necessary_striche 
-        # If the value is higehr than 12, we increase the effective_value in steps, 
-        # until we reach the given value, increasing the striche as by the 1d6 vobsy rules. 
-        elif val is not None and val > 12: 
-            necessary_striche = 3
-            striche_per_point = 2
-            effective_value = 12
-            while effective_value < val: 
-                effective_value += 1
-                necessary_striche += int(striche_per_point + 0.1) # this +0.1 is necessary to avoid some crazy rounding down at 2.0
-                striche_per_point += 1/3.0
-            return effective_value,  necessary_striche    
+        return pmw6.value_and_striche_fertigkeiten(val=val, striche=striche)
     
     
     def value_and_striche_eigenschaften(self,  val=None,  striche=None):
         """Return value and striche."""
-        vorzeichen = 1
-        if striche is not None and striche < 0: 
-            striche = -striche
-            vorzeichen = -1
-        if striche is not None and striche >= 0: 
-            # first create an aggregator
-            necessary_striche = 0
-            striche_per_point = 1
-            effective_value = 12
-            # We raise the value until the necessary_striche is higher of equal to the striche. 
-            # If it's higher, we reduce the value afterwards. 
-            # add all values together, up to the number of strichen. 
-            while necessary_striche < striche: 
-                effective_value += 1
-                necessary_striche += int(striche_per_point + 0.1) # this +0.1 is necessary to avoid some crazy rounding down at 2.0
-                striche_per_point += 1/3.0
-            if necessary_striche > striche: 
-                effective_value -= 1
-                necessary_striche -= int(striche_per_point)
-            if vorzeichen == 1: 
-                return effective_value,  striche
-            else: 
-                return 24 - effective_value,  -striche
-        
-        if val is not None and val < 12: 
-            val = 24 - val
-            vorzeichen = -1
-        # If the value is higehr than 12, we increase the effective_value in steps, 
-        # until we reach the given value, increasing the striche as by the 1d6 vobsy rules. 
-        if val is not None and val >= 12: 
-            necessary_striche = 0
-            striche_per_point = 1
-            effective_value = 12
-            while effective_value < val: 
-                effective_value += 1
-                necessary_striche += int(striche_per_point + 0.1) # this +0.1 is necessary to avoid some crazy rounding down at 2.0
-                striche_per_point += 1/3.0
-            if vorzeichen == 1: 
-                return effective_value,  necessary_striche
-            else: 
-                return 24 - effective_value,  -necessary_striche
+        return pmw6.value_and_striche_eigenschaften(val=val, striche=striche)
         
         
     def fight_round(self,  other, styles_self=[], styles_other=[]):
     res = skill + pmw6()
     return res - MW,  res
 
+# Convert between different represenations for skill values. 
+
+def value_to_plusses(value=12, thing="attribute"): 
+    """Return the value in effective plusses for attributes and skills. 
+    @param thing: What is checked: attribute or skill. 
+    @type thign: String. 
+    """
+    if thing == "attribute": 
+        return round((value-12) / 3.0)
+    elif thing == "skill": 
+        if value <= 6: 
+            return 0
+        elif value == 9: 
+            return 1
+        else: 
+            return round((value - 9) / 3.0)
+
+# Convert between value and Strichen. 
+
+
+    
+
+def value_and_striche_fertigkeiten(val=None,  striche=None):
+    """Return value and striche"""
+    striche_fertigkeiten = [3,  6, 9, 12]
+    # First we do the case, when we get striche and want a value
+    # For a low number of striche, this is quite easy. 
+    if striche is not None and striche <= 3: 
+        val = striche_fertigkeiten[int(striche)]
+        return val,  striche
+    # for higher numbers of strichen, itthe necessary list is a bit longer. 
+    elif striche is not None and striche > 3: 
+        # first create an aggregator
+        necessary_striche = 3
+        striche_per_point = 2
+        effective_value = 12
+        # We raise the value until the necessary_striche is higher of equal to the striche. 
+        # If it's higher, we reduce the value afterwards. 
+        # add all values together, up to the number of strichen. 
+        while necessary_striche < striche: 
+            effective_value += 1
+            necessary_striche += int(striche_per_point + 0.1) # this +0.1 is necessary to avoid some crazy rounding down at 2.0
+            striche_per_point += 1/3.0
+        if necessary_striche > striche: 
+            effective_value -= 1
+            necessary_striche -= int(striche_per_point)
+        return effective_value,  striche
+    
+    # If we have a value, we return the number of necessary_striche, 
+    # If teh value is lower than or equal to 12, it's easy to get the striche 
+    # by inverse searching in the striche_fertigkeiten list. 
+    if val is not None and val <= 12: 
+        necessary_striche = striche_fertigkeiten.index(val)
+        return val,  necessary_striche 
+    # If the value is higehr than 12, we increase the effective_value in steps, 
+    # until we reach the given value, increasing the striche as by the 1d6 vobsy rules. 
+    elif val is not None and val > 12: 
+        necessary_striche = 3
+        striche_per_point = 2
+        effective_value = 12
+        while effective_value < val: 
+            effective_value += 1
+            necessary_striche += int(striche_per_point + 0.1) # this +0.1 is necessary to avoid some crazy rounding down at 2.0
+            striche_per_point += 1/3.0
+        return effective_value,  necessary_striche    
+
+
+def value_and_striche_eigenschaften(val=None,  striche=None):
+    """Return value and striche."""
+    vorzeichen = 1
+    if striche is not None and striche < 0: 
+        striche = -striche
+        vorzeichen = -1
+    if striche is not None and striche >= 0: 
+        # first create an aggregator
+        necessary_striche = 0
+        striche_per_point = 1
+        effective_value = 12
+        # We raise the value until the necessary_striche is higher of equal to the striche. 
+        # If it's higher, we reduce the value afterwards. 
+        # add all values together, up to the number of strichen. 
+        while necessary_striche < striche: 
+            effective_value += 1
+            necessary_striche += int(striche_per_point + 0.1) # this +0.1 is necessary to avoid some crazy rounding down at 2.0
+            striche_per_point += 1/3.0
+        if necessary_striche > striche: 
+            effective_value -= 1
+            necessary_striche -= int(striche_per_point)
+        if vorzeichen == 1: 
+            return effective_value,  striche
+        else: 
+            return 24 - effective_value,  -striche
+    
+    if val is not None and val < 12: 
+        val = 24 - val
+        vorzeichen = -1
+    # If the value is higher than 12, we increase the effective_value in steps, 
+    # until we reach the given value, increasing the striche as by the 1d6 vobsy rules. 
+    if val is not None and val >= 12: 
+        necessary_striche = 0
+        striche_per_point = 1
+        effective_value = 12
+        while effective_value < val: 
+            effective_value += 1
+            necessary_striche += int(striche_per_point + 0.1) # this +0.1 is necessary to avoid some crazy rounding down at 2.0
+            striche_per_point += 1/3.0
+        if vorzeichen == 1: 
+            return effective_value,  necessary_striche
+        else: 
+            return 24 - effective_value,  -necessary_striche
+
 #### FUNCTIONS ####