package eu.jonahbauer.wizard.common.messages.observer;

import eu.jonahbauer.wizard.common.messages.player.JuggleMessage;
import eu.jonahbauer.wizard.common.messages.player.PickTrumpMessage;
import eu.jonahbauer.wizard.common.messages.player.PlayCardMessage;
import eu.jonahbauer.wizard.common.messages.player.PredictMessage;
import eu.jonahbauer.wizard.common.model.Card;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.UUID;

/**
 * A {@link UserInputMessage} is sent when user input is required.
 */
@Getter
@RequiredArgsConstructor
@EqualsAndHashCode(callSuper = true)
public final class UserInputMessage extends ObserverMessage {
    /**
     * The UUID of the player whose input is required. May be {@code null} to indicate that an input is required from
     * every player.
     */
    private final UUID player;
    /**
     * The type of input that is required.
     */
    private final Action action;
    /**
     * A timeout in {@link System#currentTimeMillis() UNIX time} after which a default action is taken.
     */
    private final long timeout;

    public enum Action {
        /**
         * An action that indicates that a player should make a prediction. A {@link UserInputMessage} with this
         * {@link UserInputMessage#getAction()} should be responded to with a {@link PredictMessage}.
         */
        MAKE_PREDICTION,
        /**
         * An action that indicates that a player should change his a prediction by ±1. A {@link UserInputMessage} with
         * this {@link UserInputMessage#getAction()} should be responded to with a {@link PredictMessage}.
         */
        CHANGE_PREDICTION,
        /**
         * An action that indicates that a player should play a card. A {@link UserInputMessage} with this
         * {@link UserInputMessage#getAction()} should be responded to with a {@link PlayCardMessage}.
         */
        PLAY_CARD,
        /**
         * An action that indicates that a player should choose a card that will be given to his left neighbor as a
         * result of a played {@link Card#JUGGLER}. A {@link UserInputMessage} with this
         * {@link UserInputMessage#getAction()} should be responded to with a {@link JuggleMessage}.
         */
        JUGGLE_CARD,
        /**
         * An action that indicates that a player should pick a trump suit. A {@link UserInputMessage} with this
         * {@link UserInputMessage#getAction()} should be responded to with a {@link PickTrumpMessage}.
         */
        PICK_TRUMP
    }
}
