Changeset 609
- Timestamp:
- 07/31/10 08:10:20 (9 years ago)
- Location:
- trunk/game
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/game/run.py
r584 r609 27 27 utils.addPaths ('./lib', './lib/extensions') 28 28 29 #from settings import Setting30 29 31 30 TDS = Setting(app_name="PARPG", -
trunk/game/scripts/gamemodel.py
r608 r609 134 134 info.update(extra) 135 135 ID = info.pop("id") if info.has_key("id") else info.pop("ID") 136 if not info.has_key("item_ id"):137 info[ 'item_id'] = ID136 if not info.has_key("item_type"): 137 info["item_type"] = info["type"] 138 138 ID = self.createUniqueID(ID) 139 139 new_item = CarryableItem(ID = ID, **info) … … 504 504 item_data = agent["item"] 505 505 inst_dict["item"] = item_data 506 inst_dict["item_ id"] = agent["ItemType"]506 inst_dict["item_type"] = agent["ItemType"] 507 507 508 508 self.createMapObject(self.active_map.agent_layer, inst_dict, inst) -
trunk/game/scripts/gui/dialoguegui.py
r591 r609 99 99 def getStuff(state, thing): 100 100 """Moves an item from the npc inventory to the players 101 @param thing: item_ idof the item101 @param thing: item_type of the item 102 102 @type thing: str """ 103 item = state['npc'].inventory.findItem(item_ id= thing)103 item = state['npc'].inventory.findItem(item_type = thing) 104 104 if item: 105 105 state['npc'].give(item, state['pc']) … … 110 110 def giveStuff(state, thing): 111 111 """Moves an item from the pc inventory to the npcs 112 @param thing: item_ idof the item112 @param thing: item_type of the item 113 113 @type thing: str """ 114 114 """Moves an item from the npc inventory to the players 115 @param thing: item_ idof the item115 @param thing: item_type of the item 116 116 @type thing: str """ 117 item = state['pc'].inventory.findItem(item_ id= thing)117 item = state['pc'].inventory.findItem(item_type = thing) 118 118 if item: 119 119 state['pc'].give(item, state['npc']) … … 127 127 @param who: Sets whose item to replace. Should be either pc or npc 128 128 @type who: str 129 @param old_items: item_ ids of the items to replace129 @param old_items: item_types of the items to replace 130 130 @type old_item: list of str 131 131 @param new_item: Types of the items that replace the old items 132 132 @type new_item: list of str """ 133 133 old_item_instances = [] 134 for item_ idin old_items:134 for item_type in old_items: 135 135 old_item_instances.append(state[who].inventory.\ 136 findItem(item_ id = item_id))136 findItem(item_type = item_type)) 137 137 if old_item_instances: 138 138 for old_item in old_item_instances: … … 154 154 @param who: Sets whose item to replace. Should be either pc or npc 155 155 @type who: str 156 @param old_item: item_ idof the item to replace156 @param old_item: item_type of the item to replace 157 157 @type old_item: str 158 158 @param new_item: Type of the item that replaces the old item 159 159 @type new_item: str """ 160 old_item = state[who].inventory.findItem(item_ id= old_item)160 old_item = state[who].inventory.findItem(item_type = old_item) 161 161 if old_item: 162 162 inst_dict = {} -
trunk/game/scripts/inventory.py
r605 r609 84 84 85 85 86 def count(self, item_ id):87 return sum(item.count(item_ id) for item in self.items.values())86 def count(self, item_type = ""): 87 return sum(item.count(item_type) for item in self.items.values()) 88 88 89 89 def takeOff(self, item): -
trunk/game/scripts/objects/actors.py
r591 r609 230 230 actor.inventory.placeItem(item) 231 231 232 def hasItem(self, item_ id):232 def hasItem(self, item_type): 233 233 """Returns wether an item is present in the players inventory or not 234 @param item_ id: ID of the item235 @type item_ id: str234 @param item_type: ID of the item 235 @type item_type: str 236 236 @return: True when the item is present, False when not""" 237 return self.inventory.findItem(item_ id = item_id)238 239 def itemCount(self, item_ id= ""):240 """Returns number of all items or items specified by item_ id237 return self.inventory.findItem(item_type = item_type) 238 239 def itemCount(self, item_type = ""): 240 """Returns number of all items or items specified by item_type 241 241 the player has. 242 @param item_ id: ID of the item, can be empty243 @type item_ id: str242 @param item_type: ID of the item, can be empty 243 @type item_type: str 244 244 @return: Number of items""" 245 return self.inventory.count(item_ id)245 return self.inventory.count(item_type) 246 246 247 247 def getLocation(self): -
trunk/game/scripts/objects/base.py
r596 r609 362 362 pass 363 363 364 def count (self, item_ id= ""):364 def count (self, item_type = ""): 365 365 """Returns the number of items""" 366 if item_ id:366 if item_type: 367 367 ret_count = 0 368 368 for index in self.items : 369 if self.items[index].item_ id == item_id:369 if self.items[index].item_type == item_type: 370 370 ret_count += 1 371 371 return ret_count … … 393 393 return None 394 394 395 def findItemByItem ID(self, item_id):396 """Returns the item with the passed item_ id"""395 def findItemByItemType(self, item_type): 396 """Returns the item with the passed item_type""" 397 397 for index in self.items : 398 if self.items[index].item_ id == item_id:398 if self.items[index].item_type == item_type: 399 399 return self.items[index] 400 400 return None … … 414 414 if "kind" in kwargs and not self.items[index].trueAttr(kwargs["kind"]): 415 415 continue 416 if "item_ id" in kwargs and self.items[index].item_id != kwargs["item_id"]:416 if "item_type" in kwargs and self.items[index].item_type != kwargs["item_type"]: 417 417 continue 418 418 return self.items[index] … … 425 425 item_dict = item.getStateForSaving() 426 426 item_dict["index"] = index 427 item_dict["type"] = type(item).__name__427 item_dict["type"] = item.item_type 428 428 items.append(item_dict) 429 429 return items -
trunk/game/scripts/objects/composed.py
r596 r609 81 81 class CarryableItem (GameObject, Carryable, Usable): 82 82 """Composite class that will be used for all carryable items""" 83 def __init__(self, item_ id, type = "CarryableItem", **kwargs):83 def __init__(self, item_type, **kwargs): 84 84 GameObject.__init__(self, **kwargs) 85 85 Carryable.__init__(self, **kwargs) 86 86 Usable.__init__(self, **kwargs) 87 self.item_id = item_id 88 self.item_type = type 87 self.item_type = item_type 89 88 90 89 def prepareStateForSaving(self, state): … … 94 93 """ 95 94 super(CarryableItem, self).prepareStateForSaving(state) 96 del state["in_container"] 95 if state.has_key("in_container"): 96 del state["in_container"] 97 97 del state["on_map"] 98 98 del state["agent"] -
trunk/game/scripts/objects/items.py
r592 r609 22 22 class MapItem(CarryableItem): 23 23 """Item that is lying on a map""" 24 def __init__(self, ID, item_ id, item, name = 'Item', text = 'An item',24 def __init__(self, ID, item_type, item, name = 'Item', text = 'An item', 25 25 gfx = 'item', **kwargs): 26 CarryableItem.__init__(self, ID = ID, item_ id = item_id, name = name,26 CarryableItem.__init__(self, ID = ID, item_type = item_type, name = name, 27 27 text = text, gfx = gfx, **kwargs) 28 28 self.item = item
Note: See TracChangeset
for help on using the changeset viewer.