comparison gamemodel.py @ 84:bb9e2f2548c6

Added moveObject method to the GameModel class.
author KarstenBock@gmx.net
date Fri, 23 Sep 2011 15:08:27 +0200
parents 43e7a8d94446
children a9cc5559ec2a
comparison
equal deleted inserted replaced
83:43e7a8d94446 84:bb9e2f2548c6
133 raise ValueError( 133 raise ValueError(
134 "Number exceeds MAX_ID_NUMBER:" + str(self.MAX_ID_NUMBER)) 134 "Number exceeds MAX_ID_NUMBER:" + str(self.MAX_ID_NUMBER))
135 135
136 ID = ID + "_" + str(id_number) 136 ID = ID + "_" + str(id_number)
137 return ID 137 return ID
138
139 def moveObject(self, object_id, new_map):
140 """Moves the object to a new map, or in a container
141 @param object_id: ID of the object
142 @type object_id: str
143 @param new_map: ID of the new map, or None
144 @type object_id: str """
145 game_object = self.game_state.getObjectById(object_id)
146 self.deleteObject(object_id)
147 self.game_state.addObject(object_id, new_map, game_object)
138 148
139 def deleteObject(self, object_id): 149 def deleteObject(self, object_id):
140 """Removes an object from the game 150 """Removes an object from the game
141 @param object_id: ID of the object 151 @param object_id: ID of the object
142 @type object_id: str """ 152 @type object_id: str """