Example #1
0
 def _paint_tile(self, pixel):
     if ui_cfg.base_style == 1:
         BoardTools.draw_vertical_hexagon(self.canvas, pixel, \
                 self.hex_radius, self._get_base_options())
     elif ui_cfg.base_style == 2:
         BoardTools.draw_rect(self.canvas, pixel, \
                 self.hex_radius, self._get_base_options())
Example #2
0
 def get_pixel_width(self):
     if ui_cfg.base_style == 1:
         tile_offsets = BoardTools.get_hex_tile_offsets(self.hex_radius)
         x_toff = tile_offsets[0]
         width = x_toff / 2 + (BASE_COLUMN_COUNT * x_toff)
         return width
     elif ui_cfg.base_style == 2:
         tile_offsets = BoardTools.get_rect_tile_offsets(self.hex_radius)
         x_toff = tile_offsets[0]
         width = (BASE_COLUMN_COUNT) * x_toff
         return width
Example #3
0
 def get_pixel_height(self):
     if ui_cfg.base_style == 1:
         tile_offsets = BoardTools.get_hex_tile_offsets(self.hex_radius)
         y_toff = tile_offsets[1]
         height = ((self.row_count-1) * y_toff) + 2 * self.hex_radius
         return height
     elif ui_cfg.base_style == 2:
         tile_offsets = BoardTools.get_rect_tile_offsets(self.hex_radius)
         y_toff = tile_offsets[1]
         height = (y_toff * self.row_count)
         return height
Example #4
0
    def _get_relative_center_pixel_for_visual_position(self, pos):
        x = pos[0]
        y = pos[1]

        offsets = BoardTools.get_hex_vertex_offsets(self.hex_radius)
        xoffset = offsets[0]
        yoffset = offsets[1]

        shifts = BoardTools.get_hex_tile_offsets(self.hex_radius)
        xshift = shifts[0]
        yshift = shifts[1]

        oddOffset = 0
        if y % 2 == 1:
            oddOffset = xoffset

        x_pixel = xoffset + oddOffset + (x * xshift)
        y_pixel = self.hex_radius + (y * yshift)
        return (x_pixel, y_pixel)
Example #5
0
    def paint(self, sector_function):
        for i in xrange(self.major):
            for j in xrange(self.minor):
                if j % 2 == 1 and i == self.major - 1:
                    continue

                visual_pos = (i, j)
                bp = BoardTools.get_backend_position_for_visual_position( \
                        visual_pos, self.minor)

                sector = sector_function(bp)
                hex_options = self._get_hexagon_options(sector)

                pixel = self.get_center_pixel_for_visual_position(visual_pos)
                BoardTools.draw_vertical_hexagon(self.canvas, pixel, \
                        self.hex_radius, hex_options)

                BoardTestTools.draw_backend_coordinates(self.canvas, \
                        visual_pos, pixel, \
                        self.hex_radius, self.minor)
Example #6
0
    def _get_relative_center_pixel_for_slot(self, slot):
        column = slot[0]
        row = slot[1]

        if ui_cfg.base_style == 1:
            vertex_offsets = BoardTools.get_hex_vertex_offsets(self.hex_radius)
            x_voff = vertex_offsets[0]
            y_voff = vertex_offsets[1]
        
            tile_offsets = BoardTools.get_hex_tile_offsets(self.hex_radius)
            x_toff = tile_offsets[0]
            y_toff = tile_offsets[1]

            oddOffset = 0
            #odd rows are shifted by a half tile 
            if row % 2 == 1:
                oddOffset = x_toff / 2

            x_pixel = (x_toff / 2) + oddOffset + (column * x_toff)
            y_pixel = self.hex_radius + (row * y_toff)
            y_pixel = self.get_pixel_height() - y_pixel

            if (self.direction == TKPlayerBase.RIGHT):
                x_pixel = self.get_pixel_width() - x_pixel

            return (x_pixel, y_pixel)

        elif ui_cfg.base_style == 2:
            tile_offsets = BoardTools.get_rect_tile_offsets(self.hex_radius)
            x_toff = tile_offsets[0]
            y_toff = tile_offsets[1]

            x_pixel = (x_toff / 2) + (column * x_toff)
            y_pixel = (y_toff / 2) + row * y_toff
            y_pixel = self.get_pixel_height() - y_pixel
            return (x_pixel, y_pixel)
Example #7
0
    def _init_simulator_casting_hexes(self):
        sector_dict = {}
        for x in xrange(self.game.board.field_length):
            for y in xrange(self.game.board.field_width):
                if x == self.game.board.field_length - 1 and y % 2 == 1:
                    continue
                pos = BoardTools.get_backend_position_for_visual_position((x, y), self.game.board.field_width)
                sector = self.game.board.get_sector_for_position(pos)
                if sector in sector_dict:
                    sector_dict[sector].append(pos)
                else:
                    sector_dict[sector] = [pos]

        self.game.board.right_facing_casting_zones = []
        self.game.board.right_facing_casting_zones.extend(sector_dict[0])
        self.game.board.right_facing_casting_zones.extend(sector_dict[1])

        self.game.board.left_facing_casting_zones = []
        self.game.board.left_facing_casting_zones.extend(sector_dict[3])
        self.game.board.left_facing_casting_zones.extend(sector_dict[4])
Example #8
0
 def get_pixel_width(self):
     xshift = BoardTools.get_hex_tile_offsets(self.hex_radius)[0]
     width = self.major * xshift
     return width
Example #9
0
 def get_pixel_height(self):
     tile_offsets = BoardTools.get_hex_tile_offsets(self.hex_radius)
     y_toff = tile_offsets[1]
     height = ((self.minor-1) * y_toff) + 2 * self.hex_radius
     return height
Example #10
0
 def get_center_pixel_for_battlefield_position(self, pos):
     vp = BoardTools.get_visual_position_for_backend_position(pos, \
             self.bf_height)
     pixel = self.battlefield.get_center_pixel_for_visual_position(vp)
     return pixel