assertNoOverlap method

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

Implementation

@visibleForTesting
void assertNoOverlap(Map<Stone, StoneStartPosition> stonesPositions) {
  final bounds = stonesPositions.map((key, value) => MapEntry(
      key,
      Rect.fromLTWH(value.x.toDouble(), value.y.toDouble(),
          key.width.toDouble(), key.height.toDouble())));
  bool overlap = false;
  bounds.forEach((key, value) {
    bounds.forEach((key2, value2) {
      if (key != key2 && value.overlaps(value2)) {
        overlap = true;
        print(
            "Overlapping stones: $key (${stonesPositions[key]})\n $key2 (${stonesPositions[key2]})");
      }
    });
  });
  assert(!overlap,
      "Two stones or more are overlapping (check console for more details)!");
}