Mercurial > parpg-source
comparison components/container.py @ 77:180cbd2b5da8
Fixed bugs in the container functions.
author | KarstenBock@gmx.net |
---|---|
date | Fri, 23 Sep 2011 13:30:17 +0200 |
parents | 58d58bf2e567 |
children | 939984cff702 |
comparison
equal
deleted
inserted
replaced
76:4cf150131139 | 77:180cbd2b5da8 |
---|---|
68 """Returns the item that is in the slot, or has the given type.""" | 68 """Returns the item that is in the slot, or has the given type.""" |
69 if type(slot_or_type) == int: | 69 if type(slot_or_type) == int: |
70 if len(container.children) >= (slot_or_type + 1): | 70 if len(container.children) >= (slot_or_type + 1): |
71 return container.children[slot_or_type] | 71 return container.children[slot_or_type] |
72 else: | 72 else: |
73 for item in container.children: | 73 for child in container.children: |
74 if child and child.type == slot_or_type: | 74 if child and child.item_type == slot_or_type: |
75 return child | 75 return child |
76 | 76 |
77 return None | 77 return None |
78 | 78 |
79 def remove_item(container, slot_or_type): | 79 def remove_item(container, slot_or_type): |
83 if item: | 83 if item: |
84 container.children[slot_or_type] = None | 84 container.children[slot_or_type] = None |
85 item.container = None | 85 item.container = None |
86 item.slot = -1 | 86 item.slot = -1 |
87 else: | 87 else: |
88 for item in container.children: | 88 for child in container.children: |
89 if child and child.type == slot_or_type: | 89 if child and child.item_type == slot_or_type: |
90 container.children[child.slot] = None | 90 container.children[child.slot] = None |
91 child.container = None | 91 child.container = None |
92 child.slot = -1 | 92 child.slot = -1 |
93 | 93 |
94 def take_item(container, slot_or_type): | 94 def take_item(container, slot_or_type): |