diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/Ghost.java b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/Ghost.java new file mode 100644 index 0000000..9e5fc16 --- /dev/null +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/Ghost.java @@ -0,0 +1,9 @@ +package ch.unibas.dmi.dbis.cs108.Klassenstruktur; + +public class Ghost extends Passenger { + protected boolean isOG; //true if the Ghost is the original ghost. + + public boolean getIsOG() { + return isOG; + } +} diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/GhostNPC.java b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/GhostNPC.java new file mode 100644 index 0000000..7d80968 --- /dev/null +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/GhostNPC.java @@ -0,0 +1,22 @@ +package ch.unibas.dmi.dbis.cs108.Klassenstruktur; + +public class GhostNPC extends Ghost{ + + /** + * 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.sock = null; + isGhost = true; + isPlayer = false; + kickedOff = false; + if (name == null) { + this.name = "Robot Nr. " + position; + } else this.name = name; + } +} diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/GhostPlayer.java b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/GhostPlayer.java new file mode 100644 index 0000000..3ee1b9c --- /dev/null +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/GhostPlayer.java @@ -0,0 +1,29 @@ +package ch.unibas.dmi.dbis.cs108.Klassenstruktur; + +import java.net.Socket; + +public class GhostPlayer extends Ghost{ + + /** + * 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 sock the socket for the player. + * @param isOG true if the ghost is the original ghost. + */ + public GhostPlayer(int position, String name, Socket sock, boolean isOG) { + this.position = position; + this.sock = sock; + this.isOG = isOG; + isGhost = true; + isPlayer = true; + kickedOff = false; + if (name == null) { + this.name = "Human Nr. " + position; + } else this.name = name; + } + + public void send(String msg) { + //todo: pass message along to client. + } +} diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/Human.java b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/Human.java new file mode 100644 index 0000000..eeda085 --- /dev/null +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/Human.java @@ -0,0 +1,4 @@ +package ch.unibas.dmi.dbis.cs108.Klassenstruktur; + +public class Human extends Passenger { +} diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/HumanNPC.java b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/HumanNPC.java new file mode 100644 index 0000000..87c47cd --- /dev/null +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/HumanNPC.java @@ -0,0 +1,5 @@ +package ch.unibas.dmi.dbis.cs108.Klassenstruktur; + +public class HumanNPC extends Human { + +} diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/HumanPlayer.java b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/HumanPlayer.java new file mode 100644 index 0000000..f968ac9 --- /dev/null +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/HumanPlayer.java @@ -0,0 +1,4 @@ +package ch.unibas.dmi.dbis.cs108.Klassenstruktur; + +public class HumanPlayer extends Human{ +} diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/Passenger.java b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/Passenger.java new file mode 100644 index 0000000..e53eccf --- /dev/null +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/Klassenstruktur/Passenger.java @@ -0,0 +1,58 @@ +package ch.unibas.dmi.dbis.cs108.Klassenstruktur; + +import java.net.Socket; + +public class Passenger { + protected int position; //the player's Cabin number (1 to 6) + 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 Socket sock; //the socket for the client associated with this Passenger, for NPCs, this can be null. + //todo: maybe this should be a thread or some class instead of a socket? depends on client-server structure... + + + /** + * 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 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; + } +}