Commits

Brandon Rhodes  committed e0c0efe

Debugged the last carry() edge cases, and fixed a big data problem: only
the first of a list of verb synonyms was getting its default_message set!

  • Participants
  • Parent commits 0278da2

Comments (0)

Files changed (3)

File adventure/data.py

         return
     word = make_object(data.vocabulary, Word, word_n + 2000)
     message = make_object(data.messages, Message, message_n)
-    word.default_message = message
+    for word2 in word.synonyms:
+        word2.default_message = message
 
 def section9(data, bit, *nlist):
     for n in nlist:

File adventure/game.py

 
     def t_carry(self, verb, obj):  #9010
         if obj.is_toting:
-            self.write_message(verb.default_message or 54)
+            self.write(verb.default_message)
             self.finish_turn()
             return
         if obj.is_fixed or len(obj.rooms) > 1:
                 obj = self.bottle
             else:
                 # They must mean they want to fill the bottle.
-                if self.bottle.is_toting and self.bottle.contents is None:
+                if not self.bottle.is_toting:
+                    self.write_message(104)
+                elif self.bottle.contents is not None:
+                    self.write_message(105)
+                else:
                     self.t_fill(verb, self.bottle)  # hand off control to "fill"
                     return
-                elif self.bottle.contents is not None:
-                    self.write_message(105)
-                elif not self.bottle.is_toting:
-                    self.write_message(104)
-                else:
-                    self.write_message(verb.default_message)
                 self.finish_turn()
                 return
         if len(self.inventory) >= 7:
             obj = self.rod2
 
         if not obj.is_toting:
-            self.write_message(verb.default_message)
+            self.write(verb.default_message)
             self.finish_turn()
             return
 
                 troll = self.troll
                 if not eggs.rooms and not troll.rooms and not troll.prop:
                     self.troll.prop = 1
-                eggs.rooms = list(eggs.starting_rooms)
                 if self.loc is start:
                     self.write(eggs.messages[0])
                 elif self.is_here(eggs):
                     self.write(eggs.messages[1])
                 else:
                     self.write(eggs.messages[2])
+                eggs.rooms = list(eggs.starting_rooms)
+                eggs.is_toting = False
         self.finish_turn()
 
     def i_brief(self, verb):  #8260

File adventure/tests/vignettes.txt

 YOU ARE IN A JUMBLE OF ROCK, WITH CRACKS EVERYWHERE.
 <BLANKLINE>
 
+And now, we exercise dozens of fiddly edge cases for verbs.
+
+>>> quiet(restart())
+>>> carry                       # ambiguous in the face of several objects
+CARRY WHAT?
+<BLANKLINE>
+
+>>> quiet(restart(room=25))
+>>> get(plant)
+THE PLANT HAS EXCEPTIONALLY DEEP ROOTS AND CANNOT BE PULLED FREE.
+<BLANKLINE>
+
+>>> quiet(restart(), goto(24))
+>>> get(oil)
+YOU HAVE NOTHING IN WHICH TO CARRY IT.
+<BLANKLINE>
+
+>>> quiet(restart(), get(bottle), goto(24))
+>>> get(oil)
+YOUR BOTTLE IS ALREADY FULL.
+<BLANKLINE>
+>>> get(bottle)
+YOU ARE ALREADY CARRYING IT!
+<BLANKLINE>
+
 
 todo: test plant2 in repository