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:
@@ -19,7 +19,7 @@ public GameStates(ClientState parent, ClientGameLogic logic) {
|
|||||||
|
|
||||||
protected void handlePowerCard(PlayCardMessage msg) {
|
protected void handlePowerCard(PlayCardMessage msg) {
|
||||||
if (msg.getCard().equals(BonusCard.TURBO)) {
|
if (msg.getCard().equals(BonusCard.TURBO)) {
|
||||||
//logic.getGame().setDiceModifier(msg.getDiceModifier());
|
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||||
} else if (msg.getCard().equals(BonusCard.SHIELD)) {
|
} else if (msg.getCard().equals(BonusCard.SHIELD)) {
|
||||||
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
|
if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
|
||||||
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
|
logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ public void received(DiceNowMessage msg) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(DieMessage msg) {
|
public void received(DieMessage msg) {
|
||||||
// logic.getGame().setDiceEyes(msg.getDiceEye());
|
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||||
// logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
|
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes()));
|
||||||
if (msg.getDiceEye() == 6) {
|
if (msg.getDiceEye() == 6) {
|
||||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
|
||||||
logic.getGame().getGameStatistics().increaseDiced6();
|
logic.getGame().getGameStatistics().increaseDiced6();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
||||||
import pp.mdga.game.Player;
|
import pp.mdga.game.Player;
|
||||||
import pp.mdga.message.client.AnimationEndMessage;
|
import pp.mdga.message.client.AnimationEndMessage;
|
||||||
|
import pp.mdga.notification.ActivePlayerNotification;
|
||||||
import pp.mdga.notification.MovePieceNotification;
|
import pp.mdga.notification.MovePieceNotification;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -73,8 +74,10 @@ public void selectAnimationEnd(){
|
|||||||
logic.send(new AnimationEndMessage());
|
logic.send(new AnimationEndMessage());
|
||||||
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){
|
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){
|
||||||
parent.getParent().setState(parent.getParent().getTurn());
|
parent.getParent().setState(parent.getParent().getTurn());
|
||||||
|
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
|
||||||
} else {
|
} else {
|
||||||
parent.getParent().setState(parent.getParent().getWaiting());
|
parent.getParent().setState(parent.getParent().getWaiting());
|
||||||
|
logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public void enter() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
//logic.getGame().setDiceModifier(1);
|
logic.getGame().setDiceModifier(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TurnState getParent() {
|
public TurnState getParent() {
|
||||||
@@ -30,7 +30,7 @@ public TurnState getParent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void received(DieMessage msg){
|
public void received(DieMessage msg){
|
||||||
// logic.getGame().setDiceEyes(msg.getDiceEye());
|
logic.getGame().setDiceEyes(msg.getDiceEye());
|
||||||
parent.setState(parent.getChoosePiece());
|
parent.setState(parent.getChoosePiece());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public void selectCard(BonusCard card){
|
|||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg){
|
public void received(PlayCardMessage msg){
|
||||||
if(msg.getCard().equals(BonusCard.TURBO)){
|
if(msg.getCard().equals(BonusCard.TURBO)){
|
||||||
//logic.getGame().setDiceModifier(msg.getDiceModifier());
|
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
||||||
} else {
|
} else {
|
||||||
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
|
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,16 @@ public class Game {
|
|||||||
*/
|
*/
|
||||||
private Color activeColor;
|
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.
|
* This constructor creates a new Game object.
|
||||||
*/
|
*/
|
||||||
@@ -414,4 +424,40 @@ public void setDie(Die die) {
|
|||||||
public void setHost(int host) {
|
public void setHost(int host) {
|
||||||
this.host = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()));
|
this.logic.getServerSender().broadcast(new LobbyPlayerJoinedMessage(entry.getKey(), entry.getValue(), entry.getKey() == this.logic.getGame().getHost()));
|
||||||
|
|
||||||
if(entry.getKey() != from) {
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user