Commits

Arne Babenhauserheide  committed f04a088

Fixed empty attributes to attribute dict problems -> turned attributes into a property.

  • Participants
  • Parent commits 58c8487

Comments (0)

Files changed (4)

File ews/amov/Charakter.py

         Region: ' '
     Stimmung: ' '
 - Werte:
-    - Eigenschaften: " "
+    - Eigenschaften: 
+        Geschicklichkeit: &id003
+          Zahlenwert: 13
     - Fertigkeiten: 
         Nahkampf: &id001
           Zahlenwert: 12
           Grundwert: 12
+          Passende Eigenschaften: 
+          - *id003
     - Berufe: 
         Mensch: 
             Zahlenwert: 9
         # Get the experience, either from the char, if it has it, or calculate it from all other values.
         self.amov.ladeGrunddaten().setdefault(_("Striche"), self.calculate_might()) #: The experience of the char. 
         
-        #: The attributes of the Char. # TODO: If Eigenschaften changes from ' ' to a dict, update attribute "attributes"
-        self.attributes = self.amov.eigenschaften
-        
-        #: The skills of the char
-        self.skills = self.amov.fertigkeiten
-        
-        #: The equipment of the char. 
-        self.equipment = self.amov.ausruestung
-        
         #: The main weapon of the char
         self.weapon = self.amov.kampfwerte[_("Hauptwaffe")][_("Waffe")]
         
           self.morale_dict = self.amov.eigenschaften.setdefault(_("Morale"), {})
           self.morale = [self.morale_dict.setdefault(_("Zahlenwert"), 12)]
     
+    def get_attributes(self): 
+        """Get the attributes for the attribute property, so it stays up to date."""
+        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
+    def get_equipment(self): 
+        """Get the skills for the skill property, so it stays up to date."""
+        return self.amov.ausruestung
+    
+    # A property always gets loaded directly from the values, so it stays up to date. 
+    # This avoids String to dict problems. 
+    #: The attributes of the char. 
+    attributes = property(fget=get_attributes)
+    #: The attributes of the char. 
+    skills = property(fget=get_attributes)
+    #: The equipment of the char. 
+    equipment = property(fget=get_attributes)
+    
     
     def save_data_into_char_dict(self): 
         """Save the data from the attributes back into the amov data. 
       long_description=LONG_DESCRIPTION, 
       author='Arne Babenhauserheide',
       author_email='arne_bab@web.de',
-      keywords=["ews", "rpg", "characters"], 
+      keywords=["ews", "rpg", "characters", "1d6"], 
       license="GNU GPL-3 or later", 
       platforms=["any"], 
       requires = [], 
 
 class Char(ews_char):
     def __init__(self, template=False, *args, **kwds): 
-        super(Char, self).__init__(template=False, *args, **kwds)
+        super(Char, self).__init__(template=template, *args, **kwds)
         self.battle_diff_treshold = 4 #: The treshold of the char below which no hit is scored. 
     
     def battle_stats(self):