From d51deaf29ecbfb4e6f8f550e6b31f1bba93377fb Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Wed, 11 Mar 2020 08:02:30 +0100 Subject: [PATCH 1/8] =?UTF-8?q?Fikser=20noen=20sm=C3=A5feil=20i=20makeMove?= =?UTF-8?q?()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/inf112/fiasko/roborally/objects/RoboRallyGame.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java index f56c624..d88dffa 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java +++ b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java @@ -141,14 +141,14 @@ public class RoboRallyGame implements IDrawableGame { sleep(); switch (action) { case MOVE_1: - moveForward(robotID); + gameBoard.moveRobotForward(robotID); break; case MOVE_2: - moveForward(robotID); + gameBoard.moveRobotForward(robotID); moveForward(robotID); break; case MOVE_3: - moveForward(robotID); + gameBoard.moveRobotForward(robotID); moveForward(robotID); moveForward(robotID); break; From 2219ea3dbed7c0cfc611ca866958bd7e02da91e0 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Wed, 11 Mar 2020 08:02:56 +0100 Subject: [PATCH 2/8] Legger til kryonet avhengigheten i pom --- pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pom.xml b/pom.xml index 267c8f9..0ff0081 100644 --- a/pom.xml +++ b/pom.xml @@ -20,6 +20,13 @@ 1.8 + + + clojars + http://clojars.org/repo/ + + + @@ -53,6 +60,12 @@ natives-desktop + + kryonet + kryonet + 2.21 + + junit junit From ea45a0cd93c995322d827a3310ab57f8431bc5ab Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Thu, 12 Mar 2020 11:16:29 +0100 Subject: [PATCH 3/8] Legger til manglende kryo avhengighet --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 0ff0081..b8996ba 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,12 @@ natives-desktop + + com.esotericsoftware + kryo + 5.0.0-RC5 + + kryonet kryonet From bf63d608a7db3a76a7d726cb83a86e03631e350e Mon Sep 17 00:00:00 2001 From: Tobydrama Date: Thu, 12 Mar 2020 11:23:27 +0100 Subject: [PATCH 4/8] Added more test to PlayerTest --- .../fiasko/roborally/objects/PlayerTest.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/test/java/inf112/fiasko/roborally/objects/PlayerTest.java b/src/test/java/inf112/fiasko/roborally/objects/PlayerTest.java index 5e4e00b..90e9cce 100644 --- a/src/test/java/inf112/fiasko/roborally/objects/PlayerTest.java +++ b/src/test/java/inf112/fiasko/roborally/objects/PlayerTest.java @@ -40,4 +40,70 @@ public class PlayerTest { playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1)); assertEquals(Action.MOVE_1,playerTest.getProgram().get(0).getAction()); } + @Test + public void addMultipuleCards(){ + playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1)); + playerTest.setCardInProgram(new ProgrammingCard(30,Action.MOVE_2)); + playerTest.setCardInProgram(new ProgrammingCard(23452342,Action.MOVE_3)); + 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()); + } + @Test(expected = IllegalArgumentException.class) + public void addTooManyCardsGetsAError() { + playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1)); + playerTest.setCardInProgram(new ProgrammingCard(30,Action.MOVE_2)); + playerTest.setCardInProgram(new ProgrammingCard(234523423,Action.MOVE_3)); + playerTest.setCardInProgram(new ProgrammingCard(2342342,Action.MOVE_3)); + playerTest.setCardInProgram(new ProgrammingCard(23432342,Action.MOVE_3)); + playerTest.setCardInProgram(new ProgrammingCard(234523242,Action.MOVE_3)); + } + @Test + public void removeCardsFromPlayerProgram() { + playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1)); + playerTest.setCardInProgram(new ProgrammingCard(30,Action.MOVE_2)); + playerTest.setCardInProgram(new ProgrammingCard(234523423,Action.MOVE_3)); + playerTest.setCardInProgram(new ProgrammingCard(2342342,Action.MOVE_3)); + playerTest.setCardInProgram(new ProgrammingCard(23432342,Action.MOVE_3)); + assertEquals(Action.MOVE_3,playerTest.getProgram().get(4).getAction()); + playerTest.removeProgramCard(4); + assertEquals(null,playerTest.getProgram().get(4)); + } + @Test + public void removeAllCardsFromPlayerProgram() { + playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1)); + playerTest.setCardInProgram(new ProgrammingCard(30,Action.MOVE_2)); + playerTest.setCardInProgram(new ProgrammingCard(234523423,Action.MOVE_3)); + playerTest.setCardInProgram(new ProgrammingCard(2342342,Action.MOVE_3)); + playerTest.setCardInProgram(new ProgrammingCard(23432342,Action.MOVE_3)); + assertEquals(Action.MOVE_3,playerTest.getProgram().get(4).getAction()); + assertEquals(Action.MOVE_3,playerTest.getProgram().get(3).getAction()); + assertEquals(Action.MOVE_3,playerTest.getProgram().get(2).getAction()); + assertEquals(Action.MOVE_2,playerTest.getProgram().get(1).getAction()); + assertEquals(Action.MOVE_1,playerTest.getProgram().get(0).getAction()); + playerTest.removeProgramCard(4); + playerTest.removeProgramCard(3); + playerTest.removeProgramCard(2); + playerTest.removeProgramCard(1); + playerTest.removeProgramCard(0); + assertEquals(null,playerTest.getProgram().get(4)); + assertEquals(null,playerTest.getProgram().get(3)); + assertEquals(null,playerTest.getProgram().get(2)); + assertEquals(null,playerTest.getProgram().get(1)); + assertEquals(null,playerTest.getProgram().get(0)); + } + + @Test(expected = IllegalArgumentException.class) + public void getErrorIfYouRemoveMoreThenIndexFive(){ + playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1)); + playerTest.removeProgramCard(5); + + } + @Test(expected = IllegalArgumentException.class) + public void getErrorIfYouRemoveANegativIndex(){ + playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1)); + playerTest.removeProgramCard(-1); + + } + } From 9c5a50d74a71a57f3001df002053d70c945554d0 Mon Sep 17 00:00:00 2001 From: Tobydrama Date: Thu, 12 Mar 2020 11:24:04 +0100 Subject: [PATCH 5/8] Added more comments to deck --- .../inf112/fiasko/roborally/objects/Deck.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/main/java/inf112/fiasko/roborally/objects/Deck.java b/src/main/java/inf112/fiasko/roborally/objects/Deck.java index 9988b04..4d0b8dc 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Deck.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Deck.java @@ -18,6 +18,9 @@ public abstract class Deck implements IDeck { this.cardList = new ArrayList<>(cardList); } + /** + * Randomises the order of the deck + */ @Override public void shuffle() { Random randomGenerator = new Random(); @@ -31,12 +34,21 @@ public abstract class Deck implements IDeck { } } + /** + * Draws one card from the other deck + * @param other The deck to draw the card from + */ @Override public void draw(IDeck other) { Deck otherDeck = (Deck) other; cardList.add(otherDeck.cardList.remove(0)); } + /** + * Draws multiple cards from the other deck + * @param other The other deck to draw from + * @param n The number of cards to draw + */ @Override public void draw(IDeck other, int n) { Deck otherDeck = (Deck) other; @@ -48,27 +60,47 @@ public abstract class Deck implements IDeck { } } + /** + * Empty the entire deck into the other deck + * @param other The deck to move this deck's cards into + */ @Override public void emptyInto(IDeck other) { Deck otherDeck = (Deck) other; otherDeck.draw(this, this.size()); } + /** + * Checks if the deck is empty + * @return Boolean for if the deck is empty + */ @Override public boolean isEmpty() { return cardList.isEmpty(); } + /** + * Gets the size of the deck + * @return int size of the deck + */ @Override public int size() { return cardList.size(); } + /** + * Gets a list of all the cards in the deck + * @return ArrayList of cards from the deck + */ @Override public List getCards() { return new ArrayList<>(cardList); } + /** + * Gets the card from the deck in String format + * @return String the cards from the deck + */ @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -78,11 +110,19 @@ public abstract class Deck implements IDeck { return builder.toString(); } + /** + * Looks at the top card in the deck + * @return ProgrammingCard the first card in the deck + */ @Override public T peekTop() { return cardList.get(0); } + /** + * Looks at the bottom card of the deck + * @return ProgrammingCard the last card in the deck + */ @Override public T peekBottom() { return cardList.get(size()-1); From 4f9d58152c4611928acbdd25c0e34af433b9bf72 Mon Sep 17 00:00:00 2001 From: Tobydrama Date: Thu, 12 Mar 2020 11:24:20 +0100 Subject: [PATCH 6/8] Added comments to Player --- .../fiasko/roborally/objects/Player.java | 60 ++++++++++++++++--- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/src/main/java/inf112/fiasko/roborally/objects/Player.java b/src/main/java/inf112/fiasko/roborally/objects/Player.java index 7e28586..75908b3 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Player.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Player.java @@ -5,6 +5,10 @@ import inf112.fiasko.roborally.element_properties.RobotID; import java.util.ArrayList; import java.util.List; +/** + * This Class represents a player + */ + public class Player { private final RobotID robotID; private final String name; @@ -12,11 +16,21 @@ public class Player { private ProgrammingCardDeck playerDeck; private List program = new ArrayList(); - // Constructor for the player class, it get assigned a Robot, a player nam and a deck + /** + * Instantiates a new player + * @param robotID the global identifier of the robot + * @param name the unique name of the player + * @param playerDeck the hand of cards dealt to the player + */ public Player(RobotID robotID, String name, ProgrammingCardDeck playerDeck) { this.robotID = robotID; this.name = name; this.playerDeck = playerDeck; + program.add(0, null); //sets the initial values in program to null + program.add(1, null); + program.add(2, null); + program.add(3, null); + program.add(4, null); } /** @@ -25,22 +39,42 @@ public class Player { */ public RobotID getRobotID(){return robotID;} + /** + * Gives you the Name of the player + * @return a player Name + */ public String getName() {return name;} + /** + * Gives you the players program + * @return a list + */ public List getProgram() {return program;} + /** + * Gives you the player hand/deck + * @return a deck + */ public ProgrammingCardDeck getPlayerDeck() {return playerDeck;} + /** + * Gives you the players powerdown status + * @return a boolean + */ public boolean getPowerDownNextRound() { return powerDownNextRound;} + /** + * Sets the prowerdown status + * @param powerDownStatus the boolean that determines if it goes to a powerdown or not + */ public void setPowerDownNextRound(boolean powerDownStatus) { this.powerDownNextRound = powerDownStatus;} + /** + * Places a card in to the player program + * @param card the card that is placed in to the player program + */ public void setCardInProgram(ProgrammingCard card) { for (int i = 0; i < 5; i++) { - if (program.size() == 0) { - program.add(i, card); - return; - } if (program.get(i) == null) { program.add(i, card); return; @@ -49,10 +83,20 @@ public class Player { throw new IllegalArgumentException("Program deck is full,tried to add to many cards"); } - + /** + * Removes a card by the given index from the player program and returns it. + * @param cardNr the index of the card that is being removed + * @return the card that was removed from the program + */ public ProgrammingCard removeProgramCard(int cardNr) { - program.add(cardNr, null); - return program.remove(cardNr+1); + if(cardNr<5 && cardNr>-1) { + program.add(cardNr, null); + return program.remove(cardNr + 1); + } + else{ + throw new IllegalArgumentException("cant remove more then index 4 or remove negatives"); + + } } } From 9ebd5e3af039128eb2681a911ab37864a8402ec2 Mon Sep 17 00:00:00 2001 From: torlunjen Date: Thu, 12 Mar 2020 11:49:14 +0100 Subject: [PATCH 7/8] Adds method to rotate robots standing cogwheels --- .../fiasko/roborally/objects/Board.java | 4 +-- .../roborally/objects/RoboRallyGame.java | 27 ++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/inf112/fiasko/roborally/objects/Board.java b/src/main/java/inf112/fiasko/roborally/objects/Board.java index 3414d49..5ab22dc 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Board.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Board.java @@ -251,7 +251,7 @@ public class Board { * @param position The position to check * @return The robot id of the robot on the position or null if there is no robot there */ - private RobotID getRobotOnPosition(Position position) { + RobotID getRobotOnPosition(Position position) { for (RobotID robotID : robots.keySet()) { Robot robot = robots.get(robotID); if (position.equals(robot.getPosition())) { @@ -266,7 +266,7 @@ public class Board { * @param position The position to check * @return True if there is a robot on the specified position */ - private boolean hasRobotOnPosition(Position position) { + boolean hasRobotOnPosition(Position position) { return getRobotOnPosition(position) != null; } diff --git a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java index f56c624..3024908 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java +++ b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java @@ -3,6 +3,7 @@ package inf112.fiasko.roborally.objects; import inf112.fiasko.roborally.element_properties.Action; import inf112.fiasko.roborally.element_properties.Position; import inf112.fiasko.roborally.element_properties.RobotID; +import inf112.fiasko.roborally.element_properties.TileType; import inf112.fiasko.roborally.utility.BoardLoaderUtil; import java.io.IOException; @@ -182,4 +183,28 @@ public class RoboRallyGame implements IDrawableGame { sleep(); gameBoard.moveRobotForward(robotID); } -} + + /** + * Rotates all robots that are standing on cogWheel tiles on the board. + * @throws InterruptedException If interrupted while sleeping. + */ + private void rotateCogwheels() throws InterruptedException { + List> cogWheelsLeft = gameBoard.getPositionsOfTileOnBoard(TileType.COGWHEEL_LEFT); + List> cogWheelsRight = gameBoard.getPositionsOfTileOnBoard(TileType.COGWHEEL_RIGHT); + + for (BoardElementContainer cogLeft : cogWheelsLeft) { + if (!gameBoard.hasRobotOnPosition(cogLeft.getPosition())) { + return; + } + sleep(); + makeMove(gameBoard.getRobotOnPosition(cogLeft.getPosition()), Action.ROTATE_LEFT); + } + for (BoardElementContainer cogRight : cogWheelsRight) { + if (!gameBoard.hasRobotOnPosition(cogRight.getPosition())) { + return; + } + sleep(); + makeMove(gameBoard.getRobotOnPosition(cogRight.getPosition()), Action.ROTATE_RIGHT); + } + } +} \ No newline at end of file From f3fa78c107a78d4dc73301fc0c0bf600476c0519 Mon Sep 17 00:00:00 2001 From: torlunjen Date: Thu, 12 Mar 2020 12:01:01 +0100 Subject: [PATCH 8/8] =?UTF-8?q?Legger=20til=20referat=20fra=20parprogramme?= =?UTF-8?q?rings=C3=B8kt/m=C3=B8te?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/team/referater/referat_12_03_2020.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/team/referater/referat_12_03_2020.md diff --git a/docs/team/referater/referat_12_03_2020.md b/docs/team/referater/referat_12_03_2020.md new file mode 100644 index 0000000..eae6cdd --- /dev/null +++ b/docs/team/referater/referat_12_03_2020.md @@ -0,0 +1,5 @@ +## Oppmøte +Alle i teamet var tilstede. + +## Gjennomgått +Vi har jobbet med parprogrammering. \ No newline at end of file