Skip to content

Commit 19f0fe7

Browse files
committed
style: remove unnecessary whitespace in code files for cleaner formatting
1 parent 0015c5b commit 19f0fe7

File tree

10 files changed

+61
-61
lines changed

10 files changed

+61
-61
lines changed

packages/r/karma1337/conway/conway.gno

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ func LoadPatternAt(_ realm, pattern string, coordinate string) bool {
8686
// Render displays the current state of the game as a formatted string.
8787
func Render(path string) string {
8888
var output strings.Builder
89-
89+
9090
output.WriteString("# Conway's Game of Life\n\n")
9191
output.WriteString("Generation: " + strconv.Itoa(currentGrid.GetGeneration()) + "\n\n")
92-
92+
9393
output.WriteString(renderer.RenderHelp(patternManager))
9494
output.WriteString(renderer.RenderGrid(currentGrid))
95-
95+
9696
return output.String()
9797
}
9898

@@ -126,22 +126,22 @@ func parseCoordinate(coordinate string) (int, int, bool) {
126126
if len(coordinate) < 2 {
127127
return -1, -1, false
128128
}
129-
129+
130130
// Extract letter part and number part
131131
letter := coordinate[:1]
132132
numberStr := coordinate[1:]
133-
133+
134134
// Convert letter to column
135135
col := letterToColumn(letter)
136136
if col == -1 {
137137
return -1, -1, false
138138
}
139-
139+
140140
// Convert number string to row
141141
row, err := strconv.Atoi(numberStr)
142142
if err != nil || row < 0 || row >= GRID_HEIGHT {
143143
return -1, -1, false
144144
}
145-
145+
146146
return col, row, true
147-
}
147+
}

packages/r/karma1337/conway/conway_test.gno

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ func TestCoordinateParsing(t *testing.T) {
1414
if col != 5 || row != 5 {
1515
t.Errorf("Expected F5 to parse to (5,5), got (%d,%d)", col, row)
1616
}
17-
17+
1818
// Test invalid coordinates
1919
_, _, valid = parseCoordinate("")
2020
if valid {
2121
t.Error("Expected empty string to be invalid")
2222
}
23-
23+
2424
_, _, valid = parseCoordinate("AA")
2525
if valid {
2626
t.Error("Expected coordinate without number to be invalid")
@@ -34,32 +34,32 @@ func TestLetterColumnConversion(t *testing.T) {
3434
if col != 0 {
3535
t.Errorf("Expected A to convert to 0, got %d", col)
3636
}
37-
37+
3838
col = letterToColumn("F")
3939
if col != 5 {
4040
t.Errorf("Expected F to convert to 5, got %d", col)
4141
}
42-
42+
4343
// Test invalid input
4444
col = letterToColumn("")
4545
if col != -1 {
4646
t.Errorf("Expected empty string to return -1, got %d", col)
4747
}
48-
48+
4949
// Test column to letter conversion
5050
letter := columnToLetter(0)
5151
if letter != "A" {
5252
t.Errorf("Expected 0 to convert to A, got %s", letter)
5353
}
54-
54+
5555
letter = columnToLetter(5)
5656
if letter != "F" {
5757
t.Errorf("Expected 5 to convert to F, got %s", letter)
5858
}
59-
59+
6060
// Test invalid column
6161
letter = columnToLetter(-1)
6262
if letter != "" {
6363
t.Errorf("Expected -1 to return empty string, got %s", letter)
6464
}
65-
}
65+
}

packages/r/karma1337/conway/game.gno

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ func (ge *GameEngine) ApplyRules(isAlive bool, neighborCount int) bool {
4141
func (ge *GameEngine) Step(grid *Grid) *Grid {
4242
newGrid := NewGrid()
4343
newGrid.generation = grid.generation + 1
44-
44+
4545
for y := 0; y < GRID_HEIGHT; y++ {
4646
for x := 0; x < GRID_WIDTH; x++ {
4747
neighbors := ge.CountNeighbors(grid, x, y)
4848
alive := grid.GetCell(x, y)
4949
newGrid.SetCell(x, y, ge.ApplyRules(alive, neighbors))
5050
}
5151
}
52-
52+
5353
return newGrid
54-
}
54+
}

packages/r/karma1337/conway/game_test.gno

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func TestGridCreation(t *testing.T) {
1111
if grid == nil {
1212
t.Error("Expected NewGrid to return a non-nil grid")
1313
}
14-
14+
1515
// Test initial state
1616
if grid.GetCell(0, 0) {
1717
t.Error("Expected new grid cells to be dead initially")
@@ -34,7 +34,7 @@ func TestPatternManagerCreation(t *testing.T) {
3434
if pm == nil {
3535
t.Error("Expected NewPatternManager to return a non-nil pattern manager")
3636
}
37-
37+
3838
// Test that it has some patterns
3939
patterns := pm.GetAvailablePatterns()
4040
if len(patterns) == 0 {
@@ -49,4 +49,4 @@ func TestRendererCreation(t *testing.T) {
4949
if r == nil {
5050
t.Error("Expected NewRenderer to return a non-nil renderer")
5151
}
52-
}
52+
}

packages/r/karma1337/conway/grid.gno

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ func (g *Grid) Copy() *Grid {
6464
}
6565
newGrid.cells = g.cells // Array copy in Go
6666
return newGrid
67-
}
67+
}

packages/r/karma1337/conway/grid_test.gno

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ func TestGridOperations(t *testing.T) {
1111
if grid == nil {
1212
t.Error("Expected NewGrid to return a non-nil grid")
1313
}
14-
14+
1515
// Test setting and getting cells
1616
grid.SetCell(5, 5, true)
1717
if !grid.GetCell(5, 5) {
1818
t.Error("Expected cell to be alive after setting to true")
1919
}
20-
20+
2121
grid.SetCell(5, 5, false)
2222
if grid.GetCell(5, 5) {
2323
t.Error("Expected cell to be dead after setting to false")
@@ -27,12 +27,12 @@ func TestGridOperations(t *testing.T) {
2727
// TestGridGeneration tests generation tracking and incrementing functionality.
2828
func TestGridGeneration(t *testing.T) {
2929
grid := NewGrid()
30-
30+
3131
// Initial generation should be 0
3232
if grid.GetGeneration() != 0 {
3333
t.Errorf("Expected initial generation to be 0, got %d", grid.GetGeneration())
3434
}
35-
35+
3636
// Test incrementing generation
3737
grid.IncrementGeneration()
3838
if grid.GetGeneration() != 1 {
@@ -43,22 +43,22 @@ func TestGridGeneration(t *testing.T) {
4343
// TestGridClear tests the grid clearing functionality and state reset.
4444
func TestGridClear(t *testing.T) {
4545
grid := NewGrid()
46-
46+
4747
// Set some cells alive
4848
grid.SetCell(1, 1, true)
4949
grid.SetCell(2, 2, true)
5050
grid.SetCell(3, 3, true)
51-
51+
5252
// Clear the grid
5353
grid.Clear()
54-
54+
5555
// Check that all cells are dead
5656
if grid.GetCell(1, 1) || grid.GetCell(2, 2) || grid.GetCell(3, 3) {
5757
t.Error("Expected all cells to be dead after Clear")
5858
}
59-
59+
6060
// Generation should reset to 0
6161
if grid.GetGeneration() != 0 {
6262
t.Errorf("Expected generation to be 0 after clear, got %d", grid.GetGeneration())
6363
}
64-
}
64+
}

packages/r/karma1337/conway/patterns.gno

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ func (pm *PatternManager) GetAvailablePatterns() []string {
117117
patterns = append(patterns, name)
118118
}
119119
return patterns
120-
}
120+
}

packages/r/karma1337/conway/patterns_test.gno

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func TestPatternManagerInitialization(t *testing.T) {
1010
if pm == nil {
1111
t.Error("Expected NewPatternManager to return a non-nil pattern manager")
1212
}
13-
13+
1414
// Test that we have available patterns
1515
patterns := pm.GetAvailablePatterns()
1616
if len(patterns) == 0 {
@@ -22,12 +22,12 @@ func TestPatternManagerInitialization(t *testing.T) {
2222
func TestPatternLoading(t *testing.T) {
2323
pm := NewPatternManager()
2424
grid := NewGrid()
25-
25+
2626
patterns := pm.GetAvailablePatterns()
2727
if len(patterns) == 0 {
2828
t.Skip("No patterns available to test")
2929
}
30-
30+
3131
// Test loading the first available pattern
3232
success := pm.LoadPattern(grid, patterns[0], 5, 5)
3333
if !success {
@@ -39,7 +39,7 @@ func TestPatternLoading(t *testing.T) {
3939
func TestInvalidPatternLoading(t *testing.T) {
4040
pm := NewPatternManager()
4141
grid := NewGrid()
42-
42+
4343
// Test loading a non-existent pattern
4444
success := pm.LoadPattern(grid, "nonexistent_pattern", 5, 5)
4545
if success {
@@ -51,7 +51,7 @@ func TestInvalidPatternLoading(t *testing.T) {
5151
func TestBlinkerPatternExists(t *testing.T) {
5252
pm := NewPatternManager()
5353
patterns := pm.GetAvailablePatterns()
54-
54+
5555
// Check if blinker pattern exists
5656
found := false
5757
for _, pattern := range patterns {
@@ -60,7 +60,7 @@ func TestBlinkerPatternExists(t *testing.T) {
6060
break
6161
}
6262
}
63-
63+
6464
if found {
6565
// Test loading blinker pattern
6666
grid := NewGrid()
@@ -69,4 +69,4 @@ func TestBlinkerPatternExists(t *testing.T) {
6969
t.Error("Expected blinker pattern to load successfully")
7070
}
7171
}
72-
}
72+
}

packages/r/karma1337/conway/renderer.gno

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ func NewRenderer() *Renderer {
1616
// RenderGrid converts the grid state to a visual string representation.
1717
func (r *Renderer) RenderGrid(grid *Grid) string {
1818
var output strings.Builder
19-
19+
2020
output.WriteString("\n```\n") // Start code block for proper monospace rendering
21-
21+
2222
// Grid header with column letters (A-T for 20 columns)
2323
output.WriteString(" ")
2424
for x := 0; x < GRID_WIDTH; x++ {
2525
letter := string(rune('A' + x)) // Convert to A, B, C, D...
2626
output.WriteString(letter + " ")
2727
}
2828
output.WriteString("\n")
29-
29+
3030
// Grid content
3131
for y := 0; y < GRID_HEIGHT; y++ {
3232
// Row number with proper spacing
@@ -35,7 +35,7 @@ func (r *Renderer) RenderGrid(grid *Grid) string {
3535
} else {
3636
output.WriteString(strconv.Itoa(y) + " ")
3737
}
38-
38+
3939
// Cells with spaces between them
4040
for x := 0; x < GRID_WIDTH; x++ {
4141
if grid.GetCell(x, y) {
@@ -46,16 +46,16 @@ func (r *Renderer) RenderGrid(grid *Grid) string {
4646
}
4747
output.WriteString("\n")
4848
}
49-
49+
5050
output.WriteString("```\n") // End code block
51-
51+
5252
return output.String()
5353
}
5454

5555
// RenderHelp generates the help/action text including available commands and patterns.
5656
func (r *Renderer) RenderHelp(patternManager *PatternManager) string {
5757
var output strings.Builder
58-
58+
5959
output.WriteString("Actions:\n")
6060
output.WriteString("* [NewGame](conway$help&func=NewGame) - Start a new game\n")
6161
output.WriteString("* [Step](conway$help&func=Step) - Advance one generation (high gas usage!)\n")
@@ -65,7 +65,7 @@ func (r *Renderer) RenderHelp(patternManager *PatternManager) string {
6565
output.WriteString("* [LoadPattern](conway$help&func=LoadPattern) pattern x y - Load pattern using numeric coordinates\n")
6666
output.WriteString("* [LoadPatternAt](conway$help&func=LoadPatternAt) pattern coordinate - Load pattern using letter coordinates\n")
6767
output.WriteString("* [Clear](conway$help&func=Clear) - Clear the grid\n\n")
68-
68+
6969
output.WriteString("Example commands (use --broadcast for single-step execution):\n")
7070
output.WriteString("```\n")
7171
output.WriteString("# Start new game\n")
@@ -77,7 +77,7 @@ func (r *Renderer) RenderHelp(patternManager *PatternManager) string {
7777
output.WriteString("# Set cell at (5,5) to alive (using numeric coordinates)\n")
7878
output.WriteString("gnokey maketx call -pkgpath \"gno.land/r/demo/games/conway\" -func \"SetCell\" -args \"5\" -args \"5\" -args \"true\" -gas-fee 1000000ugnot -gas-wanted 5000000 -send \"\" --broadcast ADDRESS\n")
7979
output.WriteString("```\n\n")
80-
80+
8181
// List available patterns
8282
patterns := patternManager.GetAvailablePatterns()
8383
output.WriteString("Available patterns: ")
@@ -88,6 +88,6 @@ func (r *Renderer) RenderHelp(patternManager *PatternManager) string {
8888
output.WriteString(pattern)
8989
}
9090
output.WriteString("\n\n")
91-
91+
9292
return output.String()
93-
}
93+
}

0 commit comments

Comments
 (0)