diff options
| author | Julian Irwin <julian.irwin@gmail.com> | 2013-01-26 13:03:36 -0500 |
|---|---|---|
| committer | Julian Irwin <julian.irwin@gmail.com> | 2013-01-26 13:03:36 -0500 |
| commit | 96ec51791405fd8982fdda3ee430a0520f0a822c (patch) | |
| tree | 337afbc8831baddd574700b0a0150102d5120e69 /weatbag/action.py | |
| parent | 7f6cb008d54bb650662605ecd702089f87eea70d (diff) | |
| parent | f19f86792b33beaf2e1e12989a85557ae7fbc29c (diff) | |
Merge branch 'master' of git://github.com/takluyver/weatbag into southern-tiles-1
Getting everything up to date before I continue. Also see if anyone has added cool new features.
Diffstat (limited to 'weatbag/action.py')
| -rw-r--r-- | weatbag/action.py | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/weatbag/action.py b/weatbag/action.py index 9ef0f47..73e5a47 100644 --- a/weatbag/action.py +++ b/weatbag/action.py @@ -1,24 +1,23 @@ import sys from . import words +from weatbag.items import combine def get_action(): """Prompts for an action, splits it into words, and removes any prepositions. - + movement actions will be represented by the move token object in this module, followed by a one-letter direction. """ action = [] while len(action) == 0: action = input('> ').lower().split() - for prep in words.prepositions.intersection(action): - action.remove(prep) - + action = [w for w in action if w not in words.prepositions] return action move_directions = {'n','e','s','w','north','east','south','west'} def is_move(do): - return len(do) == 2 and (do[0] in words.move) and (do[1] in move_directions) + return len(do) == 2 and (do[0] in words.move) and (do[1] in move_directions) def handle_action(tile, player, do): if len(do) == 1 and do[0] == 'quit': @@ -35,6 +34,32 @@ def handle_action(tile, player, do): break print(item, '(%d)' % n) + elif len(do) >= 3 and (do[0] in words.combine): + for split in range(2, len(do)): + item1 = ' '.join(do[1:split]) + item2 = ' '.join(do[split:]) + if player.has(item1): + if player.has(item2): + results = combine(item1, item2) + if results is not None: + player.take(item1) + player.take(item2) + player.inventory.update(results) + else: + print("You can't combine {} with {}".format(item1, item2)) + + else: + print("You don't have a {}".format(item2)) + + return + + elif player.has(item2): + print("You don't have a {}".format(item1)) + return + + else: + print("You don't have those items.") + else: tile.action(player, do) |
