Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ccf36dff19
@ -1,2 +1,2 @@
|
||||
rootProject.name = 'example-project'
|
||||
rootProject.name = 'Night Train to Budapest'
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ public class GhostNPC extends Ghost{
|
||||
public GhostNPC(int position, String name, boolean isOG) {
|
||||
this.isOG = isOG;
|
||||
this.position = position;
|
||||
this.sock = null;
|
||||
this.clientHandler = null;
|
||||
isGhost = true;
|
||||
isPlayer = false;
|
||||
kickedOff = false;
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.Multiplayer.Server.ClientHandler;
|
||||
|
||||
import java.net.Socket;
|
||||
|
||||
public class GhostPlayer extends Ghost{
|
||||
@ -8,12 +10,11 @@ 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) {
|
||||
public GhostPlayer(int position, String name, ClientHandler clientHandler, boolean isOG) {
|
||||
this.position = position;
|
||||
this.sock = sock;
|
||||
this.clientHandler = clientHandler;
|
||||
this.isOG = isOG;
|
||||
isGhost = true;
|
||||
isPlayer = true;
|
||||
|
||||
@ -9,7 +9,7 @@ public class HumanNPC extends Human {
|
||||
*/
|
||||
public HumanNPC(int position, String name) {
|
||||
this.position = position;
|
||||
this.sock = null;
|
||||
this.clientHandler = null;
|
||||
isGhost = false;
|
||||
isPlayer = false;
|
||||
kickedOff = false;
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.Multiplayer.Server.ClientHandler;
|
||||
|
||||
import java.net.Socket;
|
||||
|
||||
public class HumanPlayer extends Human{
|
||||
@ -7,11 +9,10 @@ public class HumanPlayer extends Human{
|
||||
* 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.
|
||||
*/
|
||||
public HumanPlayer(int position, String name, Socket sock, boolean isOG) {
|
||||
public HumanPlayer(int position, String name, ClientHandler clientHandler, boolean isOG) {
|
||||
this.position = position;
|
||||
this.sock = sock;
|
||||
this.clientHandler = clientHandler;
|
||||
isGhost = false;
|
||||
isPlayer = true;
|
||||
kickedOff = false;
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.Multiplayer.Server.ClientHandler;
|
||||
|
||||
import java.net.Socket;
|
||||
|
||||
public class Passenger {
|
||||
@ -8,9 +10,7 @@ public class Passenger {
|
||||
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...
|
||||
|
||||
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.
|
||||
@ -56,4 +56,8 @@ public class Passenger {
|
||||
public Boolean getIsPlayer() {
|
||||
return isPlayer;
|
||||
}
|
||||
|
||||
public ClientHandler getClientHandler() {
|
||||
return clientHandler;
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,6 +47,10 @@ public class ClientHandler implements Runnable{
|
||||
}
|
||||
}
|
||||
|
||||
public String getClientUserName() {
|
||||
return clientUserName;
|
||||
}
|
||||
|
||||
public void broadcastMessage(String msg) {
|
||||
for (ClientHandler client : clientHandlers) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user