Moved klassenstruktur into gamelogic
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class Ghost extends Passenger {
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
protected boolean isOG; //true if the Ghost is the original ghost.
|
||||
|
||||
public boolean getIsOG() {
|
||||
return isOG;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class GhostNPC extends Ghost {
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
/**
|
||||
* Creates a new GhostNPC. Should be used at game start or if a HumanNPC is turned into a ghost.
|
||||
*
|
||||
* @param position position on the train
|
||||
* @param name player name. if null, then a default name is used.
|
||||
* @param isOG true if the ghost is the original ghost.
|
||||
*/
|
||||
public GhostNPC(int position, String name, boolean isOG) {
|
||||
this.isOG = isOG;
|
||||
this.position = position;
|
||||
this.clientHandler = null;
|
||||
isGhost = true;
|
||||
isPlayer = false;
|
||||
kickedOff = false;
|
||||
if (name == null) {
|
||||
this.name = "Robot Nr. " + position;
|
||||
} else {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class GhostPlayer extends Ghost {
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
/**
|
||||
* Creates a new GhostPlayer. Should be used at game start or if a HumanPlayer is turned into a
|
||||
* 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.
|
||||
*/
|
||||
public GhostPlayer(int position, String name, ClientHandler clientHandler, boolean isOG) {
|
||||
this.position = position;
|
||||
this.clientHandler = clientHandler;
|
||||
this.isOG = isOG;
|
||||
isGhost = true;
|
||||
isPlayer = true;
|
||||
kickedOff = false;
|
||||
if (name == null) {
|
||||
this.name = "Player Nr. " + position;
|
||||
} else {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void send(String msg) {
|
||||
//todo(Jonas): pass message along to client.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class Human extends Passenger {
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class HumanNPC extends Human {
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
/**
|
||||
* Creates a new HumanNPC.
|
||||
*
|
||||
* @param position position on the train
|
||||
* @param name player name. if null, then a default name is used.
|
||||
*/
|
||||
public HumanNPC(int position, String name) {
|
||||
this.position = position;
|
||||
this.clientHandler = null;
|
||||
isGhost = false;
|
||||
isPlayer = false;
|
||||
kickedOff = false;
|
||||
if (name == null) {
|
||||
this.name = "Robot Nr. " + position;
|
||||
} else {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class HumanPlayer extends Human {
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
/**
|
||||
* Creates a new GhostPlayer. Should be used at game start or if a HumanPlayer is turned into a
|
||||
* ghost.
|
||||
*
|
||||
* @param position position on the train
|
||||
* @param name name. if null, then a default name is used.
|
||||
*/
|
||||
public HumanPlayer(int position, String name, ClientHandler clientHandler, boolean isOG) {
|
||||
this.position = position;
|
||||
this.clientHandler = clientHandler;
|
||||
isGhost = false;
|
||||
isPlayer = true;
|
||||
kickedOff = false;
|
||||
if (name == null) {
|
||||
this.name = "Player Nr. " + position;
|
||||
} else {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class Passenger {
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
protected int position; //the player's Cabin number (0 to 5)
|
||||
protected String name; //the player's Name
|
||||
protected Boolean isGhost; //boolean regarding if the player is a ghost. Could probably be removed since ghost is a subclass but I'm keeping it in.
|
||||
protected Boolean isPlayer; //same here
|
||||
protected Boolean kickedOff; //true if the player has been voted off.
|
||||
protected ClientHandler clientHandler; //the socket for the client associated with this Passenger, for NPCs, this can be null.
|
||||
|
||||
/**
|
||||
* Sends a protocol message to the respective player.
|
||||
*
|
||||
* @param msg the message that is sent to this player.
|
||||
**/
|
||||
public void send(String msg) {
|
||||
//todo: send protocol message to the respective client OR process messages for NPCS
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the Position of this passenger
|
||||
*
|
||||
* @param position the position of this passenger
|
||||
*/
|
||||
public void setPosition(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the name of this passenger.
|
||||
*
|
||||
* @param name the new name for this passenger.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the kickedOff status of this Passenger
|
||||
*
|
||||
* @param kickedOff should be set to true if the passenger has been kicked off.
|
||||
*/
|
||||
public void setKickedOff(boolean kickedOff) {
|
||||
this.kickedOff = kickedOff;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Boolean getIsGhost() {
|
||||
return isGhost;
|
||||
}
|
||||
|
||||
public Boolean getKickedOff() {
|
||||
return kickedOff;
|
||||
}
|
||||
|
||||
public Boolean getIsPlayer() {
|
||||
return isPlayer;
|
||||
}
|
||||
|
||||
public ClientHandler getClientHandler() {
|
||||
return clientHandler;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user