////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////

package pp.battleship.game.client;

import pp.battleship.message.server.StartBattleMessage;

import java.lang.System.Logger.Level;

class WaitState extends ClientState {

    /**
     * Creates a new instance of {@link WaitState}.
     *
     * @param logic the game logic
     */
    public WaitState(ClientGameLogic logic) {
        super(logic);
    }

    @Override
    public boolean showEditor() {
        return true;
    }

    /**
     * Starts the battle based on the server message.
     *
     * @param msg the message indicating whose turn it is to shoot
     */
    @Override
    public void receivedStartBattle(StartBattleMessage msg) {
        ClientGameLogic.LOGGER.log(Level.INFO, "start battle, {0} turn", msg.isMyTurn() ? "my" : "other's"); //NON-NLS
        logic.setInfoText(msg.getInfoTextKey());
        logic.setState(new BattleState(logic, msg.isMyTurn()));
    }
}
