Skip to content

Commit

Permalink
GameState#getPlayer -> GameState#getPlayerState
Browse files Browse the repository at this point in the history
  • Loading branch information
Sothatsit committed May 30, 2024
1 parent b47f85d commit a381d6e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/main/java/net/royalur/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,13 @@ public void addStates(Iterable<GameState> states) {
seen += 1;
if (state == null)
throw new IllegalArgumentException("The states list should not contain any null entries");

addState(state);

if (state instanceof ControlGameState && getLastControlState() != null) {
throw new IllegalArgumentException(
"Only a single control game state per game is currently supported"
);
}

addState(state);
}
if (seen == 0)
throw new IllegalArgumentException("There were no states to add");
Expand Down Expand Up @@ -507,7 +506,7 @@ public PlayerState getDarkPlayer() {
* @return The state of the player {@code player}.
*/
public PlayerState getPlayer(PlayerType player) {
return getState().getPlayer(player);
return getState().getPlayerState(player);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/royalur/rules/state/EndGameState.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ public PlayerType getLoser() {
* @return The state of the player that won the game.
*/
public PlayerState getWinningPlayer() {
return getPlayer(getWinner());
return getPlayerState(getWinner());
}

/**
* Gets the state of the player that lost the game.
* @return The state of the player that lost the game.
*/
public PlayerState getLosingPlayer() {
return getPlayer(getLoser());
return getPlayerState(getLoser());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/royalur/rules/state/GameState.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public PlayerState getDarkPlayer() {
* @param player The player to retrieve the state of.
* @return The state of the player {@code player}.
*/
public PlayerState getPlayer(PlayerType player) {
public PlayerState getPlayerState(PlayerType player) {
return switch (player) {
case LIGHT -> getLightPlayer();
case DARK -> getDarkPlayer();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/royalur/rules/state/OngoingGameState.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public PlayerType getWaiting() {
* @return The state of the player that we are waiting on to interact with the game.
*/
public PlayerState getTurnPlayer() {
return getPlayer(getTurn());
return getPlayerState(getTurn());
}

/**
Expand All @@ -69,6 +69,6 @@ public PlayerState getTurnPlayer() {
* with the game.
*/
public PlayerState getWaitingPlayer() {
return getPlayer(getWaiting());
return getPlayerState(getWaiting());
}
}

0 comments on commit a381d6e

Please sign in to comment.