Byttet pakkenavn.

This commit is contained in:
Steinar Aalstad Lillesund
2020-04-14 15:54:09 +02:00
parent 9f716cc9a3
commit 382960d623
49 changed files with 94 additions and 93 deletions

View File

@@ -0,0 +1,14 @@
package inf112.fiasko.roborally.elementproperties;
/**
* This enum represents an action on a programming card
*/
public enum Action {
ROTATE_RIGHT,
ROTATE_LEFT,
U_TURN,
MOVE_1,
MOVE_2,
MOVE_3,
BACK_UP
}

View File

@@ -0,0 +1,91 @@
package inf112.fiasko.roborally.elementproperties;
/**
* This enum represents all possible directions for an element on the board
*/
public enum Direction {
NORTH (1),
NORTH_EAST (2),
EAST (3),
SOUTH_EAST (4),
SOUTH (5),
SOUTH_WEST (6),
WEST (7),
NORTH_WEST (8);
private final int directionID;
/**
* Constructor to let a direction to be represented by a numerical identifier
* @param directionID <p>The numerical identifier assigned to the direction</p>
*/
Direction(int directionID) {
this.directionID = directionID;
}
/**
* Gets the numerical identifier used for alternate identification of a direction
* @return <p>The numerical id of the direction</p>
*/
public int getDirectionID() {
return this.directionID;
}
/**
* Gets a direction from its numerical id
* @param directionID <p>The numerical representation of a direction</p>
* @return <p>The enum value representing the direction, or null if the id is invalid</p>
*/
public static Direction getDirectionFromID(int directionID) {
for (Direction direction : Direction.values()) {
if (direction.directionID == directionID) {
return direction;
}
}
return null;
}
/**
* Checks whether two directions are perpendicular
* @param direction1 The first direction
* @param direction2 The second direction
* @return True if the directions are perpendicular
*/
public static boolean arePerpendicular(Direction direction1, Direction direction2) {
return direction1.equals(getLeftRotatedDirection(direction2)) ||
direction1.equals(getRightRotatedDirection(direction2));
}
/**
* Gets the reverse of a direction
* @param direction A direction
* @return The reverse direction
*/
public static Direction getReverseDirection(Direction direction) {
return getDirectionFromID((((direction.getDirectionID() + 3) % 8) + 1));
}
/**
* Gets the direction if something rotated to the left
*
* A rotation is assumed to be a ninety degrees rotation, so NORTH would become WEST and so on.
*
* @param direction A direction
* @return The left rotated direction
*/
public static Direction getLeftRotatedDirection(Direction direction) {
return getDirectionFromID(((((direction.getDirectionID() - 3) + 8) % 8) + 1));
}
/**
* Gets the direction if something rotated to the right
*
* A rotation is assumed to be a ninety degrees rotation, so NORTH would become EAST and so on.
*
* @param direction A direction
* @return The left rotated direction
*/
public static Direction getRightRotatedDirection(Direction direction) {
return getDirectionFromID((((direction.getDirectionID() + 1) % 8) + 1));
}
}

View File

@@ -0,0 +1,24 @@
package inf112.fiasko.roborally.elementproperties;
public enum GameState {
//Indicates that the server is waiting for something
WAITING,
//Gives the game Access to the client and server
BEGINNING_OF_GAME,
//Indicates that the users' input is being run. The board should be shown
RUNNING_PROGRAMS,
//Indicates that
INITIAL_SETUP,
//
TURN_SETUP,
//Indicates that the game is in the process of cleaning up after a turn
TURN_CLEANUP,
//Indicates that the user is in the process of choosing cards
CHOOSING_CARDS,
//Indicates that the user is in the process of choosing whether to power down
CHOOSING_POWER_DOWN,
//Indicates that the user is in the process of choosing whether to stay in power down
CHOOSING_STAY_IN_POWER_DOWN,
//Indicates that the user is in the process of sending their cards to the server
SENDING_CARDS
}

View File

@@ -0,0 +1,40 @@
package inf112.fiasko.roborally.elementproperties;
public enum ParticleType {
LASER_BEAM_SINGLE (1),
LASER_BEAM_DOUBLE (2),
LASER_BEAM_SINGLE_CROSS (3),
LASER_BEAM_DOUBLE_CROSS (4);
private final int particleTypeID;
/**
* Constructor to let a particle type be represented by a numerical identifier
* @param particleTypeID <p>The numerical identifier assigned to the particle type</p>
*/
ParticleType(int particleTypeID) {
this.particleTypeID = particleTypeID;
}
/**
* Gets the numerical id used for alternate identification of a tile type
* @return <p>The numerical id of the tile type</p>
*/
public int getParticleTypeID() {
return this.particleTypeID;
}
/**
* Gets a particle type value from its numerical representation
* @param particleTypeID <p>The numerical representation of a particle type</p>
* @return <p>The enum value representing the particle type, or null if the id is invalid</p>
*/
public static ParticleType getParticleTypeFromID(int particleTypeID) {
for (ParticleType type : ParticleType.values()) {
if (type.particleTypeID == particleTypeID) {
return type;
}
}
return null;
}
}

View File

@@ -0,0 +1,53 @@
package inf112.fiasko.roborally.elementproperties;
/**
* This class represent a position on the board
*/
public class Position {
private final int xCoordinate;
private final int yCoordinate;
/**
* Initializes the position
* @param xCoordinate The x coordinate of the position
* @param yCoordinate The y coordinate of the position
*/
public Position(int xCoordinate, int yCoordinate) {
this.xCoordinate = xCoordinate;
this.yCoordinate = yCoordinate;
}
/**
* Gets the x coordinate of the position
* @return The x coordinate of the position
*/
public int getXCoordinate() {
return xCoordinate;
}
/**
* Gets the y coordinate of the position
* @return The y coordinate of the position
*/
public int getYCoordinate() {
return yCoordinate;
}
@Override
public String toString() {
return String.format("X: %d, Y: %d", xCoordinate, yCoordinate);
}
@Override
public boolean equals(Object obj) {
if (obj.getClass() != Position.class) {
return false;
}
if (obj == this) {
return true;
}
return this.xCoordinate == ((Position) obj).xCoordinate &&
this.yCoordinate == ((Position) obj).yCoordinate;
}
}

View File

@@ -0,0 +1,47 @@
package inf112.fiasko.roborally.elementproperties;
/**
* This class represents an id for marking specific robots
*/
public enum RobotID {
ROBOT_1 (1),
ROBOT_2 (2),
ROBOT_3 (3),
ROBOT_4 (4),
ROBOT_5 (5),
ROBOT_6 (6),
ROBOT_7 (7),
ROBOT_8 (8);
private final int robotID;
/**
* Constructor to let a robotID be represented by a numerical identifier
* @param robotID <p>The numerical identifier assigned to the robot ID</p>
*/
RobotID(int robotID) {
this.robotID = robotID;
}
/**
* Gets the numerical id used for identification of a robot id
* @return <p>The numerical id of the robot id</p>
*/
public int getRobotIDID() {
return this.robotID;
}
/**
* Gets a robot ID value from its numerical representation
* @param robotID <p>The numerical representation of a robot id</p>
* @return <p>The enum value representing the robot ID, or null if the id is invalid</p>
*/
public static RobotID getRobotIDFromID(int robotID) {
for (RobotID type : RobotID.values()) {
if (type.robotID == robotID) {
return type;
}
}
return null;
}
}

View File

@@ -0,0 +1,74 @@
package inf112.fiasko.roborally.elementproperties;
/**
* This enum represents all possible tile types
*/
public enum TileType {
TILE (1),
HOLE (2),
COGWHEEL_RIGHT (3),
COGWHEEL_LEFT (4),
CONVEYOR_BELT_SLOW(5),
CONVEYOR_BELT_SLOW_RIGHT(6),
CONVEYOR_BELT_SLOW_LEFT(7),
CONVEYOR_BELT_SLOW_SIDE_ENTRANCES(8),
CONVEYOR_BELT_SLOW_SIDE_ENTRANCE_LEFT(9),
CONVEYOR_BELT_SLOW_SIDE_ENTRANCE_RIGHT(10),
CONVEYOR_BELT_FAST(11),
CONVEYOR_BELT_FAST_RIGHT(12),
CONVEYOR_BELT_FAST_LEFT(13),
CONVEYOR_BELT_FAST_SIDE_ENTRANCES(14),
CONVEYOR_BELT_FAST_SIDE_ENTRANCE_LEFT(15),
CONVEYOR_BELT_FAST_SIDE_ENTRANCE_RIGHT(16),
FLAG_1 (17),
FLAG_2 (18),
FLAG_3 (19),
FLAG_4 (20),
WRENCH (21),
WRENCH_AND_HAMMER (22),
ROBOT_SPAWN_1 (23),
ROBOT_SPAWN_2 (24),
ROBOT_SPAWN_3 (25),
ROBOT_SPAWN_4 (26),
ROBOT_SPAWN_5 (27),
ROBOT_SPAWN_6 (28),
ROBOT_SPAWN_7 (29),
ROBOT_SPAWN_8 (30),
PIT_EMPTY (31),
PIT_FULL (32),
PIT_NORMAL (33),
PIT_CORNER (34),
PIT_U (35);
private final int tileTypeID;
/**
* Constructor to let a tile type be represented by a numerical identifier
* @param tileTypeID <p>The numerical identifier assigned to the tile type</p>
*/
TileType(int tileTypeID) {
this.tileTypeID = tileTypeID;
}
/**
* Gets the numerical id used for alternate identification of a tile type
* @return <p>The numerical id of the tile type</p>
*/
public int getTileTypeID() {
return this.tileTypeID;
}
/**
* Gets a tile type value from its numerical representation
* @param tileTypeID <p>The numerical representation of a tile type</p>
* @return <p>The enum value representing the tile type, or null if the id is invalid</p>
*/
public static TileType getTileTypeFromID(int tileTypeID) {
for (TileType type : TileType.values()) {
if (type.tileTypeID == tileTypeID) {
return type;
}
}
return null;
}
}

View File

@@ -0,0 +1,43 @@
package inf112.fiasko.roborally.elementproperties;
/**
* This enum represents all possible wall types
*/
public enum WallType {
WALL_NORMAL (1),
WALL_CORNER (2),
WALL_LASER_SINGLE (3),
WALL_LASER_DOUBLE (4);
private final int wallTypeID;
/**
* Constructor to let a wall type be represented by a numerical identifier
* @param wallTypeID <p>The numerical identifier assigned to the wall type</p>
*/
WallType(int wallTypeID) {
this.wallTypeID = wallTypeID;
}
/**
* Gets the numerical id used for alternate identification of a wall type
* @return <p>The numerical id of the wall type</p>
*/
public int getWallTypeID() {
return this.wallTypeID;
}
/**
* Gets a wall type value from its numerical representation
* @param wallTypeID <p>The numerical representation of a wall type</p>
* @return <p>The enum value representing the wall type, or null if the id is invalid</p>
*/
public static WallType getWallTypeFromID(int wallTypeID) {
for (WallType type : WallType.values()) {
if (type.wallTypeID == wallTypeID) {
return type;
}
}
return null;
}
}