-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Mw3y/step-2
Step 2
- Loading branch information
Showing
25 changed files
with
1,803 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Qodana | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- step-1 | ||
|
||
jobs: | ||
qodana: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: 'Qodana Scan' | ||
uses: JetBrains/[email protected] | ||
env: | ||
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#-------------------------------------------------------------------------------# | ||
# Qodana analysis is configured by qodana.yaml file # | ||
# https://www.jetbrains.com/help/qodana/qodana-yaml.html # | ||
#-------------------------------------------------------------------------------# | ||
version: "1.0" | ||
|
||
#Specify inspection profile for code analysis | ||
profile: | ||
name: qodana.starter | ||
|
||
#Enable inspections | ||
#include: | ||
# - name: <SomeEnabledInspectionId> | ||
|
||
#Disable inspections | ||
#exclude: | ||
# - name: <SomeDisabledInspectionId> | ||
# paths: | ||
# - <path/where/not/run/inspection> | ||
|
||
projectJDK: 21 #(Applied in CI/CD pipeline) | ||
|
||
#Execute shell command before Qodana execution (Applied in CI/CD pipeline) | ||
#bootstrap: sh ./prepare-qodana.sh | ||
|
||
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline) | ||
#plugins: | ||
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com) | ||
|
||
#Specify Qodana linter for analysis (Applied in CI/CD pipeline) | ||
linter: jetbrains/qodana-jvm:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ch.epfl.chacun; | ||
|
||
/** | ||
* Represents an animal. | ||
* | ||
* @param id the id of the animal | ||
* @param kind the kind of the animal | ||
* @author Maxence Espagnet (sciper: 372808) | ||
* @author Balthazar Baillat (sciper: 373420) | ||
*/ | ||
public record Animal(int id, Kind kind) { | ||
|
||
/** | ||
* Returns the id of the tile on which the animal is located. | ||
* | ||
* @return the id of the tile on which the animal is located | ||
*/ | ||
public int tileId() { | ||
// id = 10 * zoneId + animalNumber | ||
return Zone.tileId(id / 10); | ||
} | ||
|
||
/** | ||
* Represents the different kinds of animals. | ||
*/ | ||
public enum Kind { | ||
MAMMOTH, | ||
AUROCHS, | ||
DEER, | ||
TIGER | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ch.epfl.chacun; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Represents the different possible directions of a tile. | ||
* | ||
* @author Maxence Espagnet (sciper: 372808) | ||
* @author Balthazar Baillat (sciper: 373420) | ||
*/ | ||
public enum Direction { | ||
N, | ||
E, | ||
S, | ||
W; | ||
|
||
// All the values of Direction. | ||
public static final List<Direction> ALL = List.of(Direction.values()); | ||
|
||
// The number of elements of Direction. | ||
public static final int COUNT = ALL.size(); | ||
|
||
/** | ||
* Returns the direction after applying the given rotation. | ||
* | ||
* @param rotation the rotation to apply | ||
* @return the direction after applying the rotation | ||
*/ | ||
public Direction rotated(Rotation rotation) { | ||
return ALL.get((this.ordinal() + rotation.ordinal()) % COUNT); | ||
} | ||
|
||
/** | ||
* Returns the opposite of the receiver direction. | ||
* | ||
* @return the opposite of the receiver direction | ||
*/ | ||
public Direction opposite() { | ||
// There is only four directions, so we can just add 2 to the ordinal | ||
return ALL.get((this.ordinal() + 2) % COUNT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package ch.epfl.chacun; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Represents the different possible occupants of a zone. | ||
* | ||
* @param kind the occupant kind | ||
* @param zoneId the id of the zone in which is the occupant is located | ||
* @author Maxence Espagnet (sciper: 372808) | ||
* @author Balthazar Baillat (sciper: 373420) | ||
*/ | ||
public record Occupant(Kind kind, int zoneId) { | ||
|
||
/** | ||
* Checks for the validity of the given kind and zoneId. | ||
* | ||
* @throws NullPointerException if kind is null | ||
* @throws IllegalArgumentException if zoneId is smaller than 0 | ||
*/ | ||
public Occupant { | ||
Objects.requireNonNull(kind); | ||
Preconditions.checkArgument(zoneId >= 0); | ||
} | ||
|
||
/** | ||
* Returns the number of occupants of the given kind owned by a player | ||
* | ||
* @param kind the occupant kind | ||
* @return the number of occupants of the given kind owned by a player | ||
*/ | ||
public static int occupantsCount(Kind kind) { | ||
return switch (kind) { | ||
case PAWN -> 5; | ||
case HUT -> 3; | ||
}; | ||
} | ||
|
||
/** | ||
* Represents the different kinds of occupants. | ||
*/ | ||
public enum Kind { | ||
PAWN, HUT | ||
} | ||
} |
Oops, something went wrong.