package eu.jonahbauer.wizard.client.libgdx.actions.overlay;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
import eu.jonahbauer.wizard.client.libgdx.util.AnimationTimings;
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
import org.jetbrains.annotations.NotNull;

import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;

public class StartRoundOverlay extends Overlay {

    private final int round;

    public StartRoundOverlay(@NotNull GameScreen gameScreen, int round) {
        super(gameScreen, Long.MAX_VALUE);
        this.round = round;
    }

    @Override
    public Actor createContent() {
        var root = new VerticalGroup().columnCenter().space(10f);

        var label = new Label(messages.format("game.overlay.round.title", round + 1), skin, "enchanted");
        label.setFontScale(1.5f);
        root.addActor(label);

        return root;
    }

    @Override
    public void show(Group parent) {
        super.show(parent);

        var root = getRoot();
        root.addAction(sequence(
                delay(AnimationTimings.OVERLAY_HOLD),
                run(this::close)
        ));
    }
}
