////////////////////////////////////////
// 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;
import pp.battleship.model.IntPoint;

/**
 * A message sent by the client to indicate a shooting action in the game.
 */
@Serializable
public class ShootMessage extends ClientMessage {
    private IntPoint position;

    /**
     * Default constructor for serialization purposes.
     */
    private ShootMessage() { /* empty */ }

    /**
     * Constructs a ShootMessage with the specified position.
     *
     * @param position the position where the shot is fired
     */
    public ShootMessage(IntPoint position) {
        this.position = position;
    }

    /**
     * Returns the position of the shot.
     *
     * @return the position of the shot
     */
    public IntPoint getPosition() {
        return position;
    }

    /**
     * Returns a string representation of the ShootMessage.
     *
     * @return a string representation of the ShootMessage
     */
    @Override
    public String toString() {
        return "ShootMessage{position=" + position + '}'; //NON-NLS
    }

    /**
     * Accepts a visitor to process this message.
     *
     * @param interpreter the visitor to process this message
     * @param from        the connection ID from which the message was received
     */
    @Override
    public void accept(ClientInterpreter interpreter, int from) {
        interpreter.received(this, from);
    }
}
