Limit number of bombs (EMILY)

This commit is contained in:
Eryn Wells 2017-05-13 17:44:06 +00:00
parent 9540ff4dd9
commit 966e0fba61

View file

@ -13,6 +13,8 @@ LOGGER = logging.getLogger(__name__)
CMD_RE = None CMD_RE = None
ADD_RE = None ADD_RE = None
MAX_BOMBS = 10
COLLECTIONS = {} COLLECTIONS = {}
# #
@ -80,6 +82,9 @@ def _handle_bomb(match, channel):
except TypeError: # count is None except TypeError: # count is None
count = 1 count = 1
bombs = COLLECTIONS[collection]
count = min(MAX_BOMBS, len(bombs), count)
LOGGER.info('Getting %d item%s from %s', count, '' if count == 1 else 's', collection) LOGGER.info('Getting %d item%s from %s', count, '' if count == 1 else 's', collection)
items = random.sample(COLLECTIONS[collection], count) items = random.sample(COLLECTIONS[collection], count)
LOGGER.debug('I HAVE BOMB FOOD: %s', items) LOGGER.debug('I HAVE BOMB FOOD: %s', items)