Skip to content

Commit

Permalink
updated logger and javadoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kubakubakuba committed May 22, 2023
1 parent cd3db8f commit 2c69108
Show file tree
Hide file tree
Showing 27 changed files with 447 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,20 @@ public class ChatView extends Application {
private double xOffset = 0;
private double yOffset = 0;

/**
* Constructor
* @param chatControl the chat controller
* @param client the client
*/
public ChatView(ChatController chatControl, Client client) {
this.chatControl = chatControl;
this.localClient = client;
}

/**
* Start the chat window
* @param stage the stage to show the window on
*/
public void start(Stage stage) {
this.stage = stage;
stage.initStyle(StageStyle.UNDECORATED);
Expand Down Expand Up @@ -98,20 +107,13 @@ public void addMessage(String msg) {
*/
public void enableChat(){
enabled = true;
/*javafx.application.Platform.runLater(() -> {
inputField.setDisable(false);
});*/
}

/**
* Disable chat
*/
public void disableChat(){
enabled = false;
/*javafx.application.Platform.runLater(() -> {
inputField.setDisable(true);
});*/
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,26 @@ public class FieldOperativeLeaderView extends Application {
private Button[][] buttons = new Button[5][5];
private Button saveBtn;

/**
* Constructor
* @param controller the game controller
*/
public FieldOperativeLeaderView(GameController controller) {
this.localControl = controller;
}

/**
* Start the game window
* @param args the arguments
*/
public static void main(String[] args) {
launch(args);
}

/**
* Start the game window
* @param gameStage the stage to show the window on
*/
@Override
public void start(Stage gameStage) {
localControl.getGameData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,27 @@ public class FieldOperativeView extends Application {

private Button saveBtn;
private StackPane[][] stackPane = new StackPane[5][5];

/**
* Constructor
* @param controller the game controller
*/
public FieldOperativeView(GameController controller) {
this.localControl = controller;
}

/**
* Start the game window
* @param args the arguments
*/
public static void main(String[] args) {
launch(args);
}

/**
* Start the game window
* @param gameStage the stage to show the window on
*/
@Override
public void start(Stage gameStage) {
localControl.getGameData();
Expand Down Expand Up @@ -144,6 +157,9 @@ public void start(Stage gameStage) {
gameStage.show();
}

/**
* Update the game window
*/
public void update() {
ArrayList<ArrayList<Key.KeyType>> old = localControl.getRevealedCardsBoard();
localControl.getGameData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class GameView extends Application {
public FieldOperativeView getViewF() {return viewF;}
public FieldOperativeLeaderView getViewL() {return viewL;}

/**
* Constructor
* @param controller the game controller
*/
public GameView(GameController controller) {
this.localControl = controller;
this.team = localControl.getClient().getPlayer().getTeam();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ public class LobbyView extends Application {
private Stage stage;
private LobbyController localControl = null;


/**
* Constructor
* @param lobbyStage the stage to show the window on
* @param ID the ID of the player
* @param control the lobby controller
* @param isPlayerHost whether the player is the host
*/
public LobbyView(Stage lobbyStage, String ID, LobbyController control, boolean isPlayerHost) {
this.stage = lobbyStage;
this.ID = ID;
Expand All @@ -51,6 +57,10 @@ public LobbyView(Stage lobbyStage, String ID, LobbyController control, boolean i

}

/**
* Creates the lobby scene
* @param lobbyStage the stage to show the window on
*/
@Override
public void start(Stage lobbyStage) {
lobbyStage.setScene(createLobbyScene());
Expand Down Expand Up @@ -230,6 +240,10 @@ private Scene createGuestLobby() {
return setBackground(layout);
}

/**
* Sets the common elements of the lobby scene
* @return VBox of the common elements of the lobby scene
*/
private VBox createCommonView() {

scrollPane = new ScrollPane();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,29 @@ public class ServerPicker extends Application {
private int serverPort;
private ArrayList<String> sessions;

/**
* Constructor
* @param args
*/
public static void main(String[] args) {
launch(args);
}

/**
* Constructor
* @param serverIP
* @param serverPort
*/
public ServerPicker(String serverIP, int serverPort){
this.serverIP = serverIP;
this.serverPort = serverPort;
System.out.println("Server IP: " + serverIP + " Server Port: " + serverPort);
}

/**
* Start the server picker window
* @param primaryStage the stage to show the window on
*/
@Override
public void start(Stage primaryStage) {
primaryStage.setOnCloseRequest(event -> {
Expand Down Expand Up @@ -148,17 +162,35 @@ public Scene createScene() {
return new Scene(bckrndPane, 650, 600);
}

/**
* Sets the previous scene
* @param scene the previous scene
*/
public void setPreviousScene(Scene scene) {
this.previousScene = scene;
}

/**
* Sets the previous stage
* @param stage the previous stage
*/
public void setStage(Stage stage) {
this.previousStage = stage;
}

/**
* Sets the ID
* @param ID the ID
*/

public void setID(String ID) {
this.ID = ID;
}

/**
* Displays an error message when unable to connect to a session
* @param errorMsg the error message
*/
private void connectError(String errorMsg) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Unable to join session");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,25 @@ public class SpymasterView extends Application {
private GameController localControl;
private Button saveBtn;

/**
* Constructor
* @param controller the game controller
*/
public SpymasterView(GameController controller) {
this.localControl = controller;
}

/**
* Start the game window
*/
public static void main() {
launch();
}

/**
* Start the game window
* @param gameStage the stage to show the window on
*/
@Override
public void start(Stage gameStage) {

Expand Down Expand Up @@ -200,6 +211,9 @@ public void start(Stage gameStage) {
}


/**
* Updates the view of the game
*/
public void update() {
ArrayList<ArrayList<Key.KeyType>> old = localControl.getRevealedCardsBoard();
localControl.getGameData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ public class StartView extends Application {

private String id;
private String serverIP;

/**
* Constructor
*/
public void startApp() {
launch();
}

/**
* Start the start window
* @param stage the stage to show the window on
*/
@Override
public void start(Stage stage) {
// Create a label with custom text
Expand Down Expand Up @@ -182,6 +190,11 @@ public void start(Stage stage) {
stage.setScene(scene);
stage.show();
}

/**
* Returns the id of the player
* @return id of the player
*/
public String getId() {
return id;
}
Expand Down
6 changes: 6 additions & 0 deletions CodeNames/src/main/java/cz/cvut/fel/pjv/codenames/Start.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
import cz.cvut.fel.pjv.codenames.server.Server;
import javafx.application.Application;
import javafx.stage.Stage;

import java.util.logging.Level;
import java.util.logging.LogManager;

/**
* @author Prokop Jansa, Jakub Pelc
* @version 1.0
*/
public class Start {
public static void main(String[] args) {
LogManager.getLogManager().getLogger("").setLevel(Level.INFO);

boolean isServer = false;
int port = 1515;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public class ChatController {
private Client client;
private ChatListener chatListen;

/**
* Constructor
* @param client the client
*/
public ChatController(Client client){
this.client = client;
this.chatView = new ChatView(this, client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ public class ChatListener implements Runnable {
private Client client;
private ChatController chatControl;

/**
* Constructor
* @param chatControl the chat controller
* @param client the client
*/
public ChatListener(ChatController chatControl, Client client){
this.chatControl = chatControl;
this.client = client;
this.running = true;
}

/**
* Stops the thread
*/
@Override
public void run() {
System.out.println("Listener started");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public Client getClient() {
public boolean hasGameEnded() {return gameEnded;}
public Player.PlayerTeam getWinner() {return winner;}

//constructor
/**
* Constructor
* @param client the client
* @param chatController the chat controller
*/
public GameController(Client client, ChatController chatController){
this.localClient = client;
this.chatController = chatController;
Expand Down Expand Up @@ -113,7 +117,7 @@ public void getGameData(){
update(gameData);
}
else{
System.out.println("Game data is null");
LOGGER.log(Level.SEVERE, "Game data is null");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@ public class GameListener implements Runnable {

private GameView gameView;

/**
* Constructor
* @param view the game view
* @param gameControl the game controller
*/
public GameListener(GameView view, GameController gameControl){
this.gameControl = gameControl;
this.gameView = view;
this.running = true;
}

/**
* Run method
*/
@Override
public void run() {
System.out.println("Game listener started");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public Client getLocalClient() {
return localClient;
}

//constructor
/**
* Constructor
* @param id id of client
* @param serverIP ip of server
* @param serverPort port of server
*/
public LobbyController(String id, String serverIP, int serverPort){
localClient = new Client(id, serverIP, serverPort);
}
Expand Down
Loading

0 comments on commit 2c69108

Please sign in to comment.