From bed593ac569b9d7e95ce82bc6577fb8479f79a79 Mon Sep 17 00:00:00 2001 From: Jun Song <40209659+Acewvrs@users.noreply.github.com> Date: Fri, 14 Apr 2023 16:18:55 -0400 Subject: [PATCH] Fixed Nurikabe Rules Printing Duplicate Error Messages (#526) * set test points to make sure the STT files are loaded in correctly * testing transitions * added a test case, BlockInVerticalPath for LightUp that tests there isn't a contradiction if there is a block between two bulbs. * added a test case, CannontFillMiddle for LightUp that tests CannotLightACell Contradiction Rule * removed unnecessary indent * Added unit tests tor CannotLightACellContradictionRuleTest and TooFewBulbsContradictionRuleTest. * Added test LightUp files for testing * removed an unnecessary comment and spacing * Added another set of tests for TooManyBulbsContradictionRule * Added Randomly Generated 7x7 lightup puzzles * prevented the same error message from being created numerous times when checking for direct rules. --- .../java/edu/rpi/legup/puzzle/nurikabe/NurikabeBoard.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeBoard.java b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeBoard.java index d812d0d93..d5b83d1e8 100644 --- a/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeBoard.java +++ b/src/main/java/edu/rpi/legup/puzzle/nurikabe/NurikabeBoard.java @@ -15,6 +15,10 @@ public NurikabeBoard(int size) { @Override public NurikabeCell getCell(int x, int y) { + if (y * dimension.width + x >= puzzleElements.size() || x >= dimension.width || + y >= dimension.height || x < 0 || y < 0) { + return null; + } return (NurikabeCell) super.getCell(x, y); }