Mercurial > parpg-core
diff src/parpg/components/container.py @ 46:3bacef35b252
get_free_slot no raises an exception instead of appending a slot to the container.
author | KarstenBock@gmx.net |
---|---|
date | Fri, 02 Sep 2011 12:54:43 +0200 |
parents | 9f631144124f |
children | 96af64cf3b81 |
line wrap: on
line diff
--- a/src/parpg/components/container.py Fri Sep 02 12:29:55 2011 +0200 +++ b/src/parpg/components/container.py Fri Sep 02 12:54:43 2011 +0200 @@ -32,7 +32,13 @@ def __str__(self): return "Item would exceed the bulk limit of the container." - + +class NoFreeSlotError(Exception): + """Error that gets raised when the container has no free slots.""" + + def __str__(self): + return "Container can't hold any more items." + def get_free_slot(container): """Returns the first slot of the container that is not occupied.""" index = 0 @@ -40,8 +46,7 @@ if not child: return index index += 1 - container.children.append(None) - return index + raise NoFreeSlotError def get_total_bulk(container): """Returns the bulk of all items in the container."""