Skip to content

Commit 31c2bff

Browse files
committed
square commands expanded
1 parent 18535b4 commit 31c2bff

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

lib/src/coloring/advanced_coloring.dart

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,29 @@ class Coloring extends BasicColoring {
216216
return false;
217217
}
218218

219+
/// Color with a square shape from the current position.
220+
///
221+
/// Requires a list of [colors].
222+
bool squareBottomLeftReverse(List<int> colors, [int? n]) {
223+
final int originalRow = move.row;
224+
final int originalColumn = move.column;
225+
if (move.up() && move.right() && move.down()) {
226+
move.toPosition(originalRow, originalColumn);
227+
color(colors[0 % colors.length]);
228+
move.up();
229+
color(colors[1 % colors.length]);
230+
move.right();
231+
color(colors[2 % colors.length]);
232+
move.down();
233+
color(colors[3 % colors.length]);
234+
235+
return true;
236+
}
237+
move.toPosition(originalRow, originalColumn);
238+
239+
return false;
240+
}
241+
219242
/// Color with a square shape from the current position.
220243
///
221244
/// Requires a list of [colors].
@@ -239,6 +262,29 @@ class Coloring extends BasicColoring {
239262
return false;
240263
}
241264

265+
/// Color with a square shape from the current position.
266+
///
267+
/// Requires a list of [colors].
268+
bool squareBottomRightReverse(List<int> colors, [int? n]) {
269+
final int originalRow = move.row;
270+
final int originalColumn = move.column;
271+
if (move.left() && move.up() && move.right()) {
272+
move.toPosition(originalRow, originalColumn);
273+
color(colors[0 % colors.length]);
274+
move.left();
275+
color(colors[1 % colors.length]);
276+
move.up();
277+
color(colors[2 % colors.length]);
278+
move.right();
279+
color(colors[3 % colors.length]);
280+
281+
return true;
282+
}
283+
move.toPosition(originalRow, originalColumn);
284+
285+
return false;
286+
}
287+
242288
/// Color with a square shape from the current position.
243289
///
244290
/// Requires a list of [colors].
@@ -262,6 +308,29 @@ class Coloring extends BasicColoring {
262308
return false;
263309
}
264310

311+
/// Color with a square shape from the current position.
312+
///
313+
/// Requires a list of [colors].
314+
bool squareTopLeftReverse(List<int> colors, [int? n]) {
315+
final int originalRow = move.row;
316+
final int originalColumn = move.column;
317+
if (move.right() && move.down() && move.left()) {
318+
move.toPosition(originalRow, originalColumn);
319+
color(colors[0 % colors.length]);
320+
move.right();
321+
color(colors[1 % colors.length]);
322+
move.down();
323+
color(colors[2 % colors.length]);
324+
move.left();
325+
color(colors[3 % colors.length]);
326+
327+
return true;
328+
}
329+
move.toPosition(originalRow, originalColumn);
330+
331+
return false;
332+
}
333+
265334
/// Color with a square shape from the current position.
266335
///
267336
/// Requires a list of [colors].
@@ -285,6 +354,29 @@ class Coloring extends BasicColoring {
285354
return false;
286355
}
287356

357+
/// Color with a square shape from the current position.
358+
///
359+
/// Requires a list of [colors].
360+
bool squareTopRightReverse(List<int> colors, [int? n]) {
361+
final int originalRow = move.row;
362+
final int originalColumn = move.column;
363+
if (move.down() && move.right() && move.up()) {
364+
move.toPosition(originalRow, originalColumn);
365+
color(colors[0 % colors.length]);
366+
move.down();
367+
color(colors[1 % colors.length]);
368+
move.right();
369+
color(colors[2 % colors.length]);
370+
move.up();
371+
color(colors[3 % colors.length]);
372+
373+
return true;
374+
}
375+
move.toPosition(originalRow, originalColumn);
376+
377+
return false;
378+
}
379+
288380
/// Color with an zig-zag pattern with direction down left right
289381
/// from a starting position
290382
///

lib/src/command_caller.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class CommandCaller {
3535
"squareBottomRight": board.squareBottomRight,
3636
"squareTopLeft": board.squareTopLeft,
3737
"squareTopRight": board.squareTopRight,
38+
"squareBottomLeftReverse": board.squareBottomLeftReverse,
39+
"squareBottomRightReverse": board.squareBottomRightReverse,
40+
"squareTopLeftReverse": board.squareTopLeftReverse,
41+
"squareTopRightReverse": board.squareTopRightReverse,
3842
"diagonalUpLeft": board.diagonalUpLeft,
3943
"diagonalUpRight": board.diagonalUpRight,
4044
"diagonalDownLeft": board.diagonalDownLeft,

0 commit comments

Comments
 (0)