diff options
Diffstat (limited to 'weatbag')
| -rw-r--r-- | weatbag/action.py | 39 | ||||
| -rw-r--r-- | weatbag/words.py | 13 |
2 files changed, 35 insertions, 17 deletions
diff --git a/weatbag/action.py b/weatbag/action.py index 73e5a47..0f1a848 100644 --- a/weatbag/action.py +++ b/weatbag/action.py @@ -2,6 +2,7 @@ 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. @@ -14,26 +15,38 @@ def get_action(): action = [w for w in action if w not in words.prepositions] return action -move_directions = {'n','e','s','w','north','east','south','west'} +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 display_help(): + print("Available commands:") + print("move, give, use, fight, drop, take, look, attack, combine, talk, help, exit") + def handle_action(tile, player, do): - if len(do) == 1 and do[0] == 'quit': + + if len(do) == 1 and (do[0] in words.exit): sys.exit() - + + elif len(do) == 1 and (do[0] in words.instructions): + # Show help text + display_help() + elif len(do) == 2 and (do[0] in words.look) and (do[1] in words.surroundings): # Look around tile.describe() - + elif len(do) == 2 and (do[0] in words.look) and (do[1] in words.inventory): # Look at bag for item, n in player.inventory.most_common(): if n < 1: 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]) @@ -47,25 +60,25 @@ def handle_action(tile, player, do): 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) move_coords = { - 'n': (0, 1), + 'n': (0, 1), 's': (0, -1), 'w': (-1, 0), - 'e': (1, 0) + 'e': (1, 0) } diff --git a/weatbag/words.py b/weatbag/words.py index 05661aa..3d5cff6 100644 --- a/weatbag/words.py +++ b/weatbag/words.py @@ -7,7 +7,7 @@ e.g. This will recognise take, pick, get or collect:: #... """ # Verbs -move = {'move','walk','go'} +move = {'move', 'walk', 'go'} give = {'give', 'feed', 'present'} use = {'eat', 'use', 'wear'} fight = {'fight', 'kill', 'hit', 'attack'} @@ -22,8 +22,13 @@ talk = {'talk', 'speak', 'converse'} inventory = {'inventory', 'possessions', 'belongings', 'bag'} surroundings = {'surroundings', 'around', 'scenery'} +# Prepositions prepositions = {'up', 'down', 'on', 'under', 'in', 'at', 'to', 'with', 'and'} -# yes/no -yes = {'yes','y','yup','ye'} -no = {'no','n','nope'} +# Yes/No +yes = {'yes', 'y', 'yup', 'ye'} +no = {'no', 'n', 'nope'} + +# Control +instructions = {'instructions', 'help', '?', 'tutorial'} +exit = {'exit', 'quit'} |
