Added javadoc statements to loads of methods where there was a warning
This commit is contained in:
parent
bf31670ec1
commit
08f9f44fab
@ -33,6 +33,8 @@ public class Game implements Runnable {
|
||||
* @param nrOfPlayers is the length of the Train
|
||||
* @param nrOfGhosts is the number of OG Ghosts you want to start with and
|
||||
* @param nrOfUsers is the number of active users at the time (non NPCs)
|
||||
* @param lobby the lobby the game is in
|
||||
* @throws TrainOverflow when there are to many users
|
||||
*/
|
||||
public Game(int nrOfPlayers, int nrOfGhosts, int nrOfUsers, Lobby lobby)
|
||||
throws TrainOverflow {
|
||||
|
||||
@ -17,6 +17,8 @@ public class GhostifyHandler {
|
||||
* called. If it's being called for the first time, the ghostified player is being set as the original ghost.
|
||||
*
|
||||
* @param p Passenger to be ghostified
|
||||
* @param game the game the GhostyfyHandler is used in
|
||||
* @return a Passenger that either got ghostyfied or i still kicked off
|
||||
*/
|
||||
|
||||
public static Passenger ghost(Passenger p, Game game) {
|
||||
|
||||
@ -15,7 +15,6 @@ import org.apache.logging.log4j.Logger;
|
||||
*
|
||||
* <p>(All messages going to Clients are handled via ServerGameInfoHandler)
|
||||
*
|
||||
* <p>
|
||||
*/
|
||||
public class VoteHandler {
|
||||
public static final Logger LOGGER = LogManager.getLogger(VoteHandler.class);
|
||||
@ -27,6 +26,8 @@ public class VoteHandler {
|
||||
* being ghostified.
|
||||
*
|
||||
* @param passengers: passengers on the train
|
||||
* @param game the game the votehandler is in
|
||||
* @return returns a gameover message
|
||||
*/
|
||||
|
||||
public String ghostVote(Passenger[] passengers, Game game) {
|
||||
@ -124,6 +125,7 @@ public class VoteHandler {
|
||||
* @return Returns an empty String by default, returns a complex string when game is over:
|
||||
* "Game over: ghosts win!" or "Game over: humans win!"
|
||||
* @param passengers train passengers
|
||||
* @param game the game the Votehandler is in
|
||||
*/
|
||||
public String humanVote(Passenger[] passengers, Game game) {
|
||||
LOGGER.info(game.getGameState().toString());
|
||||
|
||||
@ -48,6 +48,7 @@ public class GhostNPC extends Ghost {
|
||||
/**
|
||||
* Sets vote of this Ghost position on a number between 0 and 5,
|
||||
* but only for positions where there aren't any ghosts and sets hasVoted to true
|
||||
* @param game the Game the NPC lives on
|
||||
* TODO: Make NPC smarter
|
||||
*/
|
||||
public void vote(Game game) {
|
||||
|
||||
@ -18,6 +18,7 @@ public class GhostPlayer extends Ghost {
|
||||
* @param position position on the train
|
||||
* @param name name. if null, then a default name is used.
|
||||
* @param isOG true if the ghost is the original ghost.
|
||||
* @param clientHandler the clientHandler connecting this Player to a Client
|
||||
*/
|
||||
public GhostPlayer(int position, String name, ClientHandler clientHandler, boolean isOG) {
|
||||
this.position = position;
|
||||
|
||||
@ -46,8 +46,7 @@ public class HumanNPC extends Human {
|
||||
/**
|
||||
* Currently returns a random integer for voting, but only for passengers that haven't been
|
||||
* kicked off yet
|
||||
*
|
||||
* @return integer between 0 and 5
|
||||
* @param game the game this NPC lives on
|
||||
*/
|
||||
public void vote(Game game) {
|
||||
Passenger[] passengers = game.getGameState().getPassengerTrain();
|
||||
|
||||
@ -18,6 +18,8 @@ public class HumanPlayer extends Human {
|
||||
* ghost.
|
||||
* @param position position on the train
|
||||
* @param name name. if null, then a default name is used.
|
||||
* @param clientHandler the clienthandler connection this Passenger to a client
|
||||
* @param isOG the boolean defining if this is the Og ghost
|
||||
*/
|
||||
public HumanPlayer(int position, String name, ClientHandler clientHandler, boolean isOG) {
|
||||
this.position = position;
|
||||
|
||||
@ -124,6 +124,7 @@ public class Passenger {
|
||||
|
||||
/**
|
||||
* true if passenger is a spectator
|
||||
* @return isSpectator
|
||||
*/
|
||||
public boolean getIsSpectator() {
|
||||
return isSpectator;
|
||||
@ -155,6 +156,8 @@ public class Passenger {
|
||||
|
||||
/**
|
||||
* When called by NPC nothing should happen, because clientHandler = null
|
||||
* @param game the game the VoteData belongs to
|
||||
* @param clientVoteData the VoteData
|
||||
*/
|
||||
public void getVoteFromGameState(ClientVoteData clientVoteData,Game game) {
|
||||
LOGGER.debug("a NPC called this method hopefully: " + position);
|
||||
@ -163,6 +166,7 @@ public class Passenger {
|
||||
/**
|
||||
* Sends a protocol message to the respective player or NPC.
|
||||
* @param msg the message that is sent to this player.
|
||||
* @param game the game the Passenger lives on
|
||||
**/
|
||||
public void send(String msg, Game game) {
|
||||
if (isPlayer) {
|
||||
|
||||
@ -105,6 +105,7 @@ public class Client {
|
||||
|
||||
/**
|
||||
* Tells user to enter a position to vote for passenger at that position
|
||||
* @param msg the message containing the position
|
||||
*/
|
||||
public void positionSetter(String msg) {
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ public class MessageFormatter {
|
||||
* handle it (see Protocol.java). May need to be redesigned once the game uses a GUI.
|
||||
*
|
||||
* @param msg the Messaged to be reformatted
|
||||
* @param position the position the client is in
|
||||
* @return the reformatted message in the form HEADR$msg
|
||||
*/
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ public class ClientPinger implements Runnable {
|
||||
/**
|
||||
* @param socket the socket the Client is connected to which is used to end the thread if the
|
||||
* connection is lost.
|
||||
* @param client the client the pinger is related to
|
||||
*/
|
||||
public ClientPinger(Client client, Socket socket) {
|
||||
gotPingBack = false;
|
||||
|
||||
@ -86,7 +86,7 @@ public class Protocol {
|
||||
public static final String clientQuitRequest = "QUITR";
|
||||
|
||||
/**
|
||||
* Client sends this message when they want to create a new lobby (& automatically join it).
|
||||
* Client sends this message when they want to create a new lobby (and automatically join it).
|
||||
* Client issues this command in {@link ch.unibas.dmi.dbis.cs108.multiplayer.client.MessageFormatter}
|
||||
* using "/g".
|
||||
* First a lobby {@link Lobby} is created of which the requesting client is the admin of.
|
||||
|
||||
@ -27,6 +27,7 @@ public class ServerPinger implements Runnable {
|
||||
/**
|
||||
* @param socket the socket the ClientHandler is connected to; used to end the thread if the
|
||||
* connection is closed.
|
||||
* @param c the ClientHandler handeling the Client this pinger pings to
|
||||
*/
|
||||
public ServerPinger(Socket socket, ClientHandler c) {
|
||||
gotPingBack = false;
|
||||
|
||||
@ -156,6 +156,7 @@ public class ClientHandler implements Runnable {
|
||||
/**
|
||||
* Returns the Lobby this ClientHandler is in. If this ClientHandler is not in a Lobby, it returns
|
||||
* null.
|
||||
* @return the Lobby this clientHandler lives in
|
||||
*/
|
||||
public Lobby getLobby() {
|
||||
try {
|
||||
@ -205,7 +206,7 @@ public class ClientHandler implements Runnable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts a chat Message to all clients across all lobbies & clients who are not in a lobby in
|
||||
* Broadcasts a chat Message to all clients across all lobbies and clients who are not in a lobby in
|
||||
* the form "Username: @msg"
|
||||
*
|
||||
* @param msg the Message to be broadcast
|
||||
@ -260,6 +261,7 @@ public class ClientHandler implements Runnable {
|
||||
* sent the message that it has been sent. Syntax:
|
||||
*
|
||||
* @param target MUST NOT BE NULL!
|
||||
* @param msg the message being whisperd
|
||||
*/
|
||||
public void whisper(String msg, ClientHandler target) {
|
||||
target.sendMsgToClient(
|
||||
@ -367,13 +369,14 @@ public class ClientHandler implements Runnable {
|
||||
* Sends an announcement to just this client. Essentially the same as broadcastAnnouncementToAll
|
||||
* except it only sends an announcement to just this client instead of everyone. Can be used for
|
||||
* private non-chat messages (e.g. "You are now a ghost").
|
||||
* @param msg the message being announced
|
||||
*/
|
||||
public void sendAnnouncementToClient(String msg) {
|
||||
sendMsgToClient(Protocol.printToClientConsole + "$" + msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes & disconnects the client. To be used if a severe connection loss is detected (i.e. if
|
||||
* Removes and disconnects the client. To be used if a severe connection loss is detected (i.e. if
|
||||
* trying to send / receive a message throws an exception, not just if ping-pong detects a
|
||||
* connection loss). This is very similar to removeClientOnLogout(), however
|
||||
* removeClientOnLogout() should only be used for regular quitting, since removeClientOnLogout()
|
||||
|
||||
@ -102,6 +102,8 @@ public class Lobby {
|
||||
* Returns the lobby with the desired LobbyID.
|
||||
* For example, getLobbyFromID(5) returns the lobby whose LobbyID is 5.
|
||||
* If no such lobby exists, it returns null.
|
||||
* @param i the Lobby ID you are looking for
|
||||
* @return the Lobby with i as its ID
|
||||
*/
|
||||
public static Lobby getLobbyFromID(int i) {
|
||||
for (Lobby l: lobbies) {
|
||||
@ -148,6 +150,8 @@ public class Lobby {
|
||||
/**
|
||||
* Returns the ID of the lobby that the client is in. If the client is not in any
|
||||
* lobby, it returns -1.
|
||||
* @param h ClientHandler that the corresponding Lobby is searched for
|
||||
* @return the Lobby ID
|
||||
*/
|
||||
public static int clientIsInLobby(ClientHandler h) {
|
||||
for (Lobby l: lobbies) {
|
||||
@ -164,6 +168,7 @@ public class Lobby {
|
||||
* Adds a player to the lobby. Returns true if successful.
|
||||
* TODO: add an appropriate response. Currently hardcoded.
|
||||
* @param client who wants to join the lobby.
|
||||
* @return true if successful
|
||||
*/
|
||||
public synchronized boolean addPlayer(ClientHandler client) {
|
||||
if (getLobbyIsOpen()) {
|
||||
@ -204,6 +209,7 @@ public class Lobby {
|
||||
|
||||
/**
|
||||
* Adds game to list of running games and sets its lobby's gameIsRunning to true.
|
||||
* @param game the game to be added
|
||||
*/
|
||||
public void addGameToRunningGames(Game game) {
|
||||
game.getLobby().gameIsRunning = true;
|
||||
@ -212,6 +218,7 @@ public class Lobby {
|
||||
|
||||
/**
|
||||
* Removes game from list of running games and sets its lobby's gameIsRunning to false.
|
||||
* @param game the game to be removed
|
||||
*/
|
||||
public void removeGameFromRunningGames(Game game) {
|
||||
game.getLobby().gameIsRunning = false;
|
||||
|
||||
@ -52,6 +52,8 @@ public class nameDuplicateChecker {
|
||||
* If that name is already used by some other ClientHandler, it returns the name with some suffix.
|
||||
* Also, any ":" or "$" are removed, so they can be used for whisper chat.
|
||||
* Also, if the name is empty, it assigns a default value ("U.N. Owen").
|
||||
* @param name the name that is checked for
|
||||
* @return returns either just the name or added some suffix
|
||||
*/
|
||||
public static String checkName(String name) {
|
||||
String tempname = name; //if this line is used, only duplicate names get a suffix.
|
||||
|
||||
Reference in New Issue
Block a user