tmcclintock/donjuan

GridPoint class

Opened this issue · 0 comments

We have the Cell and Edges and the next fundamental class we should implement is the GridPoint (other names include Intersection or idk). The GridPoint represents the location where Edges meet. The would be useful for a few reasons:

  • provide another location to fix objects, once we get to populating the dungeons
  • can make exporting easier if we want to draw walls/boundaries from the corners of Cells or boundaries that cut through Cells

It should be developed just like the Edge class. It should be defined in a grid_point.py file. A spec would be:

# grid_point.py

class GridPoint:

    def __init__(self, edges: Optional[List[Edge]]):
        self._edges = edges or []

    @property
    def edges(self):
        return self._edges

    def set_edges(edges: List[Edge]):
        self._edges = edges

And it should only be instantiated from within the Grid class:

# grid.py

class Grid:

    def __init__(self, ...):
        ...
        self.link_edges_to_grid_points()

    def link_edges_to_grid_points(self):
        # connect the edges to the grid_points and vice versa

The Edge class should get pointers to the GridPoints as well.