Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
47f808bcab
@ -282,6 +282,10 @@ eine Stimme abgeben und sie wird gezählt, NPC können sehr stupide stimmen abge
|
|||||||
Server schickt dem Client bei einem Voterequest immer seine Position im Zug mit, und der client schickt
|
Server schickt dem Client bei einem Voterequest immer seine Position im Zug mit, und der client schickt
|
||||||
sie dem Server wieder zurück.
|
sie dem Server wieder zurück.
|
||||||
|
|
||||||
|
11 & 12.04.2022 - Jonas
|
||||||
|
Implementation aller notwendigen Lobby - funktionen, list-commands, sowie whisper chat.
|
||||||
|
|
||||||
|
|
||||||
13.04.2022 - Seraina
|
13.04.2022 - Seraina
|
||||||
Spiellogik: Habe Alexs noiseHandling in die restliche Spiellogik integriert und debugged. Ebenso musste
|
Spiellogik: Habe Alexs noiseHandling in die restliche Spiellogik integriert und debugged. Ebenso musste
|
||||||
ich den Input der Clients beim Abstimmen geben umstrukturieren. Anstatt dass eine speziefische Methode
|
ich den Input der Clients beim Abstimmen geben umstrukturieren. Anstatt dass eine speziefische Methode
|
||||||
@ -318,5 +322,10 @@ Im GUI funktioniert der Whisper nun. Folgendes Colorcoding: Eigene Nachrichten s
|
|||||||
und im Momentan Whisper Nachrichten violet.
|
und im Momentan Whisper Nachrichten violet.
|
||||||
|
|
||||||
18.04.2022 - Seraina
|
18.04.2022 - Seraina
|
||||||
Nach etlichem lesen von Websites zu custom tasks in gradle habe ich entlich die build-cs108 task zum Laufen
|
Nach etlichem Lesen von Websites zu custom tasks in gradle habe ich endlich die build-cs108 task zum Laufen
|
||||||
gebracht. Es war wie so oft die einfachste Lösung.
|
gebracht. Es war wie so oft die einfachste Lösung.
|
||||||
|
|
||||||
|
18.04.2022 - Alex
|
||||||
|
- Aktualisierung des Projektplans für Meilensteine 4 und 5 abgeschlossen (hochgeladen als pdf und xls)
|
||||||
|
- Änderung des NoiseHandlers: Nun werden human players, selbst wenn nachts mehrmals Geister an ihnen vorbeilaufen, nur einmal benachrichtigt.
|
||||||
|
- Abschliessende Arbeit am Manual.
|
||||||
|
|||||||
Binary file not shown.
@ -19,7 +19,7 @@ public class BudaLogConfig {
|
|||||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
Configuration config = ctx.getConfiguration();
|
Configuration config = ctx.getConfiguration();
|
||||||
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
|
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
|
||||||
loggerConfig.setLevel(Level.INFO); // change level here
|
loggerConfig.setLevel(Level.ERROR); // change level here
|
||||||
ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig.
|
ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public class ClientGameInfoHandler {
|
|||||||
//relevant:
|
//relevant:
|
||||||
public static final String ghostVoteRequest = "Vote on who to ghostify!";
|
public static final String ghostVoteRequest = "Vote on who to ghostify!";
|
||||||
public static final String humanVoteRequest = "Vote for a ghost to kick off!";
|
public static final String humanVoteRequest = "Vote for a ghost to kick off!";
|
||||||
public static final String noiseNotification = "You heard some noise";
|
public static final String noiseNotification = "Someone passed by you ";
|
||||||
public static final String gameOverHumansWin = "Game over: humans win!";
|
public static final String gameOverHumansWin = "Game over: humans win!";
|
||||||
public static final String gameOverGhostsWin = "Game over: ghosts win!";
|
public static final String gameOverGhostsWin = "Game over: ghosts win!";
|
||||||
|
|
||||||
|
|||||||
@ -109,7 +109,7 @@ public class Game implements Runnable {
|
|||||||
LOGGER.info(gameState.toString());
|
LOGGER.info(gameState.toString());
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (isOngoing == true) {//game cycle
|
while (isOngoing) {//game cycle
|
||||||
if (!isDay) {
|
if (!isDay) {
|
||||||
LOGGER.info("NIGHT");
|
LOGGER.info("NIGHT");
|
||||||
gameOverCheck = voteHandler.ghostVote(gameState.getPassengerTrain(), this);
|
gameOverCheck = voteHandler.ghostVote(gameState.getPassengerTrain(), this);
|
||||||
|
|||||||
@ -8,30 +8,32 @@ import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
|
|||||||
* and broadcasts noise message to them (via ServerGameInfoHandler)
|
* and broadcasts noise message to them (via ServerGameInfoHandler)
|
||||||
*/
|
*/
|
||||||
public class NoiseHandler {
|
public class NoiseHandler {
|
||||||
/**
|
/** Updates the amount of times passengers on the train heard ghosts walk by them. Differentiates between two
|
||||||
* Notifies passengers in the train about a ghost walking by them. Differentiates between two
|
|
||||||
* cases: if the active ghost (predator) is to the right of his victim, the Passenger array is
|
* cases: if the active ghost (predator) is to the right of his victim, the Passenger array is
|
||||||
* being walked through from right to left (from the predator's position back to the victim's
|
* being walked through from right to left (from the predator's position back to the victim's
|
||||||
* position), otherwise the other way around. One call of noiseNotifier only deals with one
|
* position), otherwise the other way around. One call of noiseNotifier only deals with one
|
||||||
* predator infecting a victim, so if there are already multiple ghosts in the game, the method
|
* predator infecting a victim, so if there are already multiple ghosts in the game, the method
|
||||||
* should be called for each of them individually.
|
* should be called for each of them individually.
|
||||||
*
|
|
||||||
* @param passengers passengers of the train the game is played in
|
* @param passengers passengers of the train the game is played in
|
||||||
* @param predator ghost that has infected a human player during this night (called upon as
|
* @param predator ghost that has infected a human player during this night (called upon as
|
||||||
* passenger for convenience reasons)
|
* passenger for convenience reasons)
|
||||||
* @param victim human player who has been turned into a ghost this night
|
* @param victim human player who has been turned into a ghost this night
|
||||||
|
* @param noiseAmount array containing information about how many times each passenger heard a noise this night
|
||||||
* @param game current game instance
|
* @param game current game instance
|
||||||
|
* @return updated array with info on who heard how many noises
|
||||||
*/
|
*/
|
||||||
public void noiseNotifier(Passenger[] passengers, Passenger predator, Passenger victim, Game game) {
|
public int[] noiseNotifier(Passenger[] passengers, Passenger predator, Passenger victim, int[] noiseAmount, Game game) {
|
||||||
if (predator.getPosition() - victim.getPosition()
|
if (predator.getPosition() - victim.getPosition()
|
||||||
> 0) { // if predator is to the right of victim
|
> 0) { // if predator is to the right of victim
|
||||||
for (int i = predator.getPosition() - 1; i > victim.getPosition(); i--) {
|
for (int i = predator.getPosition() - 1; i > victim.getPosition(); i--) {
|
||||||
passengers[i].send(ClientGameInfoHandler.noiseNotification, game);
|
noiseAmount[i]++;
|
||||||
}
|
}
|
||||||
} else { // if predator is to the left of victim
|
} else { // if predator is to the left of victim
|
||||||
for (int i = predator.getPosition() + 1; i < victim.getPosition(); i++) {
|
for (int i = predator.getPosition() + 1; i < victim.getPosition(); i++) {
|
||||||
passengers[i].send(ClientGameInfoHandler.noiseNotification, game);
|
noiseAmount[i]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return noiseAmount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,14 +88,25 @@ public class VoteHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* notify passengers the ghosts passed by - for each ghost that ghostified a player, an instance of NoiseHandler
|
/* notify passengers the ghosts passed by - for each ghost that ghostified a player, an instance of NoiseHandler
|
||||||
is being created and the passengers this ghost passed by are being notified. The player who's just been ghostified
|
is being created and the array containing the information about the amount of times each passenger heard a ghost
|
||||||
is ignored since he didn't participate in this night's ghostification. */
|
walk by is being updated. Finally, each passenger receives information about how often he heard something during
|
||||||
|
this night. The player who's just been ghostified is ignored since he didn't participate in this night's
|
||||||
|
ghostification. */
|
||||||
|
|
||||||
|
int[] noiseAmount = new int[6];
|
||||||
for (int i = 0; i < passengers.length; i++) {
|
for (int i = 0; i < passengers.length; i++) {
|
||||||
if (passengers[i].getIsGhost() && i != ghostPosition) {
|
if (passengers[i].getIsGhost() && i != ghostPosition) {
|
||||||
NoiseHandler n = new NoiseHandler();
|
NoiseHandler n = new NoiseHandler();
|
||||||
n.noiseNotifier(passengers, passengers[i], g, game);
|
noiseAmount = n.noiseNotifier(passengers, passengers[i], g, noiseAmount, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < passengers.length; i++) {
|
||||||
|
if (!passengers[i].getIsGhost() && noiseAmount[i] != 0) { // passenger is human and someone walked by him
|
||||||
|
passengers[i].send(ClientGameInfoHandler.noiseNotification + noiseAmount[i] + " time(s)", game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no humans left in the game --> everyone has been ghostified, ghosts win
|
||||||
int humanCounter = 0;
|
int humanCounter = 0;
|
||||||
for(Passenger passenger : passengers) {
|
for(Passenger passenger : passengers) {
|
||||||
if(!passenger.getIsGhost()) { //if it is a human
|
if(!passenger.getIsGhost()) { //if it is a human
|
||||||
@ -108,7 +119,7 @@ public class VoteHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.info(game.getGameState().toString());
|
LOGGER.info(game.getGameState().toString());
|
||||||
// set hasVoted to false for all passengers for future votings
|
// set hasVoted to false for all passengers for future voting
|
||||||
for (Passenger passenger : passengers) {
|
for (Passenger passenger : passengers) {
|
||||||
passenger.setHasVoted(false);
|
passenger.setHasVoted(false);
|
||||||
passenger.setVote(Integer.MAX_VALUE);
|
passenger.setVote(Integer.MAX_VALUE);
|
||||||
|
|||||||
@ -217,9 +217,13 @@ public class ClientHandler implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public void broadcastChatMessageToAll(String msg) {
|
public void broadcastChatMessageToAll(String msg) {
|
||||||
for (ClientHandler client : connectedClients) {
|
for (ClientHandler client : connectedClients) {
|
||||||
|
|
||||||
|
// we can un-comment this if we want broadcast to only send to everyone else, excluding the person who sent it.
|
||||||
|
/*
|
||||||
if (client.getClientUserName().equals(this.getClientUserName())) {
|
if (client.getClientUserName().equals(this.getClientUserName())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
client.sendMsgToClient(Protocol.printToClientChat + "$" + clientUserName + ": " + msg);
|
client.sendMsgToClient(Protocol.printToClientChat + "$" + clientUserName + ": " + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -459,6 +463,8 @@ public class ClientHandler implements Runnable {
|
|||||||
Game game = l.getGame();
|
Game game = l.getGame();
|
||||||
if (game != null) {
|
if (game != null) {
|
||||||
l.getGame().getGameState().handleClientDisconnect(this);
|
l.getGame().getGameState().handleClientDisconnect(this);
|
||||||
|
l.removeGameFromRunningGames(game);
|
||||||
|
l.addGameToFinishedGames(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -523,13 +529,19 @@ public class ClientHandler implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all Games currenty running and already finished and displays it to the client handled by
|
* Lists all Games currently running and already finished and displays it to the client handled by
|
||||||
* this
|
* this
|
||||||
*/
|
*/
|
||||||
public void listGames() {
|
public void listGames() {
|
||||||
if (Lobby.runningGames.isEmpty() && Lobby.finishedGames.isEmpty()) {
|
if (Lobby.runningGames.isEmpty() && Lobby.finishedGames.isEmpty() && Lobby.lobbies.isEmpty()) {
|
||||||
sendAnnouncementToClient("No Games");
|
sendAnnouncementToClient("No Games");
|
||||||
} else {
|
} else {
|
||||||
|
sendAnnouncementToClient("Open Games (i.e. open Lobbies):");
|
||||||
|
for (Lobby l : Lobby.lobbies) {
|
||||||
|
if (l.getLobbyIsOpen()) {
|
||||||
|
sendAnnouncementToClient(" - Lobby Nr. " + l.getLobbyID());
|
||||||
|
}
|
||||||
|
}
|
||||||
sendAnnouncementToClient("Running Games:");
|
sendAnnouncementToClient("Running Games:");
|
||||||
try {
|
try {
|
||||||
for (Game runningGame : Lobby.runningGames) {
|
for (Game runningGame : Lobby.runningGames) {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public class JServerProtocolParser {
|
|||||||
try {
|
try {
|
||||||
header = msg.substring(0, 5);
|
header = msg.substring(0, 5);
|
||||||
if (!header.equals(Protocol.pingBack) && !header.equals(
|
if (!header.equals(Protocol.pingBack) && !header.equals(
|
||||||
Protocol.pingFromClient)) { //for debuging without constant pings
|
Protocol.pingFromClient)) { //for debugging without constant pings
|
||||||
LOGGER.debug("got message: " + msg + ".");
|
LOGGER.debug("got message: " + msg + ".");
|
||||||
}
|
}
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user