package eu.jonahbauer.wizard.client.libgdx.state;

import eu.jonahbauer.wizard.client.libgdx.Client;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import org.jetbrains.annotations.MustBeInvokedByOverriders;

import java.util.Optional;

@Log4j2
public abstract class Awaiting extends BaseState implements ClientState {
    private static final int TIMEOUT_MILLIS = 10_000;
    
    @Override
    @SneakyThrows
    @MustBeInvokedByOverriders
    public Optional<ClientState> onEnter(Client client) {
        client.timeout(this, TIMEOUT_MILLIS);
        return Optional.empty();
    }
    
    @Override
    public Optional<ClientState> onTimeout(Client client) {
        log.error("Timed out. Returning to menu.");
        return Optional.of(new Menu());
    }
    
}