コード例 #1
0
    def __init__(self, hex1, hex2, hex3):
        self.coordinate = sorted([hex1,hex2,hex3])
        self.x = self.coordinate[0]
        self.y = self.coordinate[1]
        self.z = self.coordinate[2]

        self.vertex = False

        self.building = 0 #empty = 0, settlement = 1, city == 2
        self.building_ownership = 0 #set this equal to the player.index

        self.tk_index = None  # Tkinter index of settlement or city

        port_tile_pairs = [[15,16],[2,9],[4,10],
                            [12,19],[27,26],[40,33],
                            [46,38],[44,37],[29,30]]

        self.is_port = False
        for pair in port_tile_pairs:
            if (pair[0] in self.coordinate) and (pair[1] in self.coordinate):
                self.is_port = True

        #self.settlement_owner = 0  # Owner of settlement on point
        #self.city_owner = 0  # Owner of city on point

        # Check whether point is valid on board
        tile_1 = Tile(self.x)
        tile_2 = Tile(self.y)
        tile_3 = Tile(self.z)
        if tile_1.has_neighbor(tile_2) and tile_2.has_neighbor(tile_3) and \
            tile_3.has_neighbor(tile_1):
            if not(tile_1.visible) and not(tile_2.visible) and \
                not(tile_3.visible):
                self.valid = False
            else:
                self.valid = True
        else:
            self.valid = False