コード例 #1
0
ファイル: common.py プロジェクト: oubiwann/myriad-worlds
 def getExits(self):
     reply = "\n"
     numExits = sum([1 for exit in self.exits if exit is not None])
     if numExits == 0:
         reply += "There are no %s in any direction." % self.getExitName()
     else:
         if numExits == 1:
             reply += "There is a %s to the " % self.getExitName()
         else:
             reply += "There are %ss to the " % self.getExitName()
         exitNames = [util.getDirectionName(exit)
                      for exit, room in enumerate(self.exits)
                      if room is not None]
         reply += util.enumerateExits(exitNames)
         reply += "."
         return reply
コード例 #2
0
ファイル: test_util.py プロジェクト: oubiwann/myriad-worlds
 def test_getDirectionName(self):
     result = [util.getDirectionName(x) for x in xrange(11)]
     expected = ["north", "south", "east", "west", "northeast", "southeast",
                 "southwest", "northwest", "center", "up", "down"]
     self.assertEqual(result, expected)