comparison charactercreationcontroller.py @ 155:f017f8cac2c2

Statistics are being saved and loaded.
author KarstenBock@gmx.net
date Sat, 05 Nov 2011 16:04:59 +0100
parents 4dc7951c3bfc
children b3b82c2aebee
comparison
equal deleted inserted replaced
154:4dc7951c3bfc 155:f017f8cac2c2
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. 14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>.
15 """Provides the controller that defines the behaviour of the character creation 15 """Provides the controller that defines the behaviour of the character creation
16 screen.""" 16 screen."""
17 17
18 from parpg import vfs 18 from parpg import vfs
19 import characterstatistics as char_stats
20 from controllerbase import ControllerBase 19 from controllerbase import ControllerBase
21 from gamescenecontroller import GameSceneController 20 from gamescenecontroller import GameSceneController
22 from gamesceneview import GameSceneView 21 from gamesceneview import GameSceneView
23 from parpg.world import World 22 from parpg.world import World
24 from parpg.entities import General 23 from parpg.entities import General
25 24 from parpg.components import character_statistics
26 DEFAULT_STAT_VALUE = 50
27
28 25
29 def getStatCost(offset): 26 def getStatCost(offset):
30 """Gets and returns the cost to increase stat based on the offset""" 27 """Gets and returns the cost to increase stat based on the offset"""
31 28
32 if offset < 0: 29 if offset < 0:
96 self.char_data.characterstats.origin = self.ORIGINS.keys()[0] 93 self.char_data.characterstats.origin = self.ORIGINS.keys()[0]
97 self.char_data.characterstats.age = 20 94 self.char_data.characterstats.age = 20
98 self.char_data.characterstats.picture = ( 95 self.char_data.characterstats.picture = (
99 self.PICTURES[self.GENDERS[0]][0] 96 self.PICTURES[self.GENDERS[0]][0]
100 ) 97 )
101 for primary_stat in self.model.primary_stats: 98 self.model.create_stats(self.char_data)
102 long_name = primary_stat.long_name
103 self.char_data.characterstats.primary_stats[long_name] = (
104 char_stats.PrimaryStatisticValue(
105 primary_stat, self.char_data.characterstats,
106 DEFAULT_STAT_VALUE)
107 )
108 for secondary_stat in self.model.secondary_stats:
109 name = secondary_stat.name
110 self.char_data.characterstats.secondary_stats[name] = (
111 char_stats.SecondaryStatisticValue(secondary_stat,
112 self.char_data.
113 characterstats)
114 )
115 self.char_data.container.max_bulk = self.MAX_BULK 99 self.char_data.container.max_bulk = self.MAX_BULK
116 self.char_data.container.children = inventory 100 self.char_data.container.children = inventory
117 self._stat_points = 200 101 self._stat_points = 200
118 102
119 103 def update_agent(self):
104 """Updates the player agent data in the model"""
105 agent_data = (
106 self.model.agents[self.model.ALL_AGENTS_KEY]["PlayerCharacter"]
107 )
108 agent_data["Statistics"] = (
109 character_statistics.get_stat_values(
110 self.char_data.characterstats
111 )["primary"]
112 )
113
120 def startNewGame(self): 114 def startNewGame(self):
121 """Create the new character and start a new game. 115 """Create the new character and start a new game.
122 @return: None""" 116 @return: None"""
117 self.update_agent()
123 view = GameSceneView(self.engine, self.model) 118 view = GameSceneView(self.engine, self.model)
124 controller = GameSceneController(self.engine, view, self.model, 119 controller = GameSceneController(self.engine, view, self.model,
125 self.application) 120 self.application)
126 self.application.view = view 121 self.application.view = view
127 self.application.manager.swap_modes(controller) 122 self.application.manager.swap_modes(controller)