MCPcopy Create free account
hub / github.com/SolarLune/masterplan / ForEachCell

Method ForEachCell

grid.go:165–197  ·  view source on GitHub ↗
(forEach func(c *GridCell) bool)

Source from the content-addressed store, hash-verified

163}
164
165func (selection GridSelection) ForEachCell(forEach func(c *GridCell) bool) {
166
167 offsetY := len(selection.Grid.Cells) / 2
168 offsetX := len(selection.Grid.Cells[0]) / 2
169
170 for y := selection.Start.Y; y < selection.End.Y; y++ {
171 for x := selection.Start.X; x < selection.End.X; x++ {
172 cy := int(y) + offsetY
173 cx := int(x) + offsetX
174
175 if cy < 0 {
176 cy = 0
177 }
178 if cy >= len(selection.Grid.Cells) {
179 cy = len(selection.Grid.Cells) - 1
180 }
181
182 if cx < 0 {
183 cx = 0
184 }
185 if cx >= len(selection.Grid.Cells[0]) {
186 cx = len(selection.Grid.Cells[0]) - 1
187 }
188
189 if !forEach(selection.Grid.Cells[cy][cx]) {
190 return
191 }
192
193 }
194
195 }
196
197}
198
199func (selection GridSelection) OutsideGrid() bool {
200

Callers 1

ForEachCardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected