mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-08 02:59:36 +01:00
Merge branch 'master' of https://github.com/inf112-v20/Fiasko
This commit is contained in:
commit
b83dfcdfbf
17
docs/team/referater/referat_17_03_2020.md
Normal file
17
docs/team/referater/referat_17_03_2020.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
## Oppmøte
|
||||||
|
Tilstede: Steinar, Gabriel, Kristian, Torbjørn, Petter
|
||||||
|
Ikke tilstede:
|
||||||
|
|
||||||
|
## Agenda
|
||||||
|
- Design valg
|
||||||
|
|
||||||
|
- Brukerhistorier
|
||||||
|
|
||||||
|
- Fordele Oppgaver
|
||||||
|
|
||||||
|
## Møte
|
||||||
|
- Diskuterer spørmsål vi vil sende inn the "kunden" angående innlevering/vurdering.
|
||||||
|
|
||||||
|
- Sett på og reflektert rundt multiplayer finksjonaliteten.
|
||||||
|
|
||||||
|
- Prøvd å få gruppen på samme nivå abgående forståelse rundt utfordringer med nettverk.
|
@ -6,6 +6,9 @@ import com.badlogic.gdx.Screen;
|
|||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
|
import com.badlogic.gdx.math.Vector3;
|
||||||
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||||
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
@ -18,14 +21,18 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
|||||||
private final OrthographicCamera camera;
|
private final OrthographicCamera camera;
|
||||||
private final CardRectangle cardRectangle;
|
private final CardRectangle cardRectangle;
|
||||||
private final ShapeRenderer shapeRenderer;
|
private final ShapeRenderer shapeRenderer;
|
||||||
|
private final Viewport viewport;
|
||||||
|
|
||||||
public CardChoiceScreen(final RoboRallyWrapper roboRallyWrapper) {
|
public CardChoiceScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||||
this.roboRallyWrapper = roboRallyWrapper;
|
this.roboRallyWrapper = roboRallyWrapper;
|
||||||
camera = new OrthographicCamera();
|
camera = new OrthographicCamera();
|
||||||
camera.setToOrtho(true, 1200, 1200);
|
int applicationWidth = 600;
|
||||||
|
int applicationHeight = 800;
|
||||||
|
camera.setToOrtho(true, applicationWidth, applicationHeight);
|
||||||
|
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
||||||
Rectangle card1 = new Rectangle();
|
Rectangle card1 = new Rectangle();
|
||||||
card1.x = 1200/2;
|
card1.x = 10;
|
||||||
card1.y = 1200/2;
|
card1.y = 10;
|
||||||
card1.width = 100;
|
card1.width = 100;
|
||||||
card1.height = 100;
|
card1.height = 100;
|
||||||
cardRectangle = new CardRectangle(card1);
|
cardRectangle = new CardRectangle(card1);
|
||||||
@ -60,8 +67,8 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int i, int i1) {
|
public void resize(int width, int height) {
|
||||||
//Nothing to do
|
viewport.update(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,12 +93,9 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
||||||
System.out.println(screenX + " " + screenY);
|
Vector3 transformed = viewport.unproject(new Vector3(screenX, screenY, 0));
|
||||||
System.out.println(cardRectangle.rectangle.x + " " + cardRectangle.rectangle.y + " " +
|
if (cardRectangle.rectangle.contains(transformed.x, transformed.y)) {
|
||||||
cardRectangle.rectangle.width + " " + cardRectangle.rectangle.height);
|
cardRectangle.selected = !cardRectangle.selected;
|
||||||
if (cardRectangle.rectangle.contains(screenX, screenY)) {
|
|
||||||
cardRectangle.selected = true;
|
|
||||||
System.out.println("Card touched");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -135,7 +135,7 @@ public class Board {
|
|||||||
Position robotPosition = robot.getPosition();
|
Position robotPosition = robot.getPosition();
|
||||||
Position newPosition = getNewPosition(robotPosition, direction);
|
Position newPosition = getNewPosition(robotPosition, direction);
|
||||||
//There is a wall blocking the robot. It can't proceed.
|
//There is a wall blocking the robot. It can't proceed.
|
||||||
if (robotMoveIsStoppedByWall(robotPosition, newPosition, direction)) {
|
if (moveIsStoppedByWall(robotPosition, newPosition, direction)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//Robot tried to go outside of the map. Kill it.
|
//Robot tried to go outside of the map. Kill it.
|
||||||
@ -209,13 +209,72 @@ public class Board {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a potential robot move would be blocked by a wall
|
* Gets the position 1 unit in a specific direction from another position
|
||||||
* @param robotPosition The current position of the robot
|
* @param oldPosition The old/current position of the element
|
||||||
* @param newPosition The position the robot is trying to move to
|
* @param direction The direction to move the element
|
||||||
* @param direction The direction the robot is going
|
* @return The new position of the element
|
||||||
|
*/
|
||||||
|
public Position getNewPosition(Position oldPosition, Direction direction) {
|
||||||
|
switch (direction) {
|
||||||
|
case NORTH:
|
||||||
|
return new Position(oldPosition.getXCoordinate(), oldPosition.getYCoordinate() - 1);
|
||||||
|
case SOUTH:
|
||||||
|
return new Position(oldPosition.getXCoordinate(), oldPosition.getYCoordinate() + 1);
|
||||||
|
case EAST:
|
||||||
|
return new Position(oldPosition.getXCoordinate() + 1, oldPosition.getYCoordinate());
|
||||||
|
case WEST:
|
||||||
|
return new Position(oldPosition.getXCoordinate() - 1, oldPosition.getYCoordinate());
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("It's not possible to move in that direction.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the tile on a specific position
|
||||||
|
* @param position The position to get a tile from
|
||||||
|
* @return The tile on the given position
|
||||||
|
*/
|
||||||
|
public Tile getTileOnPosition(Position position) {
|
||||||
|
if (!isValidPosition(position)) {
|
||||||
|
throw new IllegalArgumentException("Position is not on the board!");
|
||||||
|
}
|
||||||
|
return tiles.getElement(position.getXCoordinate(), position.getYCoordinate());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of BoardElementContainers, containing all tiles and positions of given tile types
|
||||||
|
* @param tiles The tiles you want all positions for
|
||||||
|
* @return A list of BoardElementContainers
|
||||||
|
*/
|
||||||
|
public List<BoardElementContainer<Tile>> getPositionsOfTileOnBoard(TileType ... tiles) {
|
||||||
|
List<BoardElementContainer<Tile>> combinedList = new ArrayList<>();
|
||||||
|
for (TileType tile : tiles) {
|
||||||
|
combinedList.addAll(makeTileList(tile, this.tiles));
|
||||||
|
}
|
||||||
|
return combinedList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of BoardElementContainers, containing all tiles and positions of given wall types
|
||||||
|
* @param walls The walls you want all positions for
|
||||||
|
* @return A list of BoardElementContainers
|
||||||
|
*/
|
||||||
|
public List<BoardElementContainer<Wall>> getPositionsOfWallOnBoard(WallType... walls) {
|
||||||
|
List<BoardElementContainer<Wall>> combinedList = new ArrayList<>();
|
||||||
|
for (WallType wall : walls) {
|
||||||
|
combinedList.addAll(makeTileList(wall, this.walls));
|
||||||
|
}
|
||||||
|
return combinedList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a potential move would be blocked by a wall
|
||||||
|
* @param robotPosition The current position of whatever is trying to move
|
||||||
|
* @param newPosition The position something is trying to move to
|
||||||
|
* @param direction The direction something is going
|
||||||
* @return True if a wall would stop its path
|
* @return True if a wall would stop its path
|
||||||
*/
|
*/
|
||||||
private boolean robotMoveIsStoppedByWall(Position robotPosition, Position newPosition, Direction direction) {
|
public boolean moveIsStoppedByWall(Position robotPosition, Position newPosition, Direction direction) {
|
||||||
return hasWallFacing(robotPosition, direction) || (isValidPosition(newPosition) &&
|
return hasWallFacing(robotPosition, direction) || (isValidPosition(newPosition) &&
|
||||||
hasWallFacing(newPosition, Direction.getReverseDirection(direction)));
|
hasWallFacing(newPosition, Direction.getReverseDirection(direction)));
|
||||||
}
|
}
|
||||||
@ -305,27 +364,6 @@ public class Board {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the position 1 unit in a specific direction from another position
|
|
||||||
* @param oldPosition The old/current position of the element
|
|
||||||
* @param direction The direction to move the element
|
|
||||||
* @return The new position of the element
|
|
||||||
*/
|
|
||||||
public Position getNewPosition(Position oldPosition, Direction direction) {
|
|
||||||
switch (direction) {
|
|
||||||
case NORTH:
|
|
||||||
return new Position(oldPosition.getXCoordinate(), oldPosition.getYCoordinate() - 1);
|
|
||||||
case SOUTH:
|
|
||||||
return new Position(oldPosition.getXCoordinate(), oldPosition.getYCoordinate() + 1);
|
|
||||||
case EAST:
|
|
||||||
return new Position(oldPosition.getXCoordinate() + 1, oldPosition.getYCoordinate());
|
|
||||||
case WEST:
|
|
||||||
return new Position(oldPosition.getXCoordinate() - 1, oldPosition.getYCoordinate());
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("It's not possible to move in that direction.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all elements on a grid
|
* Gets all elements on a grid
|
||||||
* @param grid The grid to get elements from
|
* @param grid The grid to get elements from
|
||||||
@ -342,39 +380,6 @@ public class Board {
|
|||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tile getTileOnPosition(Position position) {
|
|
||||||
if (!isValidPosition(position)) {
|
|
||||||
throw new IllegalArgumentException("Position is not on the board!");
|
|
||||||
}
|
|
||||||
return tiles.getElement(position.getXCoordinate(), position.getYCoordinate());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of BoardElementContainers, containing all tiles and positions of given tile types
|
|
||||||
* @param tiles The tiles you want all positions for
|
|
||||||
* @return A list of BoardElementContainers
|
|
||||||
*/
|
|
||||||
public List<BoardElementContainer<Tile>> getPositionsOfTileOnBoard(TileType ... tiles) {
|
|
||||||
List<BoardElementContainer<Tile>> combinedList = new ArrayList<>();
|
|
||||||
for (TileType tile : tiles) {
|
|
||||||
combinedList.addAll(makeTileList(tile, this.tiles));
|
|
||||||
}
|
|
||||||
return combinedList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of BoardElementContainers, containing all tiles and positions of given wall types
|
|
||||||
* @param walls The walls you want all positions for
|
|
||||||
* @return A list of BoardElementContainers
|
|
||||||
*/
|
|
||||||
public List<BoardElementContainer<Wall>> getPositionsOfWallOnBoard(WallType... walls) {
|
|
||||||
List<BoardElementContainer<Wall>> combinedList = new ArrayList<>();
|
|
||||||
for (WallType wall : walls) {
|
|
||||||
combinedList.addAll(makeTileList(wall, this.walls));
|
|
||||||
}
|
|
||||||
return combinedList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all position of an obj and makes a list of BoardElementContainers
|
* Finds all position of an obj and makes a list of BoardElementContainers
|
||||||
* @param type Type of obj
|
* @param type Type of obj
|
||||||
|
@ -221,10 +221,7 @@ public class BoardTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getPositionsOfTileOnBoardHasTypeCogwheelLeft() {
|
public void getPositionsOfTileOnBoardHasTypeCogwheelLeft() {
|
||||||
List<BoardElementContainer<Tile>> boardElemList = boardWithDifferentAmountOfAllTypes.getPositionsOfTileOnBoard(TileType.COGWHEEL_LEFT);
|
List<BoardElementContainer<Tile>> boardElemList = boardWithDifferentAmountOfAllTypes.getPositionsOfTileOnBoard(TileType.COGWHEEL_LEFT);
|
||||||
|
assertTrue(checkIfAllElementsAreOfSpecificTileType(boardElemList, TileType.COGWHEEL_LEFT));
|
||||||
for (BoardElementContainer<Tile> elem : boardElemList) {
|
|
||||||
assertEquals(elem.getElement().getTileType(), TileType.COGWHEEL_LEFT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -236,10 +233,7 @@ public class BoardTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getPositionsOfTileOnBoardHasTypeTile() {
|
public void getPositionsOfTileOnBoardHasTypeTile() {
|
||||||
List<BoardElementContainer<Tile>> boardElemList = boardWithDifferentAmountOfAllTypes.getPositionsOfTileOnBoard(TileType.TILE);
|
List<BoardElementContainer<Tile>> boardElemList = boardWithDifferentAmountOfAllTypes.getPositionsOfTileOnBoard(TileType.TILE);
|
||||||
|
assertTrue(checkIfAllElementsAreOfSpecificTileType(boardElemList, TileType.TILE));
|
||||||
for (BoardElementContainer<Tile> elem : boardElemList) {
|
|
||||||
assertEquals(elem.getElement().getTileType(), TileType.TILE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -251,10 +245,7 @@ public class BoardTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getPositionsOfWallOnBoardHasTypeWallNormal() {
|
public void getPositionsOfWallOnBoardHasTypeWallNormal() {
|
||||||
List<BoardElementContainer<Wall>> boardElemList = boardWithDifferentAmountOfAllTypes.getPositionsOfWallOnBoard(WallType.WALL_NORMAL);
|
List<BoardElementContainer<Wall>> boardElemList = boardWithDifferentAmountOfAllTypes.getPositionsOfWallOnBoard(WallType.WALL_NORMAL);
|
||||||
|
assertTrue(checkIfAllElementsAreOfSpecificWallType(boardElemList, WallType.WALL_NORMAL));
|
||||||
for (BoardElementContainer<Wall> elem : boardElemList) {
|
|
||||||
assertEquals(elem.getElement().getWallType(), WallType.WALL_NORMAL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -266,17 +257,32 @@ public class BoardTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getPositionsOfWallOnBoardHasTypeWallCorner() {
|
public void getPositionsOfWallOnBoardHasTypeWallCorner() {
|
||||||
List<BoardElementContainer<Wall>> boardElemList = boardWithDifferentAmountOfAllTypes.getPositionsOfWallOnBoard(WallType.WALL_CORNER);
|
List<BoardElementContainer<Wall>> boardElemList = boardWithDifferentAmountOfAllTypes.getPositionsOfWallOnBoard(WallType.WALL_CORNER);
|
||||||
|
assertTrue(checkIfAllElementsAreOfSpecificWallType(boardElemList, WallType.WALL_CORNER));
|
||||||
for (BoardElementContainer<Wall> elem : boardElemList) {
|
|
||||||
assertEquals(elem.getElement().getWallType(), WallType.WALL_CORNER);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPositionsOfWallOnBoardHasCorrect() {
|
public void getPositionsOfWallOnBoardHasCorrectTypesWithMultipleParameters() {
|
||||||
List<BoardElementContainer<Wall>> boardElemList = boardWithDifferentAmountOfAllTypes.getPositionsOfWallOnBoard(WallType.WALL_CORNER);
|
List<BoardElementContainer<Tile>> boardElemList = boardWithDifferentAmountOfAllTypes.getPositionsOfTileOnBoard(TileType.COGWHEEL_LEFT, TileType.COGWHEEL_RIGHT);
|
||||||
Predicate<BoardElementContainer<Wall>> pred = (element) -> element.getElement().getWallType() == WallType.WALL_CORNER;
|
List<TileType> tileTypeList = new ArrayList<>();
|
||||||
boardElemList.removeIf(pred);
|
List<TileType> tileTypeListResult = new ArrayList<>();
|
||||||
assertEquals(0, boardElemList.size());
|
tileTypeList.add(TileType.COGWHEEL_LEFT);
|
||||||
|
tileTypeList.add(TileType.COGWHEEL_RIGHT);
|
||||||
|
|
||||||
|
for (BoardElementContainer<Tile> elem : boardElemList) {
|
||||||
|
tileTypeListResult.add(elem.getElement().getTileType());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(tileTypeList.containsAll(tileTypeListResult) && tileTypeListResult.containsAll(tileTypeList));
|
||||||
|
}
|
||||||
|
|
||||||
|
public <K> boolean checkIfAllElementsAreOfSpecificWallType(List<BoardElementContainer<Wall>> elemList, K WallType) {
|
||||||
|
Predicate<BoardElementContainer<Wall>> pred = (element) -> element.getElement().getWallType() == WallType;
|
||||||
|
elemList.removeIf(pred);
|
||||||
|
return 0 == elemList.size();
|
||||||
|
}
|
||||||
|
public <K> boolean checkIfAllElementsAreOfSpecificTileType(List<BoardElementContainer<Tile>> elemList, K TileType) {
|
||||||
|
Predicate<BoardElementContainer<Tile>> pred = (element) -> element.getElement().getTileType() == TileType;
|
||||||
|
elemList.removeIf(pred);
|
||||||
|
return 0 == elemList.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user