paintMultileCells method

void paintMultileCells(
  1. List<String> colors,
  2. List<String> cellsPositions
)

Implementation

void paintMultileCells(List<String> colors, List<String> cellsPositions) {
  final List<int> colorsParsed =
      colors.map((String e) => containsColor(e.trim()).index).toList();
  if (colorsParsed.contains(CatColors.NaC.index) || colors.isEmpty) {
    _error = CatError.invalidColor;

    return;
  }
  final int column = _commandCaller.board.move.column;
  final int row = _commandCaller.board.move.row;
  final StringBuffer newCommand = StringBuffer();
  int j = 0;
  if(cellsPositions.isEmpty){
    _error = CatError.invalidCell;

    return;
  }
  for (final String i in cellsPositions) {
    newCommand
      ..write("go($i)")
      ..write("paint(${colors[j]})");
    j = (j + 1) % colors.length;
  }
  _parse(newCommand.toString(), false);
  _commandCaller.board.move.toPosition(row, column);
}