mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-07-29 03:05:26 +02:00
Splitter opp interfacer for tegning og intragering
Endrer ting slik at spillet får vite om server og klient ved initialisering Registerer Action for kryo Oppdaterer konstruktør i RoboRallyGameTest
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.elementproperties.GameState;
|
||||
import inf112.fiasko.roborally.networking.RoboRallyClient;
|
||||
import inf112.fiasko.roborally.networking.RoboRallyServer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -58,28 +54,4 @@ public interface IDrawableGame {
|
||||
* @return A list of all robots to draw
|
||||
*/
|
||||
List<Robot> getRobotsToDraw();
|
||||
|
||||
/**
|
||||
* Gets the current state og the game
|
||||
* @return The state the game is currently in
|
||||
*/
|
||||
GameState getGameState();
|
||||
|
||||
/**
|
||||
* Sets the current state og the game
|
||||
*/
|
||||
void setGameState(GameState gameState);
|
||||
|
||||
/**
|
||||
* Gets the name of the player who won
|
||||
* @return A string of the player name
|
||||
*/
|
||||
String getWinningPlayerName();
|
||||
|
||||
|
||||
RoboRallyClient getClient();
|
||||
|
||||
void setClient(RoboRallyClient client);
|
||||
|
||||
void setServer(RoboRallyServer server);
|
||||
}
|
||||
|
@@ -0,0 +1,26 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.elementproperties.GameState;
|
||||
|
||||
/**
|
||||
* This interface describes
|
||||
*/
|
||||
public interface IInteractableGame {
|
||||
/**
|
||||
* Gets the current state og the game
|
||||
* @return The state the game is currently in
|
||||
*/
|
||||
GameState getGameState();
|
||||
|
||||
/**
|
||||
* Sets the state of the game
|
||||
* @param gameState The new state of the game
|
||||
*/
|
||||
void setGameState(GameState gameState);
|
||||
|
||||
/**
|
||||
* Gets the name of the player who won
|
||||
* @return A string of the player name
|
||||
*/
|
||||
String getWinningPlayerName();
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
public interface IRoboRallyGame extends IDrawableGame, IInteractableGame {}
|
@@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* This class represent a game which is drawable using libgdx
|
||||
*/
|
||||
public class RoboRallyGame implements IDrawableGame {
|
||||
public class RoboRallyGame implements IRoboRallyGame {
|
||||
private Board gameBoard;
|
||||
private List<BoardElementContainer<Tile>> cogwheels;
|
||||
private List<BoardElementContainer<Tile>> conveyorBelts;
|
||||
@@ -33,19 +33,19 @@ public class RoboRallyGame implements IDrawableGame {
|
||||
private final boolean host;
|
||||
private Deck<ProgrammingCard> mainDeck;
|
||||
private GameState gameState = GameState.BEGINNING_OF_GAME;
|
||||
private String nameOfPlayer;
|
||||
private RoboRallyClient client;
|
||||
private String playerName;
|
||||
private final RoboRallyClient client;
|
||||
private RoboRallyServer server;
|
||||
private String winningPlayerName;
|
||||
|
||||
|
||||
|
||||
public String getNameOfPlayer() {
|
||||
return nameOfPlayer;
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public void setNameOfPlayer(String nameOfPlayer) {
|
||||
this.nameOfPlayer = nameOfPlayer;
|
||||
public void setPlayerName(String playerName) {
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,30 +75,17 @@ public class RoboRallyGame implements IDrawableGame {
|
||||
this.gameState = gameState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoboRallyClient getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClient(RoboRallyClient client) {
|
||||
this.client=client;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setServer(RoboRallyServer server) {
|
||||
this.server=server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new robo rally game
|
||||
* @param debug Whether to start the game in debugging mode
|
||||
*/
|
||||
public RoboRallyGame(List<Player> playerList, String boardName, boolean host, boolean debug, String name) {
|
||||
this.nameOfPlayer = name;
|
||||
public RoboRallyGame(List<Player> playerList, String boardName, boolean host, String name, RoboRallyClient client,
|
||||
RoboRallyServer server, boolean debug) {
|
||||
this.playerName = name;
|
||||
this.host = host;
|
||||
this.playerList = playerList;
|
||||
this.client = client;
|
||||
this.server = server;
|
||||
if (debug) {
|
||||
initializeDebugMode();
|
||||
} else {
|
||||
@@ -109,10 +96,13 @@ public class RoboRallyGame implements IDrawableGame {
|
||||
/**
|
||||
* Instantiates a new robo rally game
|
||||
*/
|
||||
public RoboRallyGame(List<Player> playerList, String boardName,boolean host,String nameOfPlayer) {
|
||||
this.nameOfPlayer = nameOfPlayer;
|
||||
public RoboRallyGame(List<Player> playerList, String boardName, boolean host, String playerName, RoboRallyClient client,
|
||||
RoboRallyServer server) {
|
||||
this.playerName = playerName;
|
||||
this.host = host;
|
||||
this.playerList = playerList;
|
||||
this.client = client;
|
||||
this.server = server;
|
||||
initializeGame(boardName);
|
||||
}
|
||||
|
||||
@@ -275,7 +265,7 @@ public class RoboRallyGame implements IDrawableGame {
|
||||
for (Connection connection: server.getPlayerNames().keySet()) {
|
||||
String playerName = server.getPlayerNames().get(connection);
|
||||
Player player = getPlayerFromName(playerName);
|
||||
if(player.getPlayerDeck()!=null) {
|
||||
if (player != null && player.getPlayerDeck() != null) {
|
||||
server.sendToClient(connection, player.getPlayerDeck());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user