Skip to content

Commit

Permalink
Add Regions to StarBattleBoard
Browse files Browse the repository at this point in the history
  • Loading branch information
summerhenson committed Mar 12, 2024
1 parent 7f2406c commit 555890a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
24 changes: 24 additions & 0 deletions src/main/java/edu/rpi/legup/puzzle/starbattle/StarBattleBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
public class StarBattleBoard extends GridBoard {

private int size;
protected List<StarBattleRegion> regions;
//private ArrayList<Integer> groupSizes;

public StarBattleBoard(int size) {
super(size, size);
this.size = size;
this.regions = new ArrayList<>();
}

@Override
Expand Down Expand Up @@ -44,6 +46,28 @@ public Set<StarBattleCell> getCol(int colNum) {
}
return column;
}

public StarBattleRegion getRegion(int index) {
if (index >= size) {
return null;
}
return regions.get(index);
}

public StarBattleBoard copy() {
StarBattleBoard copy = new StarBattleBoard(size);
for (int x = 0; x < this.dimension.width; x++) {
for (int y = 0; y < this.dimension.height; y++) {
copy.setCell(x, y, getCell(x, y).copy());
}
if (x < this.regions.size())
copy.regions.add(this.getRegion(x).copy());
}
for (PuzzleElement e : modifiedData) {
copy.getPuzzleElement(e).setModifiable(false);
}
return copy;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ public class StarBattleRegion extends GridRegion<StarBattleCell>{
public StarBattleRegion() {
super();
}

public StarBattleRegion copy() {
StarBattleRegion copy = new StarBattleRegion();
for (StarBattleCell c: regionCells) {
copy.addCell(c.copy());
}
return copy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import edu.rpi.legup.model.rules.DirectRule;
import edu.rpi.legup.model.tree.TreeNode;
import edu.rpi.legup.model.tree.TreeTransition;
import edu.rpi.legup.puzzle.nurikabe.NurikabeBoard;
import edu.rpi.legup.puzzle.nurikabe.NurikabeType;
import edu.rpi.legup.puzzle.nurikabe.rules.NoNumberContradictionRule;
import edu.rpi.legup.puzzle.starbattle.StarBattleBoard;
import edu.rpi.legup.puzzle.starbattle.StarBattleCell;
import edu.rpi.legup.puzzle.starbattle.StarBattleCellType;
Expand Down

0 comments on commit 555890a

Please sign in to comment.