-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e029959
commit 8cd754b
Showing
10 changed files
with
109 additions
and
115 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
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
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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package contract | ||
|
||
import "github.com/kingmidas74/gonesis-engine/pkg/maze/cell" | ||
|
||
type MazeGenerator interface { | ||
Generate(width, height int) ([]cell.Cell, error) | ||
} |
15 changes: 15 additions & 0 deletions
15
internal/domain/entity/maze_generator_collection/collection.go
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package maze_generator_collection | ||
|
||
import "github.com/kingmidas74/gonesis-engine/internal/domain/contract" | ||
|
||
func (c *MazeGeneratorCollection) Register(mazeType contract.MazeType, mazeGenerator contract.MazeGenerator) { | ||
c.mazeGenerators[mazeType] = mazeGenerator | ||
} | ||
|
||
func (c *MazeGeneratorCollection) Get(mazeType contract.MazeType) (contract.MazeGenerator, error) { | ||
mazeGenerator, ok := c.mazeGenerators[mazeType] | ||
if !ok { | ||
return nil, ErrMazeGenerationTypeIsNotSupported | ||
} | ||
return mazeGenerator, nil | ||
} |
18 changes: 18 additions & 0 deletions
18
internal/domain/entity/maze_generator_collection/constructor.go
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package maze_generator_collection | ||
|
||
import ( | ||
"errors" | ||
"github.com/kingmidas74/gonesis-engine/internal/domain/contract" | ||
) | ||
|
||
type MazeGeneratorCollection struct { | ||
mazeGenerators map[contract.MazeType]contract.MazeGenerator | ||
} | ||
|
||
func New() *MazeGeneratorCollection { | ||
return &MazeGeneratorCollection{ | ||
mazeGenerators: map[contract.MazeType]contract.MazeGenerator{}, | ||
} | ||
} | ||
|
||
var ErrMazeGenerationTypeIsNotSupported = errors.New("maze generation type is not supported") |
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
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
This file was deleted.
Oops, something went wrong.
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