-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explode grid class and logic into their own class
- Loading branch information
1 parent
dd5364d
commit 901e9cc
Showing
15 changed files
with
965 additions
and
835 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1 @@ | ||
from ..maze_logic import grids | ||
from ..maze_logic import cells as ct | ||
from ..managers import space_rep_manager as sp_rep | ||
from ..maze_logic.algorithms import manager as algorithm_manager | ||
|
||
|
||
class GridManager: | ||
grid = None | ||
|
||
def generate_grid(props) -> None: | ||
self = GridManager | ||
|
||
grid = None | ||
maze_dimension = int(props.maze_space_dimension) | ||
if props.cell_type == ct.POLAR: | ||
self.grid = grids.GridPolar( | ||
rows=props.maze_rows_or_radius, | ||
columns=0, | ||
levels=props.maze_levels if maze_dimension == int(sp_rep.REP_REGULAR) else 1, | ||
cell_size=1 - props.cell_inset, | ||
space_rep=maze_dimension, | ||
branch_polar=props.maze_polar_branch) | ||
return | ||
elif props.cell_type == ct.HEXAGON: | ||
grid = grids.GridHex | ||
elif props.cell_type == ct.TRIANGLE: | ||
grid = grids.GridTriangle | ||
elif props.cell_type == ct.OCTOGON: | ||
grid = grids.GridOctogon | ||
elif props.cell_type == ct.DODECAGON: | ||
grid = grids.GridDodecagon | ||
else: | ||
if props.maze_weave: | ||
self.grid = grids.GridWeave( | ||
rows=props.maze_rows_or_radius, | ||
columns=props.maze_columns, | ||
levels=1, | ||
cell_size=1 - max(0.2, props.cell_inset), | ||
use_kruskal=algorithm_manager.is_kruskal_random(props.maze_algorithm), | ||
weave=props.maze_weave, | ||
space_rep=maze_dimension) | ||
return | ||
elif maze_dimension == int(sp_rep.REP_BOX): | ||
rows = props.maze_rows_or_radius | ||
cols = props.maze_columns | ||
self.grid = grids.Grid( | ||
rows=3 * rows, | ||
columns=2 * cols + 2 * rows, | ||
levels=props.maze_levels if maze_dimension == int(sp_rep.REP_REGULAR) else 1, | ||
cell_size=1 - props.cell_inset, | ||
space_rep=maze_dimension, | ||
mask=[ | ||
(0, 0, rows - 1, rows - 1), | ||
(rows + cols, 0, 2 * rows + 2 * cols - 1, rows - 1), | ||
(0, 2 * rows, rows - 1, 3 * rows - 1), | ||
(rows + cols, 2 * rows, 2 * rows + 2 * cols - 1, 3 * rows - 1)]) | ||
return | ||
else: | ||
grid = grids.Grid | ||
self.grid = grid( | ||
rows=props.maze_rows_or_radius, | ||
columns=props.maze_columns, | ||
levels=props.maze_levels if maze_dimension == int(sp_rep.REP_REGULAR) else 1, | ||
cell_size=1 - props.cell_inset, | ||
space_rep=maze_dimension) |
Oops, something went wrong.