corrected the server based validation in 'WaitState' and 'ServerGameLogic' and 'battleship.properties' and 'battleship_de.properties' and reformatted 'SeaSynchronizer'

corrected the 'ServerGameLogic' so it will send new GameLogic and will be still in EditorState, when presented with an invalid map
and added in the properties the keys writen in 'WaitState' and added the 'ReceivedGameLogic', to receive new GameDetails
This commit is contained in:
Benjamin Feyer
2024-10-08 23:05:51 +02:00
parent d53e8577d8
commit dffb5b4d63
5 changed files with 20 additions and 7 deletions

View File

@@ -122,12 +122,13 @@ private Spatial handleHit(Shot shot) {
/**
* this method attach fire to the ship, if it is hit
*
* @param shot the shot, that hit the ship
* @return the Fire
*/
private ParticleEmitter createFire(Shot shot) {
ParticleEmitter hitEffect = new ParticleEmitter("HitEffect", Type.Triangle, 5000);
ParticleEmitter hitEffect = new ParticleEmitter("HitEffect", Type.Triangle, 5000);
hitEffect.setMaterial(new Material(app.getAssetManager(), PARTICLE));
hitEffect.setImagesX(2);
hitEffect.setImagesY(2);
@@ -280,12 +281,6 @@ private Spatial createDestroyer(Battleship ship) {
model.scale(0.0001f);
model.move(0, 0.3f, 0);
model.setShadowMode(ShadowMode.CastAndReceive);
//model.setMaterial(app.getAssetManager().loadMaterial("Models/Destroyer/10619_Battleship.mtl"));
//TODO
//Material m = new Material();
//m.setTexture("textureDestroyer",app.getAssetManager().loadTexture("Models/Destroyer/10619_Battleship.mtl"));
//model.setMaterial(m);
return model;
}

View File

@@ -7,6 +7,7 @@
package pp.battleship.game.client;
import pp.battleship.message.server.GameDetails;
import pp.battleship.message.server.StartBattleMessage;
import java.lang.System.Logger.Level;
@@ -38,4 +39,18 @@ public void receivedStartBattle(StartBattleMessage msg) {
logic.setInfoText(msg.getInfoTextKey());
logic.setState(new BattleState(logic, msg.isMyTurn()));
}
/**
* Handles the GameDetails message received from the server.
* If the map is invalid, the editor state is set.
*
* @param msg the GameDetails message received
*/
@Override
public void receivedGameDetails(GameDetails msg) {
ClientGameLogic.LOGGER.log(Level.WARNING, "Invalid Map"); //NON-NLS
logic.setInfoText("map.invalid");
logic.setState(new EditorState(logic));
}
}

View File

@@ -145,6 +145,7 @@ public void received(MapMessage msg, int from) {
LOGGER.log(Level.ERROR, "playerReady not allowed in {0}", state); //NON-NLS
else if (!verifyMap(msg, from)) {
LOGGER.log(Level.ERROR, "player submitted invalid map", state);
send(getPlayerById(from), new GameDetails(config));
}
else
playerReady(getPlayerById(from), msg.getShips());

View File

@@ -41,3 +41,4 @@ background.music.checkbox= Background music on/off
background.music.volume= Background volume
player.submitted.invalid.map= invalid map submitted
local.server= instantiate local server
map.invalid=The map is invalid

View File

@@ -41,4 +41,5 @@ background.music.checkbox= Musik an/aus
background.music.volume= Musiklautst<EFBFBD>rke
player.submitted.invalid.map= Invalide karte gegeben
local.server=Lokalen Server erstellen
map.invalid=Die Karte ist ung<6E>ltig