assertNoDrawOutside method

  1. @visibleForTesting
void assertNoDrawOutside(
  1. Map<Stone, StoneStartPosition> stonesPositions
)

Implementation

@visibleForTesting
void assertNoDrawOutside(Map<Stone, StoneStartPosition> stonesPositions) {
  final stonesOutside = stonesPositions.map((key, value) {
    bool isOutside = false;
    if (this.direction == Axis.vertical) {
      isOutside = (value.x + key.width) > mainAxisSeparations;
    } else {
      isOutside = (value.y + key.height) > mainAxisSeparations;
    }
    return MapEntry(key, isOutside);
  });
  stonesOutside.removeWhere((key, value) => value == false);
  stonesOutside.forEach((key, _) {
    print(
        "Error: stone $key will be drawn outside wall with position ${stonesPositions[key]}");
  });
  assert(stonesOutside.isEmpty,
      "Stones must not draw outside the wall (see logs for more details)");
}