redo
This commit is contained in:
@@ -108,6 +108,13 @@ public record Export() {
|
|||||||
for (var h = grid.hi & MASK_HI & ~cl.hi; h != X; h &= h - 1) stream.accept(Lettrix.from(64 | Long.numberOfTrailingZeros(h), grid.g));
|
for (var h = grid.hi & MASK_HI & ~cl.hi; h != X; h &= h - 1) stream.accept(Lettrix.from(64 | Long.numberOfTrailingZeros(h), grid.g));
|
||||||
return stream.build();
|
return stream.build();
|
||||||
}
|
}
|
||||||
|
public char humanAt(int r, int c) {
|
||||||
|
int idx = c * R + r;
|
||||||
|
if (idx < 0 || idx >= 128) return '#';
|
||||||
|
boolean hasLetter = (idx < 64) ? ((grid.lo & MASK_LO & ~cl.lo) & (1L << idx)) != 0
|
||||||
|
: ((grid.hi & MASK_HI & ~cl.hi) & (1L << (idx - 64))) != 0;
|
||||||
|
return hasLetter ? LETTER(grid.g[idx]) : '#';
|
||||||
|
}
|
||||||
public String[] exportGrid(Slotinfo[] slots, Replacar clueChar, char emptyFallback) {
|
public String[] exportGrid(Slotinfo[] slots, Replacar clueChar, char emptyFallback) {
|
||||||
var sb = INIT_GRID_OUTPUT_ARR.clone();
|
var sb = INIT_GRID_OUTPUT_ARR.clone();
|
||||||
for (var slot : slots) {
|
for (var slot : slots) {
|
||||||
@@ -263,13 +270,11 @@ public record Export() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3) map of only used letter cells (everything else becomes '#')
|
// 3) render gridv2 over cropped bounds (out-of-bounds become '#')
|
||||||
var map = grid.stream().collect(Collectors.toMap(Lettrix::index, Lettrix::human));
|
|
||||||
// 4) render gridv2 over cropped bounds (out-of-bounds become '#')
|
|
||||||
var gridv2 = new String[Math.max(0, maxR - minR + 1)];
|
var gridv2 = new String[Math.max(0, maxR - minR + 1)];
|
||||||
for (int r = minR, i = 0; r <= maxR; r++, i++) {
|
for (int r = minR, i = 0; r <= maxR; r++, i++) {
|
||||||
var row = new StringBuilder(Math.max(0, maxC - minC + 1));
|
var row = new StringBuilder(Math.max(0, maxC - minC + 1));
|
||||||
for (var c = minC; c <= maxC; c++) row.append(map.getOrDefault(r | (c << 3), '#'));
|
for (var c = minC; c <= maxC; c++) row.append(grid.humanAt(r, c));
|
||||||
gridv2[i] = row.toString();
|
gridv2[i] = row.toString();
|
||||||
}
|
}
|
||||||
// 5) words output with cropped coordinates
|
// 5) words output with cropped coordinates
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ public class MarkerTest {
|
|||||||
// arrow cells are NOT in letterAt unless they are also part of a word (unlikely).
|
// arrow cells are NOT in letterAt unless they are also part of a word (unlikely).
|
||||||
// So (0,0) should be '#'
|
// So (0,0) should be '#'
|
||||||
assertEquals(1, exported.grid().length);
|
assertEquals(1, exported.grid().length);
|
||||||
//assertEquals("#TEST", exported.grid()[0]);
|
assertEquals("#TEST", exported.grid()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user