From 19ab3c9cf3dffe3324e7163a4f4f015705e28967 Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Sat, 5 Aug 2023 11:20:53 +0200 Subject: [PATCH] Added String() method to RawMaze for debugging purposes --- maze/maze.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/maze/maze.go b/maze/maze.go index c95c00e..3cb708a 100644 --- a/maze/maze.go +++ b/maze/maze.go @@ -1,5 +1,10 @@ package maze +import ( + "fmt" + "strings" +) + type Coordinates struct { X, Y int } @@ -24,6 +29,23 @@ type RawMaze struct { Data []string } +func (m *RawMaze) String() string { + var ret strings.Builder + ret.WriteString("{\n") + ret.WriteString(fmt.Sprintf("\tPathChar: %v,\n", m.PathChar)) + ret.WriteString(fmt.Sprintf("\tWallChar: %v,\n", m.WallChar)) + ret.WriteString("\tData: \n") + for _, line := range m.Data { + ret.WriteRune('\t') + ret.WriteRune('\t') + ret.WriteString(line) + ret.WriteRune('\n') + } + ret.WriteString("}") + + return ret.String() +} + type Maze struct { Width, Height uint Nodes []*Node