reworked ex 8
return to EditorState if map is invalid
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package pp.battleship.game.client;
|
package pp.battleship.game.client;
|
||||||
|
|
||||||
|
import pp.battleship.message.server.GameDetails;
|
||||||
import pp.battleship.message.server.StartBattleMessage;
|
import pp.battleship.message.server.StartBattleMessage;
|
||||||
|
|
||||||
import java.lang.System.Logger.Level;
|
import java.lang.System.Logger.Level;
|
||||||
@@ -38,4 +39,11 @@ public void receivedStartBattle(StartBattleMessage msg) {
|
|||||||
logic.setInfoText(msg.getInfoTextKey());
|
logic.setInfoText(msg.getInfoTextKey());
|
||||||
logic.setState(new BattleState(logic, msg.isMyTurn()));
|
logic.setState(new BattleState(logic, msg.isMyTurn()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receivedGameDetails(GameDetails details) {
|
||||||
|
ClientGameLogic.LOGGER.log(Level.WARNING, "Invalid Map"); //NON-NLS
|
||||||
|
logic.setInfoText("map.invalid");
|
||||||
|
logic.setState(new EditorState(logic));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,8 +142,10 @@ public Player addPlayer(int id) {
|
|||||||
public void received(MapMessage msg, int from) {
|
public void received(MapMessage msg, int from) {
|
||||||
if (state != ServerState.SET_UP)
|
if (state != ServerState.SET_UP)
|
||||||
LOGGER.log(Level.ERROR, "playerReady not allowed in {0}", state); //NON-NLS
|
LOGGER.log(Level.ERROR, "playerReady not allowed in {0}", state); //NON-NLS
|
||||||
else if(!checkMap(msg, from))
|
else if(!checkMap(msg, from)) {
|
||||||
LOGGER.log(Level.ERROR, "The submitted map is not allowed");
|
LOGGER.log(Level.ERROR, "The submitted map is not allowed");
|
||||||
|
send(players.get(from), new GameDetails(config));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
playerReady(getPlayerById(from), msg.getShips());
|
playerReady(getPlayerById(from), msg.getShips());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ dialog.error=Error
|
|||||||
dialog.question=Question
|
dialog.question=Question
|
||||||
port.must.be.integer=Port must be an integer number
|
port.must.be.integer=Port must be an integer number
|
||||||
map.doesnt.fit=The map doesn't fit to this game
|
map.doesnt.fit=The map doesn't fit to this game
|
||||||
|
map.invalid = map is invalid
|
||||||
ships.dont.fit.the.map=Ships are out of bounds
|
ships.dont.fit.the.map=Ships are out of bounds
|
||||||
menu.music.toggle = Music on/off
|
menu.music.toggle = Music on/off
|
||||||
menu.music.volume = Volume
|
menu.music.volume = Volume
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ dialog.error=Fehler
|
|||||||
dialog.question=Frage
|
dialog.question=Frage
|
||||||
port.must.be.integer=Der Port muss eine ganze Zahl sein
|
port.must.be.integer=Der Port muss eine ganze Zahl sein
|
||||||
map.doesnt.fit=Diese Karte passt nicht zu diesem Spiel
|
map.doesnt.fit=Diese Karte passt nicht zu diesem Spiel
|
||||||
|
map.invalid = Karte ung<6E>ltig
|
||||||
ships.dont.fit.the.map=Schiffe sind au<61>erhalb der Map
|
ships.dont.fit.the.map=Schiffe sind au<61>erhalb der Map
|
||||||
menu.music.toggle = Musik an/aus
|
menu.music.toggle = Musik an/aus
|
||||||
menu.music.volume = Lautst<EFBFBD>rke
|
menu.music.volume = Lautst<EFBFBD>rke
|
||||||
|
|||||||
Reference in New Issue
Block a user