def loadBiomes(self): files = getBiomeFiles(self.biomePath) self.biomes = {} for biomeID, f in enumerate(files): print biomeID, f b = Biome(f, biomeID) self.biomes[biomeID] = b
def getTileAtElevation(self, elevation): weightedTiles = self.elevations.get(elevation, self.elevations["defaultTiles"]) weights = [x[1] for x in weightedTiles] choiceIndex = getWeightedRandomChoice(weights) tile = weightedTiles[choiceIndex][0] # Set up some niceties, for the different debug views on the function keys tile.elevation = elevation tile.biomeID = self.id return tile if __name__ == "__main__": testBiomePath = "biomes" files = getBiomeFiles(testBiomePath) biomes = {} for f in files: print f b = Biome(f, f + "_id") biomes[b.id] = b for biomeID in biomes: b = biomes[biomeID] print "Biome Name:", b.name print "Biome ID:", b.id print "Tiles:" for tile in b.tiles.values(): print " <Tile: %s, \"%s\", \"%s\", %s, col=%s, \"%s\">" % (tile.glyph, tile.name, tile.allGlyphs, tile.color, tile.collidable, tile.description)