예제 #1
0
    def attempt(self):
        # Cornfield edge.
        for rank, index, coords in Hexagon.area(self.center, self.size):
            if rank >= self.size - self.wall_width:
                self.cells[coords] = (rank, self.place_corn())
            else:
                self.cells[coords] = (rank, None)

        # TODO: Return corn rows.
        self.place_passages()
        return self.cells, self.passages
예제 #2
0
    def place_passages(self):
        """Place random stairs, then set their positions in a dict."""
        if not self.passages:
            return False
        passages = {}
        perimeter = random.sample([h for h in Hexagon.perimeter(self.center, self.size - self.wall_width)], len(self.passages))

        for which, passage in self.passages.items():
            where, pos = passage
            if not pos:
                index, coords = perimeter.pop()
            # Block off the immediate surroundings.
            for rank, index, coords in Hexagon.area(coords):
                self.cells[coords] = (None, None)
            passages[which] = Path(which, where)
            self.cells[coords] = (None, passages[which])
        self.passages = passages
예제 #3
0
파일: npc.py 프로젝트: Eronarn/Hellmouth
    def retarget(self):
        target = self.owner.call("Faction", "get_target").get_result()
        if target:
            self.target = target
            self.destination = self.target.coords
            debug.log("%s retargeted to %s." % (self.owner.appearance(), self.target.appearance()))
            return True

        destination = self.owner.call("Faction", "get_destination").get_result()
        if destination:
            self.destination = destination
            debug.log("%s found no target but instead a destination." % self.owner.appearance())
            return True

        # Move somewhere random.
        debug.log("%s failed to retarget." % self.owner.appearance())
        self.destination = random.choice([h for h in Hexagon.area(self.owner.coords, 10)])
        return True
예제 #4
0
    def draw(self, display):
        map_obj = self.level.get_map()
        self.center = self.get_focus()

        # Draw the encounter map.
        for rank, index, coords in Hexagon.area(self.center, self.zoom):
            if map_obj.valid(coords) is not False:
                glyph, col = self.get_glyph(map_obj, coords)
            else:
                glyph = ','
                col = "red-black"
            display.hd(self, coords, glyph, col)

        # Draw highlights around the encounter map border.
        if len(self.get_controller().highlights) > 0:
            for highlight_id, highlight_obj in self.get_controller().highlights.items():
                if Hexagon.distance(self.center, highlight_obj.coords) > self.viewport_rank:
                    # TODO: Don't use Bresenham here, it flickers!
                    continue
                    cells = line(self.center, highlight_obj.coords, self.viewport_rank+2)
                    cell = cells.pop()
                    # TODO: Highlight color
                    glyph, col = "*", "green-black"
                    display.hd(self, cell, glyph, col)
예제 #5
0
파일: layout.py 프로젝트: Eronarn/Hellmouth
 def attempt(self):
     for rank, index, coords in Hexagon.area(self.center, self.size):
         self.cells[coords] = (rank, None)
     self.place_passages()