From 855da677c4aadd68e0adb16b7ef833a4f27a2153 Mon Sep 17 00:00:00 2001 From: George Angelopoulos Date: Wed, 1 May 2013 00:16:46 +0300 Subject: added yes/no words. Modified n2w2 to use words. In acec64fe4677305566cd2d0fa780056b07f7e6e6 there is a yes/no question introduced in tile n2w2. This is the first time yes/no answers appear in the game. So I added 'yes' and 'no' as words in weatbag/words.py and modified weatbag/tiles/n2w2.py to use them, making the code a bit cleaner. --- weatbag/tiles/n2w2.py | 6 ++++-- weatbag/words.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/weatbag/tiles/n2w2.py b/weatbag/tiles/n2w2.py index 31e3cff..010ff0e 100644 --- a/weatbag/tiles/n2w2.py +++ b/weatbag/tiles/n2w2.py @@ -1,3 +1,5 @@ +from weatbag import words + class Tile: def __init__(self): self.first_visit = True @@ -13,9 +15,9 @@ class Tile: print("The beach is quiet. Nothing seems to be going on.") def action(self, player, do): - if do[0] in ('Yes', 'yes', 'y', 'Y', 'Yup', 'yup', 'ye', 'Ye'): + if do[0] in words.yes: print("Awesome! Follow the path!") - elif do[0] in ('No', 'no', 'n', 'N', 'Nope', 'nope'): + elif do[0] in words.no: print("You might be in the wrong place then. Pack your stuff and " "quit the game.") else: diff --git a/weatbag/words.py b/weatbag/words.py index adaa012..3555046 100644 --- a/weatbag/words.py +++ b/weatbag/words.py @@ -23,3 +23,7 @@ inventory = {'inventory', 'possessions', 'belongings', 'bag'} surroundings = {'surroundings', 'around', 'scenery'} prepositions = {'up', 'down', 'on', 'under', 'in', 'at', 'to', 'with', 'and'} + +# yes/no +yes = {'yes','Yes','y','Y','Yup','yup','ye','Ye'} +no = {'no','No','n','N','Nope','nope','NOPE'} -- cgit v1.3 From 689563831f55feaa4315c66773b63a49a93c70b9 Mon Sep 17 00:00:00 2001 From: George Angelopoulos Date: Wed, 1 May 2013 02:02:53 +0300 Subject: Made all yes/no words lowercase. Upper not needed. Apparently, player input is converted to lowercase in weatbag/action.py, so we only need lowercase words in weatbag/words.py. --- weatbag/words.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weatbag/words.py b/weatbag/words.py index 3555046..05661aa 100644 --- a/weatbag/words.py +++ b/weatbag/words.py @@ -25,5 +25,5 @@ surroundings = {'surroundings', 'around', 'scenery'} prepositions = {'up', 'down', 'on', 'under', 'in', 'at', 'to', 'with', 'and'} # yes/no -yes = {'yes','Yes','y','Y','Yup','yup','ye','Ye'} -no = {'no','No','n','N','Nope','nope','NOPE'} +yes = {'yes','y','yup','ye'} +no = {'no','n','nope'} -- cgit v1.3