mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Forbedrer kommentarer og metodenavn
This commit is contained in:
parent
03c7e95e01
commit
d8acbc661d
@ -23,9 +23,10 @@ public class GameStartInfo {
|
||||
*
|
||||
* @param boardName The name of the board to be used, with extension
|
||||
* @param playerList List of players for the game
|
||||
* @param playerName The player name of the receiver
|
||||
*/
|
||||
public GameStartInfo(String boardName, List<Player> playerList, String name) {
|
||||
this.playerName = name;
|
||||
public GameStartInfo(String boardName, List<Player> playerList, String playerName) {
|
||||
this.playerName = playerName;
|
||||
this.boardName = boardName;
|
||||
this.playerList = playerList;
|
||||
}
|
||||
|
@ -161,16 +161,16 @@ public class Board {
|
||||
* Sets the power down status of the robot
|
||||
*
|
||||
* @param robotID The robot id of the robot
|
||||
* @param powerdown The status of the powerdown
|
||||
* @param powerDown The status of the power down
|
||||
*/
|
||||
public void setPowerDown(RobotID robotID, Boolean powerdown) {
|
||||
robots.get(robotID).setPowerDown(powerdown);
|
||||
public void setPowerDown(RobotID robotID, Boolean powerDown) {
|
||||
robots.get(robotID).setPowerDown(powerDown);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power down status of the robot
|
||||
*
|
||||
* @param robotID The robot id of the robot
|
||||
* @return The power down status of the robot
|
||||
*/
|
||||
public boolean getPowerDown(RobotID robotID) {
|
||||
return robots.get(robotID).isInPowerDown();
|
||||
@ -190,7 +190,7 @@ public class Board {
|
||||
/**
|
||||
* sets the damage taken of robots in powerdown to 0
|
||||
*/
|
||||
public void executePowerdown() {
|
||||
public void executePowerDown() {
|
||||
for (Robot robot : robots.values()) {
|
||||
if (robot.isInPowerDown()) {
|
||||
robot.setDamageTaken(0);
|
||||
@ -826,7 +826,7 @@ public class Board {
|
||||
* @return If the robot has touched a flag this turn
|
||||
*/
|
||||
public boolean isHasTouchedFlagThisTurnFromRobotID(RobotID robotID) {
|
||||
return robots.get(robotID).isHasTouchedFlagThisTurn();
|
||||
return robots.get(robotID).hasTouchedFlagThisTurn();
|
||||
}
|
||||
|
||||
}
|
@ -81,4 +81,11 @@ public interface InteractableGame {
|
||||
*/
|
||||
void setProgram(List<ProgrammingCard> program);
|
||||
|
||||
/**
|
||||
* Sets the name of the player that won the game
|
||||
*
|
||||
* @param winningPlayerName The player winning the game
|
||||
*/
|
||||
void setWinningPlayerName(String winningPlayerName);
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class Phase {
|
||||
private List<BoardElementContainer<Tile>> conveyorBelts;
|
||||
private List<BoardElementContainer<Tile>> fastConveyorBelts;
|
||||
private List<BoardElementContainer<Tile>> flags;
|
||||
private RoboRallyGame game;
|
||||
private InteractableGame game;
|
||||
|
||||
/**
|
||||
* Instantiates a new phase
|
||||
@ -35,7 +35,7 @@ public class Phase {
|
||||
* @param cycleDelay The amount of milliseconds to wait between moves
|
||||
* @param game The game which uses this object
|
||||
*/
|
||||
public Phase(Board gameBoard, List<Player> playerList, int cycleDelay, RoboRallyGame game) {
|
||||
public Phase(Board gameBoard, List<Player> playerList, int cycleDelay, InteractableGame game) {
|
||||
this.gameBoard = gameBoard;
|
||||
this.playerList = playerList;
|
||||
this.cycleDelay = cycleDelay;
|
||||
@ -80,6 +80,7 @@ public class Phase {
|
||||
|
||||
/**
|
||||
* Fires all lasers on the game board
|
||||
* @throws InterruptedException If it gets interrupted while trying to sleep
|
||||
*/
|
||||
public void fireAllLasers() throws InterruptedException {
|
||||
gameBoard.fireAllLasers();
|
||||
|
@ -44,15 +44,6 @@ public class Player {
|
||||
return robotID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the robot id of the robot
|
||||
*
|
||||
* @param robotID The new id of the robot
|
||||
*/
|
||||
public void setRobotID(RobotID robotID) {
|
||||
this.robotID = robotID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives you the Name of the player
|
||||
*
|
||||
@ -85,7 +76,7 @@ public class Player {
|
||||
*
|
||||
* @return a deck
|
||||
*/
|
||||
public ProgrammingCardDeck getPlayerDeck() {
|
||||
public ProgrammingCardDeck getProgrammingCardDeck() {
|
||||
return playerDeck;
|
||||
}
|
||||
|
||||
@ -94,7 +85,7 @@ public class Player {
|
||||
*
|
||||
* @param playerDeck A deck of cards given to the player
|
||||
*/
|
||||
public void setPlayerDeck(ProgrammingCardDeck playerDeck) {
|
||||
public void setProgrammingCardDeck(ProgrammingCardDeck playerDeck) {
|
||||
this.playerDeck = playerDeck;
|
||||
}
|
||||
|
||||
@ -103,19 +94,10 @@ public class Player {
|
||||
*
|
||||
* @return a deck with locked cards
|
||||
*/
|
||||
public ProgrammingCardDeck getLockedPlayerDeck() {
|
||||
public ProgrammingCardDeck getLockedProgrammingCardDeck() {
|
||||
return lockedPlayerDeck;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the players locked deck to the given deck
|
||||
*
|
||||
* @param lockedPlayerDeck A deck of locked cards kept by the player
|
||||
*/
|
||||
public void setLockedPlayerDeck(ProgrammingCardDeck lockedPlayerDeck) {
|
||||
this.lockedPlayerDeck = lockedPlayerDeck;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives you the players power down status
|
||||
*
|
||||
@ -139,9 +121,9 @@ public class Player {
|
||||
*
|
||||
* @param cardList list the size of 5 with programing cards
|
||||
*/
|
||||
public void setInProgram(List<ProgrammingCard> cardList) {
|
||||
public void setProgram(List<ProgrammingCard> cardList) {
|
||||
if (cardList.size() != 5) {
|
||||
throw new IllegalArgumentException("list must contain 5 programing cards");
|
||||
throw new IllegalArgumentException("The program must contain exactly 5 cards.");
|
||||
} else {
|
||||
program = new ArrayList<>(cardList);
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
|
||||
String playerName;
|
||||
for (Player player : playerList) {
|
||||
playerName = player.getName();
|
||||
player.setInProgram(programMap.get(playerName));
|
||||
player.setProgram(programMap.get(playerName));
|
||||
player.setPowerDownNextRound(powerDown.get(playerName));
|
||||
}
|
||||
//Runs 5 phases
|
||||
@ -185,21 +185,13 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
|
||||
resetHasTouchedFlagThisTurnForAllRobots();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the player that won the game
|
||||
*
|
||||
* @return The name of the winning player
|
||||
*/
|
||||
@Override
|
||||
public String getWinningPlayerName() {
|
||||
return winningPlayerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the player that won the game
|
||||
*
|
||||
* @param winningPlayerName The player winning the game
|
||||
*/
|
||||
protected void setWinningPlayerName(String winningPlayerName) {
|
||||
@Override
|
||||
public void setWinningPlayerName(String winningPlayerName) {
|
||||
this.winningPlayerName = winningPlayerName;
|
||||
}
|
||||
|
||||
@ -275,15 +267,15 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
|
||||
// Resets players power down for next turn to false.
|
||||
updateRobotPowerDown();
|
||||
// Set damage of robots in power down to 0
|
||||
gameBoard.executePowerdown();
|
||||
gameBoard.executePowerDown();
|
||||
if (host) {
|
||||
//Distributes programming cards for all players, and sends a deck to each player
|
||||
distributeProgrammingCardsToPlayers();
|
||||
for (Connection connection : server.getPlayerNames().keySet()) {
|
||||
String playerName = server.getPlayerNames().get(connection);
|
||||
Player player = getPlayerFromName(playerName);
|
||||
if (player != null && player.getPlayerDeck() != null) {
|
||||
server.sendToClient(connection, player.getPlayerDeck());
|
||||
if (player != null && player.getProgrammingCardDeck() != null) {
|
||||
server.sendToClient(connection, player.getProgrammingCardDeck());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -314,8 +306,8 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
|
||||
private void updateLockedProgrammingCardsForAllPlayers() {
|
||||
for (Player player : playerList) {
|
||||
List<ProgrammingCard> playerProgram = player.getProgram();
|
||||
ProgrammingCardDeck playerDeck = player.getPlayerDeck();
|
||||
ProgrammingCardDeck lockedPlayerDeck = player.getLockedPlayerDeck();
|
||||
ProgrammingCardDeck playerDeck = player.getProgrammingCardDeck();
|
||||
ProgrammingCardDeck lockedPlayerDeck = player.getLockedProgrammingCardDeck();
|
||||
int robotDamage;
|
||||
if (!gameBoard.isRobotAlive(player.getRobotID())) {
|
||||
robotDamage = 0;
|
||||
@ -325,7 +317,7 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
|
||||
|
||||
//The player has no locked cards. All previously locked cards should go into the free deck
|
||||
if (robotDamage <= 4) {
|
||||
lockedPlayerDeck.emptyInto(player.getPlayerDeck());
|
||||
lockedPlayerDeck.emptyInto(player.getProgrammingCardDeck());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -364,7 +356,7 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
|
||||
*/
|
||||
private void removeNonLockedProgrammingCardsFromPlayers() {
|
||||
for (Player player : playerList) {
|
||||
player.getPlayerDeck().emptyInto(mainDeck);
|
||||
player.getProgrammingCardDeck().emptyInto(mainDeck);
|
||||
}
|
||||
}
|
||||
|
||||
@ -375,7 +367,7 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
|
||||
mainDeck.shuffle();
|
||||
for (Player player : playerList) {
|
||||
RobotID robot = player.getRobotID();
|
||||
ProgrammingCardDeck playerDeck = player.getPlayerDeck();
|
||||
ProgrammingCardDeck playerDeck = player.getProgrammingCardDeck();
|
||||
int robotDamage = gameBoard.getRobotDamage(robot);
|
||||
//Powered down or heavily damaged robots don't get any cards
|
||||
if (gameBoard.getPowerDown(robot) || robotDamage >= 9) {
|
||||
|
@ -36,7 +36,7 @@ public class Robot {
|
||||
*
|
||||
* @return a boolean
|
||||
*/
|
||||
public boolean isHasTouchedFlagThisTurn() {
|
||||
public boolean hasTouchedFlagThisTurn() {
|
||||
return hasTouchedFlagThisTurn;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class BoardTest {
|
||||
boardforpowerdown.setPowerDown(RobotID.ROBOT_2, true);
|
||||
testrobot.setDamageTaken(4);
|
||||
assertEquals(4, testrobot.getDamageTaken());
|
||||
boardforpowerdown.executePowerdown();
|
||||
boardforpowerdown.executePowerDown();
|
||||
assertEquals(0, testrobot.getDamageTaken());
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class PlayerTest {
|
||||
|
||||
@Test
|
||||
public void testSetInProgram() {
|
||||
playerTest.setInProgram(cards);
|
||||
playerTest.setProgram(cards);
|
||||
assertEquals(Action.MOVE_1, playerTest.getProgram().get(0).getAction());
|
||||
assertEquals(Action.MOVE_2, playerTest.getProgram().get(1).getAction());
|
||||
assertEquals(Action.MOVE_3, playerTest.getProgram().get(2).getAction());
|
||||
@ -51,15 +51,15 @@ public class PlayerTest {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSetInProgramWithToManyCards() {
|
||||
cards.add(new ProgrammingCard(10, Action.ROTATE_LEFT));
|
||||
playerTest.setInProgram(cards);
|
||||
playerTest.setProgram(cards);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetInDeck() {
|
||||
cards.add(new ProgrammingCard(10, Action.ROTATE_LEFT));
|
||||
ProgrammingCardDeck playerDeck = new ProgrammingCardDeck(cards);
|
||||
playerTest.setPlayerDeck(playerDeck);
|
||||
assertEquals(playerDeck, playerTest.getPlayerDeck());
|
||||
playerTest.setProgrammingCardDeck(playerDeck);
|
||||
assertEquals(playerDeck, playerTest.getProgrammingCardDeck());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -74,7 +74,7 @@ public class PlayerTest {
|
||||
|
||||
@Test
|
||||
public void getProgramFromPlayer() {
|
||||
playerTest.setInProgram(cards);
|
||||
playerTest.setProgram(cards);
|
||||
assertEquals(cards, playerTest.getProgram());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user