mirror of
				https://github.com/inf112-v20/Fiasko.git
				synced 2025-11-03 19:23:45 +01:00 
			
		
		
		
	Merge branch 'master' of https://github.com/inf112-v20/Fiasko
This commit is contained in:
		
							
								
								
									
										19
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								pom.xml
									
									
									
									
									
								
							@@ -20,6 +20,13 @@
 | 
				
			|||||||
    <maven.compiler.target>1.8</maven.compiler.target>
 | 
					    <maven.compiler.target>1.8</maven.compiler.target>
 | 
				
			||||||
  </properties>
 | 
					  </properties>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <repositories>
 | 
				
			||||||
 | 
					    <repository>
 | 
				
			||||||
 | 
					      <id>clojars</id>
 | 
				
			||||||
 | 
					      <url>http://clojars.org/repo/</url>
 | 
				
			||||||
 | 
					    </repository>
 | 
				
			||||||
 | 
					  </repositories>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <dependencies>
 | 
					  <dependencies>
 | 
				
			||||||
    <!-- https://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx -->
 | 
					    <!-- https://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx -->
 | 
				
			||||||
    <dependency>
 | 
					    <dependency>
 | 
				
			||||||
@@ -53,6 +60,18 @@
 | 
				
			|||||||
      <classifier>natives-desktop</classifier>
 | 
					      <classifier>natives-desktop</classifier>
 | 
				
			||||||
    </dependency>
 | 
					    </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <dependency>
 | 
				
			||||||
 | 
					      <groupId>com.esotericsoftware</groupId>
 | 
				
			||||||
 | 
					      <artifactId>kryo</artifactId>
 | 
				
			||||||
 | 
					      <version>5.0.0-RC5</version>
 | 
				
			||||||
 | 
					    </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <dependency>
 | 
				
			||||||
 | 
					      <groupId>kryonet</groupId>
 | 
				
			||||||
 | 
					      <artifactId>kryonet</artifactId>
 | 
				
			||||||
 | 
					      <version>2.21</version>
 | 
				
			||||||
 | 
					    </dependency>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <dependency>
 | 
					    <dependency>
 | 
				
			||||||
      <groupId>junit</groupId>
 | 
					      <groupId>junit</groupId>
 | 
				
			||||||
      <artifactId>junit</artifactId>
 | 
					      <artifactId>junit</artifactId>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,9 @@
 | 
				
			|||||||
package inf112.fiasko.roborally.objects;
 | 
					package inf112.fiasko.roborally.objects;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import inf112.fiasko.roborally.element_properties.Direction;
 | 
					import inf112.fiasko.roborally.element_properties.*;
 | 
				
			||||||
import inf112.fiasko.roborally.element_properties.Position;
 | 
					import inf112.fiasko.roborally.utility.TextureConverterUtil;
 | 
				
			||||||
import inf112.fiasko.roborally.element_properties.RobotID;
 | 
					 | 
				
			||||||
import inf112.fiasko.roborally.element_properties.TileType;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.lang.reflect.Array;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.HashMap;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
@@ -327,4 +326,62 @@ public class Board {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        return elements;
 | 
					        return elements;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 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>> getPositionsOfTileOnBoard(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
 | 
				
			||||||
 | 
					     * @param type Type of obj
 | 
				
			||||||
 | 
					     * @param grid Grid to search
 | 
				
			||||||
 | 
					     * @param <K> Type of type
 | 
				
			||||||
 | 
					     * @param <T> Type of grid
 | 
				
			||||||
 | 
					     * @return List of BoardElementContainers
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private <K,T> List<BoardElementContainer<T>> makeTileList(K type, IGrid<T> grid) {
 | 
				
			||||||
 | 
					        List<BoardElementContainer<T>> objList = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int y = grid.getHeight() - 1; y >= 0; y--) {
 | 
				
			||||||
 | 
					            for (int x = 0; x < grid.getWidth(); x++) {
 | 
				
			||||||
 | 
					                T gridElement = grid.getElement(x, y);
 | 
				
			||||||
 | 
					                if (gridElement.getClass().isAssignableFrom(Tile.class)) {
 | 
				
			||||||
 | 
					                    Tile tile = (Tile) gridElement;
 | 
				
			||||||
 | 
					                    if (tile.getTileType() == type) {
 | 
				
			||||||
 | 
					                        objList.add(new BoardElementContainer<>(gridElement, new Position(x,y)));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } else if (gridElement.getClass().isAssignableFrom(Wall.class)) {
 | 
				
			||||||
 | 
					                    Wall wall = (Wall) gridElement;
 | 
				
			||||||
 | 
					                    if (wall.getWallType() == type) {
 | 
				
			||||||
 | 
					                        objList.add(new BoardElementContainer<>(gridElement, new Position(x,y)));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    throw new IllegalArgumentException("Grid has unknown type.");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return objList;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					package inf112.fiasko.roborally.objects;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import inf112.fiasko.roborally.element_properties.Position;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * This class represents a type of object and its position
 | 
				
			||||||
 | 
					 * @param <K> The type of object
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class BoardElementContainer <K>{
 | 
				
			||||||
 | 
					    K obj;
 | 
				
			||||||
 | 
					    Position pos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Initializes the BoardElementContainer
 | 
				
			||||||
 | 
					     * @param obj The object
 | 
				
			||||||
 | 
					     * @param pos The position
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    BoardElementContainer(K obj, Position pos) {
 | 
				
			||||||
 | 
					        this.obj = obj;
 | 
				
			||||||
 | 
					        this.pos = pos;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets the object
 | 
				
			||||||
 | 
					     * @return object
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public K getObject() {
 | 
				
			||||||
 | 
					        return obj;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets the position
 | 
				
			||||||
 | 
					     * @return position
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public Position getPosition() {
 | 
				
			||||||
 | 
					        return pos;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -141,14 +141,14 @@ public class RoboRallyGame implements IDrawableGame {
 | 
				
			|||||||
        sleep();
 | 
					        sleep();
 | 
				
			||||||
        switch (action) {
 | 
					        switch (action) {
 | 
				
			||||||
            case MOVE_1:
 | 
					            case MOVE_1:
 | 
				
			||||||
                moveForward(robotID);
 | 
					                gameBoard.moveRobotForward(robotID);
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case MOVE_2:
 | 
					            case MOVE_2:
 | 
				
			||||||
                moveForward(robotID);
 | 
					                gameBoard.moveRobotForward(robotID);
 | 
				
			||||||
                moveForward(robotID);
 | 
					                moveForward(robotID);
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case MOVE_3:
 | 
					            case MOVE_3:
 | 
				
			||||||
                moveForward(robotID);
 | 
					                gameBoard.moveRobotForward(robotID);
 | 
				
			||||||
                moveForward(robotID);
 | 
					                moveForward(robotID);
 | 
				
			||||||
                moveForward(robotID);
 | 
					                moveForward(robotID);
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user