Skip to content

Commit

Permalink
Put all width coords errors together
Browse files Browse the repository at this point in the history
  • Loading branch information
Kkobarii committed Feb 4, 2024
1 parent 0a8657c commit aa485ff
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,20 @@ public void validateInner(ValidationConfig validationConfig) {
int diffS = sStats.getMax() - sStats.getMin() - 1;

String widthError = "Part must not be wider than %d hexes!".formatted(hexGrid.getMaxWidth());
List<String> coords = new ArrayList<>();

if (diffQ > hexGrid.getMaxWidth()) {
errors.add(new ValidationError(getValidableClass(), "qCoord", diffQ, widthError));
coords.add("qCoord");
}
if (diffR > hexGrid.getMaxWidth()) {
errors.add(new ValidationError(getValidableClass(), "rCoord", diffR, widthError));
coords.add("rCoord");
}
if (diffS > hexGrid.getMaxWidth()) {
errors.add(new ValidationError(getValidableClass(), "sCoord", diffS, widthError));
coords.add("sCoord");
}

if (!coords.isEmpty()) {
errors.add(new ValidationError(getValidableClass(), "hexes", coords, widthError));
}

// no hexes can be on the same position
Expand Down

0 comments on commit aa485ff

Please sign in to comment.