示例#1
0
文件: config.py 项目: RWJMurphy/rouge
    def __init__(self, game_yaml):
        with open(game_yaml, 'r') as game_yaml_fh:
            self.config = AttrDict(yaml.load(game_yaml_fh.read())['game'])

        self.name = self.config['name']
        self.db = AttrDict()
        for key in ['terrains', 'entities', 'items', 'monsters']:
            self.db[key] = self.config[key]
        Terrain.load_definitions(self.db['terrains'])

        self.maps = []
        for map in self.config['maps']:
            self.maps.append(Map.from_dict(map))
        self.keymap = invert(self.config.keymap)
示例#2
0
文件: map.py 项目: RWJMurphy/rouge
 def from_dict(map_dict):
     the_map = Map()
     for line in map_dict['terrain']:
         row = []
         the_map.terrain.append(row)
         for c in line:
             row.append(Terrain.from_char(c))
     the_map.player_pos = map_dict['spawn']
     return the_map
示例#3
0
文件: map.py 项目: RWJMurphy/rouge
 def __getitem__(self, i):
     if i < 0 or i >= len(self._row):
         return Terrain.null()
     else:
         return self._row[i]