game over prompts game over music, groundwork laid for human vote result music, ghost volume adjusted.

This commit is contained in:
Jonas 2022-05-16 21:21:40 +02:00
parent c1af75e2ed
commit 2d6e15a39f
5 changed files with 42 additions and 3 deletions

View File

@ -172,6 +172,14 @@ public class Game implements Runnable {
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) && getOgGhost().getIsPlayer()) { if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) && getOgGhost().getIsPlayer()) {
OgGhostHighScore.addOgGhostWinner(getOgGhost().getName()); OgGhostHighScore.addOgGhostWinner(getOgGhost().getName());
} }
//send command to play game over sound:
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin)) {
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.playSound + "$" + "GW");
} else {
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.playSound + "$" + "HW");
}
lobby.getAdmin().broadcastAnnouncementToLobby(gameOverCheck); lobby.getAdmin().broadcastAnnouncementToLobby(gameOverCheck);
isOngoing = false; isOngoing = false;
Timer.ghostAfterVoteTimer(); Timer.ghostAfterVoteTimer();

View File

@ -91,6 +91,23 @@ public class JClientProtocolParser {
case Protocol.noiseNotificationProtocol: case Protocol.noiseNotificationProtocol:
Sound.ghost(); Sound.ghost();
break; break;
case Protocol.playSound:
switch (msg.substring(6)) {
case "GW":
Sound.gameoverghosts();
break;
case "HW":
Sound.gameoverhumans();
break;
case "GV":
Sound.voteforghost();
break;
case "HV":
Sound.voteforhuman();
break;
default:
LOGGER.warn("Invalid sound request");
}
default: default:
System.out.println("Received unknown command: " + msg); System.out.println("Received unknown command: " + msg);
} }

View File

@ -97,7 +97,14 @@ public class Sound {
public static void gameoverghosts() { gameoverghosts.play(defaultvolume); } public static void gameoverghosts() { gameoverghosts.play(defaultvolume); }
public static void gameoverhumans() { gameoverhumans.play(defaultvolume); } public static void gameoverhumans() {
stopmusicday();
gameoverhumans.play(defaultvolume);
}
public static void voteforghost() { voteforghost.play(defaultvolume); }
public static void voteforhuman() { voteforhuman.play(defaultvolume); }
public static void musicday() { public static void musicday() {
musicday.play(defaultvolume); musicday.play(defaultvolume);
@ -127,7 +134,7 @@ public class Sound {
ghost = ghost04; ghost = ghost04;
break; break;
} }
ghost.play(defaultvolume - 0.3, 0.0, playbackspeed, 0.0, 5); ghost.play(0.1, 0.0, playbackspeed, 0.0, 5);
} }
} }

View File

@ -40,7 +40,7 @@ public class GameController implements Initializable {
public static final Logger LOGGER = LogManager.getLogger(GameController.class); public static final Logger LOGGER = LogManager.getLogger(GameController.class);
public static final BudaLogConfig l = new BudaLogConfig(LOGGER); public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
static boolean justRangBell = false; //used to track if the bell has been rung recently static boolean justRangBell = false; //used to track if the bell has been rung recently
static final int minimumBellTime = 1000; //minimal time that has to pass between bells, in ms static final int minimumBellTime = 100; //minimal time that has to pass between bells, in ms
static boolean playingDayNoises = true; //true if playing day noises, false if playing night noises static boolean playingDayNoises = true; //true if playing day noises, false if playing night noises
private static ClientModel client; private static ClientModel client;

View File

@ -212,6 +212,13 @@ public class Protocol {
*/ */
public static final String noiseNotificationProtocol = "NOISE"; public static final String noiseNotificationProtocol = "NOISE";
/**
* Used to tell the client to play a sound, namely the sounds for when humans have voted for a human (PLSND$HV),
* when humans have voted for a ghost (PLSND$GV), when humans have won (i.e. have voted for the OG - PLSND$HW)
* or when ghosts have won (PLSND$GW)
*/
public static final String playSound = "PLSND";
/** /**
* Sends an information to client at which position in the train from the game (0 to 5) they sit, as soon as the game starts * Sends an information to client at which position in the train from the game (0 to 5) they sit, as soon as the game starts
* {@code POSOF$position} * {@code POSOF$position}