Code cleanup

added JavaDocs
removed unnecessary lines
This commit is contained in:
Timo Brennförder
2024-10-13 01:59:46 +02:00
parent febdd63422
commit 8c45784246
131 changed files with 2291 additions and 1548 deletions

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship;
import pp.util.config.Config;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship;
import java.util.ResourceBundle;

View File

@@ -11,15 +11,25 @@
import java.lang.System.Logger.Level;
public class AnimationState extends ClientState{
/**
* Represents the state in which the animation is played
*/
public class AnimationState extends ClientState {
private boolean myTurn;
/**
* Constructor for the AnimationState class
*
* @param logic the client logic
* @param turn a boolean containing if it's the client's turn
* @param position the position a Shell gets created
*/
public AnimationState(ClientGameLogic logic, boolean turn, IntPoint position) {
super(logic);
logic.playMusic(Music.GAME_THEME);
myTurn = turn;
if (myTurn){
if (myTurn) {
logic.getOpponentMap().add(new Shell(position));
}
else {
@@ -27,8 +37,13 @@ public AnimationState(ClientGameLogic logic, boolean turn, IntPoint position) {
}
}
/**
* Makes sure the client renders the correct view
*
* @return true
*/
@Override
boolean showBattle(){
boolean showBattle() {
return true;
}
@@ -52,8 +67,13 @@ public void receivedEffect(EffectMessage msg) {
}
}
/**
* Sets the client back to the battle state
*
* @param msg the received SwitchToBattleState message
*/
@Override
public void receivedSwitchToBattleState(SwitchToBattleState msg){
public void receivedSwitchToBattleState(SwitchToBattleState msg) {
logic.setState(new BattleState(logic, msg.getTurn()));
}
@@ -89,6 +109,7 @@ private void playSound(EffectMessage msg) {
else if (msg.getDestroyedShip() == null)
logic.playSound(Sound.EXPLOSION);
else
logic.playSound(Sound.DESTROYED_SHIP);
logic.playSound(Sound.EXPLOSION);
logic.playSound(Sound.DESTROYED_SHIP);
}
}

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;
@@ -35,11 +30,21 @@ public BattleState(ClientGameLogic logic, boolean myTurn) {
this.myTurn = myTurn;
}
/**
* Makes sure the client renders the correct view
*
* @return true
*/
@Override
public boolean showBattle() {
return true;
}
/**
* Triggers a shoot event if it's client's turn
*
* @param pos the position where the click occurred
*/
@Override
public void clickOpponentMap(IntPoint pos) {
if (!myTurn)
@@ -48,9 +53,14 @@ else if (logic.getOpponentMap().isValid(pos))
logic.send(new ShootMessage(pos));
}
/**
* Triggers an animation if StartAnimationMessage is received
*
* @param msg the received Startanimation message
*/
@Override
public void receivedStartAnimation(StartAnimationMessage msg){
logic.setState(new AnimationState(logic, msg.isMyTurn(), msg.getPosition() ));
public void receivedStartAnimation(StartAnimationMessage msg) {
logic.setState(new AnimationState(logic, msg.isMyTurn(), msg.getPosition()));
logic.playSound(Sound.MISSILE_LAUNCH);
}
}

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;
@@ -231,6 +226,8 @@ public void received(EffectMessage msg) {
}
/**
* Reports that client should play an animation
*
* @param msg
*/
@Override
@@ -239,6 +236,8 @@ public void received(StartAnimationMessage msg) {
}
/**
* Reports that client should switch to the battle state
*
* @param msg
*/
@Override
@@ -375,9 +374,10 @@ public void update(float delta) {
/**
* Triggers an event to play specified music
*
* @param music the music to be played
*/
public void playMusic(Music music){
public void playMusic(Music music) {
notifyListeners(new MusicEvent(music));
}
}

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;
@@ -167,10 +162,20 @@ void receivedEffect(EffectMessage msg) {
ClientGameLogic.LOGGER.log(Level.ERROR, "receivedEffect not allowed in {0}", getName()); //NON-NLS
}
/**
* Reports that client should switch to battle state
*
* @param msg the received SwitchToBattleState message
*/
void receivedSwitchToBattleState(SwitchToBattleState msg) {
ClientGameLogic.LOGGER.log(Level.ERROR, "receivedSwitchToBattleState not allowed in {0}", getName());
}
/**
* Reports that the client should start an animation
*
* @param msg the received StartAnimation message
*/
void receivedStartAnimation(StartAnimationMessage msg) {
ClientGameLogic.LOGGER.log(Level.ERROR, "receivedStartAnimation not allowed in {0}", getName());
}

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;
@@ -251,6 +246,12 @@ else if (!checkMapToLoad(dto)) {
selectedInHarbor = null;
}
/**
* Checks if the provided map meets the requirements
*
* @param dto the data transfer object to check
* @return boolean if the map meets the requirements
*/
private boolean checkMapToLoad(ShipMapDTO dto) {
int mapWidth = dto.getWidth();
int mapHeight = dto.getHeight();
@@ -266,7 +267,7 @@ private boolean checkMapToLoad(ShipMapDTO dto) {
// check if ships overlap
List<Battleship> ships = dto.getShips();
for(Battleship ship:ships) {
for (Battleship ship : ships) {
for (Battleship compareShip : ships) {
if (!(ship == compareShip)) {
if (ship.collidesWith(compareShip)) {

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;
@@ -20,7 +15,7 @@ class GameOverState extends ClientState {
*/
GameOverState(ClientGameLogic logic, boolean loser) {
super(logic);
if(loser){
if (loser) {
logic.playMusic(Music.LOSE_THEME);
}
else {

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;
@@ -58,6 +53,11 @@ private void fillHarbor(GameDetails details) {
}
}
/**
* Checks if map may be saved to file
*
* @return false
*/
@Override
public boolean maySaveMap() {
return false;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;
@@ -40,6 +35,11 @@ public void receivedStartBattle(StartBattleMessage msg) {
logic.setState(new BattleState(logic, msg.isMyTurn()));
}
/**
* Reverts the client back to the editor state if an invalid map is provided
*
* @param details the game details including map size and ships
*/
@Override
public void receivedGameDetails(GameDetails details) {
ClientGameLogic.LOGGER.log(Level.WARNING, "Invalid Map"); //NON-NLS

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.server;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.server;
import pp.battleship.BattleshipConfig;
@@ -157,33 +150,32 @@ else if (!checkMap(msg, from)) {
}
/**
* @param msg
* Handles the reception of an EndAnimation message
* @param msg received EndAnimation message
*/
@Override
public void received(EndAnimationMessage msg, int from){
if(state != ServerState.WAIT_ANIMATION)
public void received(EndAnimationMessage msg, int from) {
if (state != ServerState.WAIT_ANIMATION)
LOGGER.log(Level.ERROR, "animation not allowed in {0}", state);
else
if(getPlayerById(from) == players.get(0)){
LOGGER.log(Level.DEBUG, "{0} set to true", getPlayerById(from));
p1AnimationFinished = true;
shoot(getPlayerById(from), msg.getPosition());
}
else if (getPlayerById(from) == players.get(1)){
LOGGER.log(Level.DEBUG, "{0} set to true {1}", getPlayerById(from), getPlayerById(from).toString());
p2AnimationFinished = true;
shoot(getPlayerById(from), msg.getPosition());
}
if(p1AnimationFinished && p2AnimationFinished) {
setState(ServerState.BATTLE);
for (Player player : players)
send(player, new SwitchToBattleState(player == activePlayer));
p1AnimationFinished = false;
p2AnimationFinished = false;
}
else if (getPlayerById(from) == players.get(0)) {
LOGGER.log(Level.DEBUG, "{0} set to true", getPlayerById(from));
p1AnimationFinished = true;
shoot(getPlayerById(from), msg.getPosition());
}
else if (getPlayerById(from) == players.get(1)) {
LOGGER.log(Level.DEBUG, "{0} set to true {1}", getPlayerById(from), getPlayerById(from).toString());
p2AnimationFinished = true;
shoot(getPlayerById(from), msg.getPosition());
}
if (p1AnimationFinished && p2AnimationFinished) {
setState(ServerState.BATTLE);
for (Player player : players)
send(player, new SwitchToBattleState(player == activePlayer));
p1AnimationFinished = false;
p2AnimationFinished = false;
}
}
/**
* Returns true if the map contains correct ship placement and is of the correct size
*
@@ -258,6 +250,11 @@ void playerReady(Player player, List<Battleship> ships) {
}
}
/**
* Handles what Effect should be triggered based on the shot
* @param player the player receiving the message
* @param position the position the shot hit
*/
void shoot(Player player, IntPoint position) {
final Battleship selectedShip;
selectedShip = getSelectedShip(player, position);
@@ -269,6 +266,12 @@ void shoot(Player player, IntPoint position) {
}
}
/**
* Returns the ship at a given position
* @param player the player whose map will be checked for a ship
* @param position the position to be checked for a ship
* @return if there is a ship at the given position, returns the ship, else null
*/
Battleship getSelectedShip(Player player, IntPoint position) {
if (player != activePlayer) {
return player.getMap().findShipAt(position);
@@ -278,6 +281,11 @@ Battleship getSelectedShip(Player player, IntPoint position) {
}
}
/**
* Sends a message to the client that the shot missed
* @param player the player receiving the message
* @param position the position at which the shot hit in the water
*/
void shotMissed(Player player, IntPoint position) {
if (player != activePlayer) {
send(player, EffectMessage.miss(false, position));
@@ -292,6 +300,12 @@ void shotMissed(Player player, IntPoint position) {
activePlayer = player;
}
/**
* Sends a message to the client that the shot missed
* @param player the player receiving the message
* @param position the position at which the shot hit in the ship
* @param ship the ship that has been hit
*/
void shotHit(Player player, IntPoint position, Battleship ship) {
ship.hit(position);
if (getOpponent(activePlayer).getMap().getRemainingShips().isEmpty()) {
@@ -319,5 +333,4 @@ else if (ship.isDestroyed()) {
}
}
}
}

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.server;
import pp.battleship.message.server.ServerMessage;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.server;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.singlemode;
import pp.battleship.BattleshipConfig;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.singlemode;
@@ -65,8 +60,9 @@ public void received(MapMessage msg, int from) {
}
/**
* @param msg
* @param from
* Creates a copy of the provided EndAnimation message
* @param msg thr received EndAnimation message
* @param from the identifier of the sender
*/
@Override
public void received(EndAnimationMessage msg, int from) {

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.singlemode;
import pp.battleship.game.client.BattleshipClient;
@@ -21,6 +14,7 @@ class InterpreterProxy implements ServerInterpreter {
private final BattleshipClient playerClient;
static final System.Logger LOGGER = System.getLogger(InterpreterProxy.class.getName());
/**
* Constructs an InterpreterProxy with the specified BattleshipClient.
*
@@ -96,7 +90,7 @@ public void received(StartAnimationMessage msg) {
* @param msg the SwitchBattleState received from the server
*/
@Override
public void received(SwitchToBattleState msg){
public void received(SwitchToBattleState msg) {
LOGGER.log(System.Logger.Level.INFO, "Received SwitchBattleState");
forward(msg);
}

View File

@@ -137,7 +137,7 @@ public void received(StartAnimationMessage msg) {
* @param msg the SwitchBattleState received
*/
@Override
public void received(SwitchToBattleState msg){
public void received(SwitchToBattleState msg) {
LOGGER.log(Level.INFO, "Received SwitchBattleStateMessage: {0}", msg);
if (msg.getTurn())
shoot();

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.singlemode;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.message.client;
/**
@@ -27,5 +20,10 @@ public interface ClientInterpreter {
*/
void received(MapMessage msg, int from);
/**
* Processes a received EndAnimation message
* @param msg the received EndAnimation message
* @param from the connection ID from which the message was received
*/
void received(EndAnimationMessage msg, int from);
}

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.message.client;
import com.jme3.network.AbstractMessage;

View File

@@ -3,14 +3,24 @@
import com.jme3.network.serializing.Serializable;
import pp.battleship.model.IntPoint;
/**
* A message sent by the client telling the server the animation is finished
*/
@Serializable
public class EndAnimationMessage extends ClientMessage{
public class EndAnimationMessage extends ClientMessage {
private IntPoint position;
private EndAnimationMessage(){/*do nothing */}
/**
* Default constructor for serialization purposes.
*/
private EndAnimationMessage() {/*do nothing */}
public EndAnimationMessage(final IntPoint position){
/**
* Constructs an EndAnimation message
* @param position the position to be effected
*/
public EndAnimationMessage(final IntPoint position) {
this.position = position;
}
@@ -25,9 +35,11 @@ public void accept(ClientInterpreter interpreter, int from) {
interpreter.received(this, from);
}
/**
* Getter for the position
* @return IntPoint position
*/
public IntPoint getPosition() {
return position;
}
}

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.message.client;
import com.jme3.network.serializing.Serializable;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.message.client;
import com.jme3.network.serializing.Serializable;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.message.server;
import com.jme3.network.serializing.Serializable;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.message.server;
import com.jme3.network.serializing.Serializable;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.message.server;
import pp.battleship.message.client.EndAnimationMessage;
@@ -36,7 +29,15 @@ public interface ServerInterpreter {
*/
void received(EffectMessage msg);
/**
* Handles a StartAnimation message received from the server
* @param msg the received StartAnimation message
*/
void received(StartAnimationMessage msg);
/**
* Handles a SwitchToBattleState message received from the server
* @param msg the received SwitchToBattleState message
*/
void received(SwitchToBattleState msg);
}

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.message.server;
import com.jme3.network.AbstractMessage;

View File

@@ -3,14 +3,25 @@
import com.jme3.network.serializing.Serializable;
import pp.battleship.model.IntPoint;
/**
* A message sent by the server to inform clients about the start of an animation
*/
@Serializable
public class StartAnimationMessage extends ServerMessage {
private IntPoint position;
private boolean myTurn;
private StartAnimationMessage(){/*do nothing */}
/**
* Default constructor for serialization purposes.
*/
private StartAnimationMessage() {/*do nothing */}
/**
* Constructs a StartAnimation message
* @param position the position a Shell will affect
* @param myTurn boolean if it's client's turn
*/
public StartAnimationMessage(IntPoint position, boolean myTurn) {
this.position = position;
this.myTurn = myTurn;
@@ -37,9 +48,15 @@ public String getInfoTextKey() {
return "started animation at " + position;
}
/**
* Getter for the position
* @return IntPoint position
*/
public IntPoint getPosition() {return position;}
/**
* Getter for myTurn
* @return boolean myTurn
*/
public boolean isMyTurn() {return myTurn;}
}

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.message.server;
import com.jme3.network.serializing.Serializable;

View File

@@ -2,14 +2,24 @@
import com.jme3.network.serializing.Serializable;
/**
* A message sent by the server to tell client to switch to battle state
*/
@Serializable
public class SwitchToBattleState extends ServerMessage{
public class SwitchToBattleState extends ServerMessage {
private boolean myTurn;
private SwitchToBattleState(){/*do nothing */}
/**
* Default constructor for serialization purposes.
*/
private SwitchToBattleState() {/*do nothing */}
public SwitchToBattleState(boolean turn){
/**
* Constructs a SwitchToBattleState message
* @param turn boolean it's client's turn
*/
public SwitchToBattleState(boolean turn) {
myTurn = turn;
}
@@ -34,7 +44,9 @@ public String getInfoTextKey() {
return "switched to battle state";
}
public boolean getTurn(){return myTurn;}
/**
* Getter for myTurn
* @return boolean myTurn
*/
public boolean getTurn() {return myTurn;}
}

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model;
import com.jme3.network.serializing.Serializable;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model;
import com.jme3.network.serializing.Serializable;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model;
/**

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model;
/**

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model;
import java.io.Serializable;

View File

@@ -8,7 +8,7 @@ public class Shell implements Item {
private int y;
/**
* constructs a new shell object
* Constructs a new Shell object
*
* @param position the end position of the shell
*/

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model;
import pp.battleship.notification.GameEvent;
@@ -92,8 +85,9 @@ public void add(Shot shot) {
}
/**
* Registers a shell on the map
* @param shell the shell to be registered
* Registers a Shell on the map
*
* @param shell the Shell to be registered
*/
public void add(Shell shell) {
addItem(shell);

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model;
import com.jme3.network.serializing.Serializable;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model;
/**
@@ -29,5 +22,10 @@ public interface Visitor<T> {
*/
T visit(Battleship ship);
/**
* Visits a Shell element
* @param shell the Shell element to visit
* @return the result of visiting the Shell element
*/
T visit(Shell shell);
}

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model;
/**
@@ -26,5 +19,9 @@ public interface VoidVisitor {
*/
void visit(Battleship ship);
/**
* Visits a Shell element
* @param shell the Shell to be visited
*/
void visit(Shell shell);
}

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model.dto;
import pp.battleship.model.Battleship;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model.dto;
import com.google.gson.Gson;
@@ -117,15 +110,15 @@ public static ShipMapDTO loadFrom(File file) throws IOException {
/**
* This method returns the width of the DTO
*
* @return with of DTO
*/
public int getWidth() {return width;}
/**
* This method returns the height of the DTO
*
* @return height of DTO
*/
public int getHeight(){return height;}
public int getHeight() {return height;}
}

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.notification;
/**

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.notification;
/**

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.notification;
/**

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.notification;
/**
@@ -52,5 +45,4 @@ default void receivedEvent(ClientStateEvent event) { /* do nothing */ }
* @param event the received Event
*/
default void receivedEvent(MusicEvent event) { /* do nothing */ }
}

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.notification;
/**

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.notification;
import pp.battleship.model.Item;

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.notification;
import pp.battleship.model.Item;

View File

@@ -5,19 +5,19 @@
*/
public enum Music {
/**
* menu music
* Menu music
*/
MENU_THEME,
/**
* ingame music
* In game music
*/
GAME_THEME,
/**
* music for a victory
* Victory music
*/
VICTORY_THEME,
/**
* music for a loss
* Loss music
*/
LOSE_THEME,
}

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.notification;
/**

View File

@@ -1,10 +1,3 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.notification;
/**

View File

@@ -37,9 +37,9 @@ dialog.error=Error
dialog.question=Question
port.must.be.integer=Port must be an integer number
map.doesnt.fit=The map doesn't fit to this game
map.invalid = map is invalid
map.invalid=map is invalid
ships.dont.fit.the.map=Ships are out of bounds
menu.music.toggle = Music on/off
menu.music.volume = Volume
start.own.server = start server
menu.music.toggle=Music on/off
menu.music.volume=Volume
start.own.server=start server

View File

@@ -37,9 +37,9 @@ dialog.error=Fehler
dialog.question=Frage
port.must.be.integer=Der Port muss eine ganze Zahl sein
map.doesnt.fit=Diese Karte passt nicht zu diesem Spiel
map.invalid = Karte ungültig
map.invalid=Karte ungültig
ships.dont.fit.the.map=Schiffe sind außerhalb der Map
menu.music.toggle = Musik an/aus
menu.music.volume = Lautstärke
start.own.server = Server starten
menu.music.toggle=Musik an/aus
menu.music.volume=Lautstärke
start.own.server=Server starten

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.client;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.client;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.server;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.server;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.server;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.game.server;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model;

View File

@@ -1,9 +1,4 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.model;