Skip to content

Commit 851866e

Browse files
committed
Fix: Manage Render files
1 parent e5b782e commit 851866e

File tree

2 files changed

+59
-59
lines changed

2 files changed

+59
-59
lines changed

packages/r/pierre115/gnopub/grid.gno

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -36,44 +36,6 @@ func init() {
3636
}
3737
}
3838

39-
// Render the grid
40-
func renderGrid() string {
41-
out := ""
42-
43-
// Grid cells
44-
for y := 0; y < grid.Height; y++ {
45-
for x := 0; x < grid.Width; x++ {
46-
key := ufmt.Sprintf("%d,%d", x, y)
47-
color := defaultcolor
48-
link := defaultlink
49-
// If the cell is owned, use its color
50-
if cell, ok := grid.Cells[key]; ok {
51-
color = cell.Color
52-
caller := runtime.PreviousRealm().Address()
53-
54-
if cell.Url != "" {
55-
link = cell.Url
56-
}
57-
58-
// If the cell is owned by someone else, link to their pub if set
59-
if cell.Owner != "" && cell.Owner != caller {
60-
out += svgbtn.Button(cellSize, cellSize, color, "#333333", cell.Label, link)
61-
out += strings.Repeat("&nbsp;", spacingCount)
62-
continue
63-
}
64-
}
65-
link = txlink.NewLink("BuyCell").
66-
AddArgs("x", ufmt.Sprintf("%d", x), "y", ufmt.Sprintf("%d", y)).
67-
URL()
68-
out += svgbtn.Button(cellSize, cellSize, color, "#333333", "available", link)
69-
out += strings.Repeat("&nbsp;", spacingCount)
70-
}
71-
out += "\n\n"
72-
}
73-
74-
return out
75-
}
76-
7739
// Function to validate the coordinates
7840
func getCoordinate(x, y int) string {
7941
if x < 0 || x >= grid.Width || y < 0 || y >= grid.Height {
@@ -182,27 +144,6 @@ func Reset() string {
182144
return "The grid was successfully reset."
183145
}
184146

185-
// Stats of the grid (per cells owners)
186-
func getStats() string {
187-
stats := make(map[address]int)
188-
for _, cell := range grid.Cells {
189-
if cell.Owner != "" {
190-
stats[cell.Owner]++
191-
}
192-
}
193-
194-
out := "## Stats 📊:\n"
195-
if len(stats) == 0 {
196-
out += "No cells used.\n"
197-
return out
198-
}
199-
200-
for owner, count := range stats {
201-
out += ufmt.Sprintf("- %s: %d cell(s)\n", owner.String(), count)
202-
}
203-
return out
204-
}
205-
206147
func getColorName(color string) string {
207148
switch color {
208149
case "#f44336":

packages/r/pierre115/gnopub/render.gno

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,62 @@ func Render(path string) string {
4949

5050
return out
5151
}
52+
53+
// Render the grid
54+
func renderGrid() string {
55+
out := ""
56+
57+
// Grid cells
58+
for y := 0; y < grid.Height; y++ {
59+
for x := 0; x < grid.Width; x++ {
60+
key := ufmt.Sprintf("%d,%d", x, y)
61+
color := defaultcolor
62+
link := defaultlink
63+
// If the cell is owned, use its color
64+
if cell, ok := grid.Cells[key]; ok {
65+
color = cell.Color
66+
caller := runtime.PreviousRealm().Address()
67+
68+
if cell.Url != "" {
69+
link = cell.Url
70+
}
71+
72+
// If the cell is owned by someone else, link to their pub if set
73+
if cell.Owner != "" && cell.Owner != caller {
74+
out += svgbtn.Button(cellSize, cellSize, color, "#333333", cell.Label, link)
75+
out += strings.Repeat("&nbsp;", spacingCount)
76+
continue
77+
}
78+
}
79+
link = txlink.NewLink("BuyCell").
80+
AddArgs("x", ufmt.Sprintf("%d", x), "y", ufmt.Sprintf("%d", y)).
81+
URL()
82+
out += svgbtn.Button(cellSize, cellSize, color, "#333333", "available", link)
83+
out += strings.Repeat("&nbsp;", spacingCount)
84+
}
85+
out += "\n\n"
86+
}
87+
88+
return out
89+
}
90+
91+
// Stats of the grid (per cells owners)
92+
func getStats() string {
93+
stats := make(map[address]int)
94+
for _, cell := range grid.Cells {
95+
if cell.Owner != "" {
96+
stats[cell.Owner]++
97+
}
98+
}
99+
100+
out := "## Stats 📊:\n"
101+
if len(stats) == 0 {
102+
out += "No cells used.\n"
103+
return out
104+
}
105+
106+
for owner, count := range stats {
107+
out += ufmt.Sprintf("- %s: %d cell(s)\n", owner.String(), count)
108+
}
109+
return out
110+
}

0 commit comments

Comments
 (0)