adjusted a broadcast in lobby state to a send to reduce traffic (original commit f1124f32) and removed souts as well as added comments back into the code

This commit is contained in:
Fleischer Hanno
2024-12-05 17:51:18 +01:00
parent f1124f3245
commit cabd98a24a
7 changed files with 56 additions and 7 deletions

View File

@@ -19,7 +19,7 @@ public GameStates(ClientState parent, ClientGameLogic logic) {
protected void handlePowerCard(PlayCardMessage msg) {
if (msg.getCard().equals(BonusCard.TURBO)) {
//logic.getGame().setDiceModifier(msg.getDiceModifier());
logic.getGame().setDiceModifier(msg.getDiceModifier());
} else if (msg.getCard().equals(BonusCard.SHIELD)) {
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);

View File

@@ -40,8 +40,8 @@ public void received(DiceNowMessage msg) {
@Override
public void received(DieMessage msg) {
// logic.getGame().setDiceEyes(msg.getDiceEye());
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
logic.getGame().setDiceEyes(msg.getDiceEye());
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes()));
if (msg.getDiceEye() == 6) {
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6();

View File

@@ -5,6 +5,7 @@
import pp.mdga.client.gamestate.DetermineStartPlayerState;
import pp.mdga.game.Player;
import pp.mdga.message.client.AnimationEndMessage;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.MovePieceNotification;
import java.util.Map;
@@ -73,8 +74,10 @@ public void selectAnimationEnd(){
logic.send(new AnimationEndMessage());
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){
parent.getParent().setState(parent.getParent().getTurn());
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
} else {
parent.getParent().setState(parent.getParent().getWaiting());
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
}
}
}

View File

@@ -22,7 +22,7 @@ public void enter() {
@Override
public void exit() {
//logic.getGame().setDiceModifier(1);
logic.getGame().setDiceModifier(1);
}
public TurnState getParent() {
@@ -30,7 +30,7 @@ public TurnState getParent() {
}
public void received(DieMessage msg){
// logic.getGame().setDiceEyes(msg.getDiceEye());
logic.getGame().setDiceEyes(msg.getDiceEye());
parent.setState(parent.getChoosePiece());
}

View File

@@ -80,7 +80,7 @@ public void selectCard(BonusCard card){
@Override
public void received(PlayCardMessage msg){
if(msg.getCard().equals(BonusCard.TURBO)){
//logic.getGame().setDiceModifier(msg.getDiceModifier());
logic.getGame().setDiceModifier(msg.getDiceModifier());
} else {
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
}

View File

@@ -63,6 +63,16 @@ public class Game {
*/
private Color activeColor;
/**
* The dice modifier.
*/
private int diceModifier;
/**
* The number of eyes on the dice.
*/
private int diceEyes;
/**
* This constructor creates a new Game object.
*/
@@ -414,4 +424,40 @@ public void setDie(Die die) {
public void setHost(int host) {
this.host = host;
}
/**
* This method will be used to get the dice eyes.
*
* @return the dice eyes
*/
public int getDiceEyes() {
return diceEyes;
}
/**
* This method is used to get the dice modifier.
*
* @return the dice modifier
*/
public int getDiceModifier() {
return diceModifier;
}
/**
* This method will be used to set the dice eyes.
*
* @param diceEyes the new dice eyes
*/
public void setDiceEyes(int diceEyes) {
this.diceEyes = diceEyes;
}
/**
* This method is used to set the dice modifier.
*
* @param diceModifier the new dice modifier
*/
public void setDiceModifier(int diceModifier) {
this.diceModifier = diceModifier;
}
}

View File

@@ -68,7 +68,7 @@ public void received(JoinedLobbyMessage msg, int from) {
this.logic.getServerSender().broadcast(new LobbyPlayerJoinedMessage(entry.getKey(), entry.getValue(), entry.getKey() == this.logic.getGame().getHost()));
if(entry.getKey() != from) {
this.logic.getServerSender().broadcast(new UpdateReadyMessage(entry.getKey(), entry.getValue().isReady()));
this.logic.getServerSender().send(from, new UpdateReadyMessage(entry.getKey(), entry.getValue().isReady()));
}
}
}