检查worldmap中位置(x,y)是否存在地理点

时间:2015-11-30 22:29:32

标签: python python-3.x

我在课堂上被分配了一个文本冒险游戏,代码的一部分就像这样

class World:

   def __init__(self, mapdata, locdata, itemdata): 
       self.geographicalloc = {}

   def get_geographicalloc(self, x, y):
    '''Check if geographical location exists at location (x,y) in worldmap.
    Return Location object associated with this location if it does. Else, return None.
    Remember, locations represented by the number -1 on the map should return None.
    :param x: integer x representing x-coordinate of world map
    :param y: integer y representing y-coordinate of world map
    :return: Return Location object associated with this location if it does. Else, return None.
    '''

我的代码就像这样

for self.x and self.y not in self.geographicloc:
    return None    
return self.geographicalloc((x, y))

我并不是真正理解这个问题的主要概念。对于这部分问题,它是一个文本冒险游戏的位置,我很困惑。我只是试图删除所有代码,然后写

return self.geographicalloc((x, y))

但我得到一个错误说TypeError:'dict'对象不可调用

0 个答案:

没有答案