Skip to content

Commit

Permalink
Merge branch 'dev' into FinishRoomCaseRuleAttempt
Browse files Browse the repository at this point in the history
  • Loading branch information
charlestian23 authored Apr 2, 2024
2 parents cd4fabe + 9270d0e commit 84b1394
Show file tree
Hide file tree
Showing 116 changed files with 2,694 additions and 118 deletions.
63 changes: 58 additions & 5 deletions .github/workflows/java-autoformat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ name: Java Code Auto Format
on: pull_request

jobs:
format:
if: github.event.pull_request.head.repo.full_name == github.repository
format_dev:
if: |
github.event.pull_request.head.ref == 'dev' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -15,7 +17,6 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 21
distribution: temurin

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -28,7 +29,58 @@ jobs:

- name: Check for modified files
id: git-check
run: echo "modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT
run: echo "modified=$(if [[ -n $(git status -s) ]]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT

- name: Create temporary branch and pull request
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'Bram van Heuveln'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
branch_name="auto-format-code-$(date +%s)"
git checkout -b $branch_name
./gradlew :spotlessApply
git add .
git commit -am "Automated Java code formatting changes"
git push --set-upstream origin $branch_name
gh pr create -B dev -H $branch_name --title 'Automated Java code formatting changes' --body 'This pull request contains automated code formatting changes.' --reviewer ${{ github.actor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Must approve auto-format pull request
if: steps.git-check.outputs.modified == 'true'
run: |
echo "Please review and approve the appropriate auto-format-code pull request."
exit 1
format_pull_request_to_dev:
if: |
github.event.pull_request.base.ref == 'dev' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v1
with:
ref: ${{ github.head_ref }}

- name: Set up JDK 21
uses: actions/setup-java@v1
with:
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build -x test

- name: Run spotless
run: ./gradlew :spotlessApply

- name: Check for modified files
id: git-check
run: echo "modified=$(if [[ -n $(git status -s) ]]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT

- name: Push changes
if: steps.git-check.outputs.modified == 'true'
Expand All @@ -37,4 +89,5 @@ jobs:
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add .
git diff --cached --exit-code || git commit -am "Automated Java code formatting changes" && git push
git commit -am "Automated Java code formatting changes"
git push
108 changes: 55 additions & 53 deletions src/main/java/edu/rpi/legup/model/gameboard/GridRegion.java
Original file line number Diff line number Diff line change
@@ -1,53 +1,55 @@
package edu.rpi.legup.model.gameboard;

import java.util.ArrayList;
import java.util.List;

public abstract class GridRegion<T> {

protected List<T> regionCells;

/**
* Region Constructor
*/
public GridRegion() {
this.regionCells = new ArrayList<>();
}

/**
* Adds the cell to the region
* @param cell cell to be added to the region
*/
public void addCell(T cell) {
regionCells.add(cell);
}

/**
* Removes the cell from the region
* @param cell cell to be remove from the region
*/
public void removeCell(T cell) {
regionCells.remove(cell);
}

/**
* Returns the list of cells in the region
* @return list of cells in region
*/
public List<T> getCells() {
return regionCells;
}

/**
* Returns the number of cells in the region
* @return number of cells in the region
*/
public int getSize(){
return regionCells.size();
}

/*
public void colorRegion(){}
*/

}
package edu.rpi.legup.model.gameboard;

import java.util.ArrayList;
import java.util.List;

public abstract class GridRegion<T> {

protected List<T> regionCells;

/** Region Constructor */
public GridRegion() {
this.regionCells = new ArrayList<>();
}

/**
* Adds the cell to the region
*
* @param cell cell to be added to the region
*/
public void addCell(T cell) {
regionCells.add(cell);
}

/**
* Removes the cell from the region
*
* @param cell cell to be remove from the region
*/
public void removeCell(T cell) {
regionCells.remove(cell);
}

/**
* Returns the list of cells in the region
*
* @return list of cells in region
*/
public List<T> getCells() {
return regionCells;
}

/**
* Returns the number of cells in the region
*
* @return number of cells in the region
*/
public int getSize() {
return regionCells.size();
}

/*
public void colorRegion(){}
*/

}
66 changes: 34 additions & 32 deletions src/test/java/legup/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void main(String[] args) {
Result result2 = JUnitCore.runClasses(FinishWithShipsDirectRuleTests.class);
printTestResults(result2);

// Lightup Tests
// LightUp Tests
Result result3 = JUnitCore.runClasses(BulbsInPathContradictionRuleTest.class);
printTestResults(result3);
Result result4 = JUnitCore.runClasses(CannotLightACellContradictionRuleTest.class);
Expand All @@ -29,68 +29,70 @@ public static void main(String[] args) {
printTestResults(result6);
Result result7 = JUnitCore.runClasses(FinishWithBulbsDirectRuleTest.class);
printTestResults(result7);
Result result8 = JUnitCore.runClasses(LightOrEmptyCaseRuleTest.class);
Result result8 = JUnitCore.runClasses(FinishWithEmptyDirectRuleTest.class);
printTestResults(result8);
Result result9 = JUnitCore.runClasses(MustLightDirectRuleTest.class);
Result result9 = JUnitCore.runClasses(LightOrEmptyCaseRuleTest.class);
printTestResults(result9);
Result result10 = JUnitCore.runClasses(SatisfyNumberCaseRuleTest.class);
Result result10 = JUnitCore.runClasses(MustLightDirectRuleTest.class);
printTestResults(result10);
Result result11 = JUnitCore.runClasses(TooFewBulbsContradictionRuleTest.class);
Result result11 = JUnitCore.runClasses(SatisfyNumberCaseRuleTest.class);
printTestResults(result11);
Result result12 = JUnitCore.runClasses(TooManyBulbsContradictionRuleTest.class);
Result result12 = JUnitCore.runClasses(TooFewBulbsContradictionRuleTest.class);
printTestResults(result12);
Result result13 = JUnitCore.runClasses(TooManyBulbsContradictionRuleTest.class);
printTestResults(result13);

// nurikabe tests
Result result13 = JUnitCore.runClasses(BlackBetweenRegionsDirectRuleTest.class);
printTestResults(result13);
Result result14 = JUnitCore.runClasses(BlackBottleNeckDirectRuleTest.class);
Result result14 = JUnitCore.runClasses(BlackBetweenRegionsDirectRuleTest.class);
printTestResults(result14);
Result result15 = JUnitCore.runClasses(BlackOrWhiteCaseRuleTest.class);
Result result15 = JUnitCore.runClasses(BlackBottleNeckDirectRuleTest.class);
printTestResults(result15);
Result result16 = JUnitCore.runClasses(BlackSquareContradictionRuleTest.class);
Result result16 = JUnitCore.runClasses(BlackOrWhiteCaseRuleTest.class);
printTestResults(result16);
Result result17 = JUnitCore.runClasses(CornerBlackDirectRuleTest.class);
Result result17 = JUnitCore.runClasses(BlackSquareContradictionRuleTest.class);
printTestResults(result17);
Result result18 = JUnitCore.runClasses(FillinBlackDirectRuleTest.class);
Result result18 = JUnitCore.runClasses(CornerBlackDirectRuleTest.class);
printTestResults(result18);
Result result19 = JUnitCore.runClasses(FillinWhiteDirectRuleTest.class);
Result result19 = JUnitCore.runClasses(FillinBlackDirectRuleTest.class);
printTestResults(result19);
Result result20 = JUnitCore.runClasses(IsolateBlackContradictionRuleTest.class);
Result result20 = JUnitCore.runClasses(FillinWhiteDirectRuleTest.class);
printTestResults(result20);
Result result21 = JUnitCore.runClasses(MultipleNumbersContradictionRuleTest.class);
Result result21 = JUnitCore.runClasses(IsolateBlackContradictionRuleTest.class);
printTestResults(result21);
Result result22 = JUnitCore.runClasses(NoNumbersContradictionRuleTest.class);
Result result22 = JUnitCore.runClasses(MultipleNumbersContradictionRuleTest.class);
printTestResults(result22);
Result result23 = JUnitCore.runClasses(PreventBlackSquareDirectRuleTest.class);
Result result23 = JUnitCore.runClasses(NoNumbersContradictionRuleTest.class);
printTestResults(result23);
Result result24 = JUnitCore.runClasses(SurroundRegionDirectRuleTest.class);
Result result24 = JUnitCore.runClasses(PreventBlackSquareDirectRuleTest.class);
printTestResults(result24);
Result result25 = JUnitCore.runClasses(TooFewSpacesContradictionRuleTest.class);
Result result25 = JUnitCore.runClasses(SurroundRegionDirectRuleTest.class);
printTestResults(result25);
Result result26 = JUnitCore.runClasses(TooManySpacesContradictionRuleTest.class);
Result result26 = JUnitCore.runClasses(TooFewSpacesContradictionRuleTest.class);
printTestResults(result26);
Result result27 = JUnitCore.runClasses(WhiteBottleNeckDirectRuleTest.class);
Result result27 = JUnitCore.runClasses(TooManySpacesContradictionRuleTest.class);
printTestResults(result27);
Result result28 = JUnitCore.runClasses(WhiteBottleNeckDirectRuleTest.class);
printTestResults(result28);

// Treetent
Result result28 = JUnitCore.runClasses(EmptyFieldDirectRuleTest.class);
printTestResults(result28);
Result result29 = JUnitCore.runClasses(FinishWithGrassDirectRuleTest.class);
Result result29 = JUnitCore.runClasses(EmptyFieldDirectRuleTest.class);
printTestResults(result29);
Result result30 = JUnitCore.runClasses(FinishWithTentsDirectRuleTest.class);
Result result30 = JUnitCore.runClasses(FinishWithGrassDirectRuleTest.class);
printTestResults(result30);
Result result31 = JUnitCore.runClasses(LastCampingSpotDirectRuleTest.class);
Result result31 = JUnitCore.runClasses(FinishWithTentsDirectRuleTest.class);
printTestResults(result31);
Result result32 = JUnitCore.runClasses(NoTentForTreeContradictionRuleTest.class);
Result result32 = JUnitCore.runClasses(LastCampingSpotDirectRuleTest.class);
printTestResults(result32);
Result result33 = JUnitCore.runClasses(NoTreeForTentContradictionRuleTest.class);
Result result33 = JUnitCore.runClasses(NoTentForTreeContradictionRuleTest.class);
printTestResults(result33);
Result result34 = JUnitCore.runClasses(SurroundTentWithGrassDirectRuleTest.class);
Result result34 = JUnitCore.runClasses(NoTreeForTentContradictionRuleTest.class);
printTestResults(result34);
Result result35 = JUnitCore.runClasses(TreeForTentDirectRuleTest.class);
Result result35 = JUnitCore.runClasses(SurroundTentWithGrassDirectRuleTest.class);
printTestResults(result35);
Result result36 = JUnitCore.runClasses(TentOrGrassCaseRuleTest.class);
Result result36 = JUnitCore.runClasses(TreeForTentDirectRuleTest.class);
printTestResults(result36);
Result result37 = JUnitCore.runClasses(TentOrGrassCaseRuleTest.class);
printTestResults(result37);
}

private static void printTestResults(Result result) {
Expand Down
Loading

0 comments on commit 84b1394

Please sign in to comment.