Skip to content

Commit ec757c0

Browse files
committed
Small fixes to paint command
1 parent 64c2f00 commit ec757c0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/src/interpreter.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class CATInterpreter {
176176
void paintPattern(List<String> colors, String repetitions, String pattern) {
177177
final List<int> colorsParsed =
178178
colors.map((String e) => containsColor(e.trim()).index).toList();
179-
if (colorsParsed.contains(CatColors.NaC.index)) {
179+
if (colorsParsed.contains(CatColors.NaC.index) || colors.isEmpty) {
180180
_error = CatError.invalidColor;
181181

182182
return;
@@ -211,7 +211,7 @@ class CATInterpreter {
211211
void paintMultileCells(List<String> colors, List<String> cellsPositions) {
212212
final List<int> colorsParsed =
213213
colors.map((String e) => containsColor(e.trim()).index).toList();
214-
if (colorsParsed.contains(CatColors.NaC.index)) {
214+
if (colorsParsed.contains(CatColors.NaC.index) || colors.isEmpty) {
215215
_error = CatError.invalidColor;
216216

217217
return;
@@ -220,6 +220,11 @@ class CATInterpreter {
220220
final int row = _commandCaller.board.move.row;
221221
final StringBuffer newCommand = StringBuffer();
222222
int j = 0;
223+
if(cellsPositions.isEmpty){
224+
_error = CatError.invalidCell;
225+
226+
return;
227+
}
223228
for (final String i in cellsPositions) {
224229
newCommand
225230
..write("go($i)")

0 commit comments

Comments
 (0)