diff --git a/docs/team/referater/referat_24_03_2020.md b/docs/team/referater/referat_24_03_2020.md new file mode 100644 index 0000000..7d186ad --- /dev/null +++ b/docs/team/referater/referat_24_03_2020.md @@ -0,0 +1,11 @@ +## Oppmøte +Tilstede: Steinar, Gabriel, Kristian, Torbjørn, Petter +Ikke tilstede: + +## Agenda +- Oppmøte + +- Jobbe videre med oppgavene. + +## Møte +Forteller hva som er forventet å bli gjort iløp av dagen og setter i gang med arbeidet. \ No newline at end of file diff --git a/src/main/java/inf112/fiasko/roborally/game_wrapper/SimpleButton.java b/src/main/java/inf112/fiasko/roborally/game_wrapper/SimpleButton.java new file mode 100644 index 0000000..e697353 --- /dev/null +++ b/src/main/java/inf112/fiasko/roborally/game_wrapper/SimpleButton.java @@ -0,0 +1,37 @@ +package inf112.fiasko.roborally.game_wrapper; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; + +/** + * This class generates a simple text button using a default skin + */ +public class SimpleButton { + private TextButton button; + + /** + * Instantiates a new simple button + * @param text The text to display on the button + * @param font The font to use to draw button text + */ + public SimpleButton(String text, BitmapFont font) { + TextureAtlas buttonAtlas = new TextureAtlas(Gdx.files.internal("uiskin.atlas")); + Skin skin = new Skin(buttonAtlas); + TextButton.TextButtonStyle confirmCardsStyle = new TextButton.TextButtonStyle(); + confirmCardsStyle.font = font; + confirmCardsStyle.up = skin.getDrawable("default-round"); + confirmCardsStyle.down = skin.getDrawable("default-round-down"); + this.button = new TextButton(text, confirmCardsStyle); + } + + /** + * Gets the button generated + * @return A button + */ + public TextButton getButton() { + return this.button; + } +} diff --git a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java index f19ce13..d2c05e2 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java +++ b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java @@ -8,8 +8,7 @@ import inf112.fiasko.roborally.element_properties.TileType; import inf112.fiasko.roborally.utility.BoardLoaderUtil; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.function.Predicate; @@ -21,6 +20,7 @@ public class RoboRallyGame implements IDrawableGame { private List> cogwheels; private List> conveyorBelts; private List> fastConveyorBelts; + private List playerList; public RoboRallyGame(boolean debug) { if (debug) { @@ -106,6 +106,15 @@ public class RoboRallyGame implements IDrawableGame { robots.add(new Robot(RobotID.ROBOT_6, new Position(7, 7))); robots.add(new Robot(RobotID.ROBOT_7, new Position(6, 7))); robots.add(new Robot(RobotID.ROBOT_8, new Position(6, 8))); + playerList = new ArrayList<>(); + playerList.add(new Player(RobotID.ROBOT_1, "Player1")); + playerList.add(new Player(RobotID.ROBOT_2, "Player2")); + playerList.add(new Player(RobotID.ROBOT_3, "Player3")); + playerList.add(new Player(RobotID.ROBOT_4, "Player4")); + playerList.add(new Player(RobotID.ROBOT_5, "Player5")); + playerList.add(new Player(RobotID.ROBOT_6, "Player6")); + playerList.add(new Player(RobotID.ROBOT_7, "Player7")); + playerList.add(new Player(RobotID.ROBOT_8, "Player8")); gameBoard = BoardLoaderUtil.loadBoard("boards/Dizzy_Dash.txt", robots); cogwheels = gameBoard.getPositionsOfTileOnBoard(TileType.COGWHEEL_RIGHT, TileType.COGWHEEL_LEFT); @@ -169,6 +178,21 @@ public class RoboRallyGame implements IDrawableGame { makeMove(RobotID.ROBOT_7, Action.MOVE_1); } + /** + * Runs one phase as defined in the Robo Rally rulebook + * @param phaseNumber The number of the phase to run + * @throws InterruptedException If interrupted wile trying to sleep + */ + private void runPhase(int phaseNumber) throws InterruptedException { + runProgramCards(phaseNumber); + + moveAllConveyorBelts(); + rotateCogwheels(); + + fireAllLasers(); + checkAllFlags(); + } + /** * Makes the given robot move according to to the action input. * @param robotID The ID of the robot to move. @@ -382,4 +406,25 @@ public class RoboRallyGame implements IDrawableGame { sleep(); gameBoard.doLaserCleanup(); } + + private void runProgramCards(int phase) throws InterruptedException { + + List robotsToDoAction = new ArrayList<>(); + List programToBeRun = new ArrayList<>(); + List originalPriority = new ArrayList<>(); + for (Player player:playerList) { + List playerProgram = player.getProgram(); + if (!playerProgram.isEmpty()) { + originalPriority.add(playerProgram.get(phase).getPriority()); + robotsToDoAction.add(player.getRobotID()); + programToBeRun.add(playerProgram.get(phase)); + } + } + Collections.sort(programToBeRun); + for (ProgrammingCard card:programToBeRun) { + int i = originalPriority.indexOf(card.getPriority()); + RobotID robot = robotsToDoAction.get(i); + makeMove(robot, card.getAction()); + } + } } \ No newline at end of file