Ejemplo n.º 1
0
 def __connect_server_and_server_nodes(self, n1: Node, n2: Node):
     """
     Creates a vertical link between two server nodes
     :param n1: node1
     :param n2: node2
     :return: the created link
     """
     _, y1, _, _ = n1.get_link_coords(lower=True, upper=False)
     x2, y2, col2, row2 = n2.get_link_coords(upper=True, lower=False)
     e1 = batch_line(x2, y1, x2, y2, constants.RENDERING.BLACK,
                     self.idsgame_config.render_config.batch,
                     self.idsgame_config.render_config.background,
                     self.idsgame_config.render_config.line_width)
     return e1
Ejemplo n.º 2
0
    def __connect_start_and_server_nodes(self, n1: Node, n2: Node):
        """
        Creates a vertical link between the start node and server nodes on the layer below

        :param n1: node1
        :param n2: node2
        :return: a list of the created links
        """
        x1, y1, col1, row1 = n1.get_link_coords(lower=True, upper=False)
        x2, y2, col2, row2 = n2.get_link_coords(upper=True, lower=False)
        e1 = batch_line(x2, y1, x2, y2, constants.RENDERING.BLACK,
                        self.idsgame_config.render_config.batch,
                        self.idsgame_config.render_config.background,
                        self.idsgame_config.render_config.line_width)
        return e1
Ejemplo n.º 3
0
    def __root_edge(self, n1: Node):
        """
        Creates the "root edge", the edge between the START node and all immediate child nodes.
        This edge is created in a special method because it should be blinking when visualizing all attacks on
        the servers in the layer below the start node

        :param n1: node1
        :return: the created edge (openGL vertex list)
        """
        x1, y1, col1, row1 = n1.get_link_coords(lower=True, upper=False)
        return batch_line(
            x1, y1 + self.idsgame_config.render_config.rect_size / 6, x1,
            y1 - self.idsgame_config.render_config.rect_size / 6,
            constants.RENDERING.BLACK, self.idsgame_config.render_config.batch,
            self.idsgame_config.render_config.background,
            self.idsgame_config.render_config.line_width)
Ejemplo n.º 4
0
    def __leaf_edge(self, n1: Node):
        """
        Creates the "leaf edge", the edge between the DATA node and the nodes on the layer above
        This edge is created in a special method because it should be blinking when visualizing all attacks on
        the data node

        :param n1: node1
        :return: the created edge (openGL vertex list)
        """
        leaf_edge = None
        x2, y2, col2, row2 = n1.get_link_coords(upper=True, lower=False)
        leaf_edge = batch_line(
            x2, y2, x2, y2 - self.idsgame_config.render_config.rect_size / 3,
            constants.RENDERING.BLACK, self.idsgame_config.render_config.batch,
            self.idsgame_config.render_config.background,
            self.idsgame_config.render_config.line_width)
        return leaf_edge
Ejemplo n.º 5
0
    def __create_horizontal_links(self, y_coord: float, row: int) -> list:
        # create horizontal links of first layer that must be shared
        y_coords = []
        x_coords = []
        horizontal_edges = []
        for col in range(
                self.idsgame_config.game_config.num_servers_per_layer):
            x1, y1, _, _ = self.grid[row][col].get_link_coords(lower=True,
                                                               upper=False)
            y_coords.append(y_coord)
            x_coords.append(x1)

        for i in range(0, len(x_coords) - 1):
            if i < len(x_coords) - 1:
                horizontal_edge = batch_line(
                    x_coords[i], y_coords[i], x_coords[i + 1], y_coords[i + 1],
                    constants.RENDERING.BLACK,
                    self.idsgame_config.render_config.batch,
                    self.idsgame_config.render_config.background,
                    self.idsgame_config.render_config.line_width)
                horizontal_edges.append(horizontal_edge)
        return horizontal_edges