package cz.jzitnik.game.sprites;

import cz.jzitnik.tui.Sprite;

import java.util.Optional;

public class Lava extends Sprite {
    public Lava() {
        loadResource("lava.ans");
    }

    public String getSprite() {
        return getSprite(Water.WaterState.FIRST);
    }

    public String getSprite(Enum e) {
        String[] resource = getResource().split("\n");

        int numberFormTop = switch (e) {
            case Water.WaterState.FIRST -> 0;
            case Water.WaterState.SECOND -> 5;
            case Water.WaterState.THIRD -> 10;
            case Water.WaterState.FOURTH -> 15;
            case Water.WaterState.FIFTH -> 20;
            default -> throw new IllegalStateException("Unexpected value: " + e);
        };

        StringBuilder stringBuilder = new StringBuilder();

        for (int i = 0; i < 25; i++) {
            if (i < numberFormTop) {
                stringBuilder.append("\033[49m ".repeat(50));
            } else {
                stringBuilder.append(resource[i]);
            }
            stringBuilder.append("\n");
        }

        return stringBuilder.toString();
    }

    @Override
    public Optional<Class<Water.WaterState>> getStates() {
        return Optional.of(Water.WaterState.class);
    }
}
