diagonalDownRight method
Color in diagonal with a direction down right from a current position defined by the movement.
Requires a list of colors
and a number n
of cells to color.
If no number n
of cells is passed all the diagonal is colored.
Return true on success.
Implementation
bool diagonalDownRight(List<int> colors, [int? n]) {
int? param = n;
int j = 0;
int offset = 0;
bool once = false;
if (param == null) {
while (move.diagonalUpLeft()) {
offset++;
}
final List<int> newColors = buildOffset(colors, offset);
while (color(newColors[j]) && move.diagonalDownRight()) {
j = (j + 1) % colors.length;
once = true;
}
if (once) {
return true;
}
return false;
} else {
param--;
}
if (param < 1 || !color(colors[j])) {
return false;
}
for (int i = 0; i < param; i++) {
j = (j + 1) % colors.length;
if (!move.diagonalDownRight() || !color(colors[j])) {
return false;
}
}
return true;
}