예제 #1
0
    def create_map(self, map_radius):
        self.universe_map = {}
        for q in Tile.frange_le(-map_radius, map_radius):
            r1 = max(-map_radius, -q - map_radius)
            r2 = min(map_radius, -q + map_radius)

            for r in Tile.frange_le(r1, r2):
                hex = Tile.Hex(q, r, -q - r)
                system = System.System(hex, None,
                                       None)  #location, faction, planets
                planets = []
                for i in range(random.randint(1, 4)):
                    planet_type = random.randint(1, 5)
                    if (planet_type == 1):
                        planets.append(
                            Planet.Planet(hex, system, None, None,
                                          Planet_Type.Desert())
                        )  #location, system, faction, bases, planet_type
                    elif (planet_type == 2):
                        planets.append(
                            Planet.Planet(hex, system, None, None,
                                          Planet_Type.MoltenLava())
                        )  #location, system, faction, bases, planet_type
                    elif (planet_type == 3):
                        planets.append(
                            Planet.Planet(hex, system, None, None,
                                          Planet_Type.Forset())
                        )  #location, system, faction, bases, planet_type
                    elif (planet_type == 4):
                        planets.append(
                            Planet.Planet(hex, system, None, None,
                                          Planet_Type.Ocean())
                        )  #location, system, faction, bases, planet_type
                    elif (planet_type == 5):
                        planets.append(
                            Planet.Planet(hex, system, None, None,
                                          Planet_Type.Tundra())
                        )  #location, system, faction, bases, planet_type
                system.update_planets(planets)
                self.universe_map[q, r, -q - r] = (system)