diff src/parpg/charactercreationcontroller.py @ 187:f612b4638744

Statistics are being saved and loaded.
author KarstenBock@gmx.net
date Sat, 05 Nov 2011 16:04:59 +0100
parents 8cc26e89398c
children
line wrap: on
line diff
--- a/src/parpg/charactercreationcontroller.py	Sat Nov 05 14:53:12 2011 +0100
+++ b/src/parpg/charactercreationcontroller.py	Sat Nov 05 16:04:59 2011 +0100
@@ -16,15 +16,12 @@
    screen."""
 
 from parpg import vfs
-import characterstatistics as char_stats
 from controllerbase import ControllerBase
 from gamescenecontroller import GameSceneController
 from gamesceneview import GameSceneView
 from parpg.world import World
 from parpg.entities import General
-
-DEFAULT_STAT_VALUE = 50
-
+from parpg.components import character_statistics
 
 def getStatCost(offset):
     """Gets and returns the cost to increase stat based on the offset"""
@@ -98,28 +95,26 @@
         self.char_data.characterstats.picture = (
             self.PICTURES[self.GENDERS[0]][0]
         )
-        for primary_stat in self.model.primary_stats:
-            long_name = primary_stat.long_name
-            self.char_data.characterstats.primary_stats[long_name] = (
-                char_stats.PrimaryStatisticValue(
-                    primary_stat, self.char_data.characterstats, 
-                    DEFAULT_STAT_VALUE)
-            )
-        for secondary_stat in self.model.secondary_stats:
-            name = secondary_stat.name            
-            self.char_data.characterstats.secondary_stats[name] = (
-                char_stats.SecondaryStatisticValue(secondary_stat, 
-                                                   self.char_data.
-                                                   characterstats)
-            )
+        self.model.create_stats(self.char_data)
         self.char_data.container.max_bulk = self.MAX_BULK
         self.char_data.container.children = inventory
-        self._stat_points = 200
-  
-       
+        self._stat_points = 200 
+    
+    def update_agent(self):
+        """Updates the player agent data in the model"""
+        agent_data = (
+            self.model.agents[self.model.ALL_AGENTS_KEY]["PlayerCharacter"]
+        )
+        agent_data["Statistics"] = (
+            character_statistics.get_stat_values(
+                self.char_data.characterstats
+            )["primary"]
+        )
+        
     def startNewGame(self):
         """Create the new character and start a new game.
            @return: None"""
+        self.update_agent()
         view = GameSceneView(self.engine, self.model)
         controller = GameSceneController(self.engine, view, self.model,
                                          self.application)