toMirror method

dynamic toMirror(
  1. dynamic arrangement
)

Mirrors a starting position's arrangement of pieces (its "twin").

param arrangement A starting position's arrangement returns The mirrored arrangement of pieces, or false if invalid arrangement

Implementation

dynamic toMirror(arrangement) {
    if (!FischerRandomValidators().isValidArrangement(arrangement)) return false;
    List<String> converted = [];
    if (arrangement is String) {
      converted = arrangement.runes.map((e) => String.fromCharCode(e).toString()).toList().reversed.toList();
    } else if (arrangement is List<String>) {
      converted = arrangement.reversed.toList();
    }
    return converted;
  }