package de.frajul.endlessroll.main.tutorial;

import java.util.ArrayList;
import java.util.List;

import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.tools.ToolType;

/**
 * Created by Julian on 10.06.2017.
 */

public class ToolShopTutorial extends Tutorial {

    private List<BreakPoint> atStartBreakPoints = new ArrayList<>();
    private List<BreakPoint> afterSpringBoughtBreakPoints = new ArrayList<>();

    private boolean firstPartShown;

    public ToolShopTutorial() {
        super(-1, -1, new BreakPoint(0, R.string.tutorial_toolshop_welcome, -1),
                new BreakPoint(0, R.string.tutorial_toolshop_toolbar,
                        R.drawable.tutorial_toolshop_toolbar),
                new BreakPoint(0, R.string.tutorial_toolshop_all_tools,
                        R.drawable.tutorial_toolshop_all_tools),
                new BreakPoint(0, R.string.tutorial_toolshop_inspector,
                        R.drawable.tutorial_toolshop_inspector),
                new BreakPoint(0, R.string.tutorial_toolshop_select_buy_spring,
                        R.drawable.tutorial_toolshop_select_buy_spring),
                new BreakPoint(1, R.string.tutorial_toolshop_equip_spring,
                        R.drawable.tutorial_toolshop_equip_spring));
        for (BreakPoint breakPoint : super.getBreakPoints()) {
            if (breakPoint.getX() == 0)
                atStartBreakPoints.add(breakPoint);
            else
                afterSpringBoughtBreakPoints.add(breakPoint);
        }
    }

    @Override
    public void reset() {
        currentBreakPoints.clear();
        firstPartShown = false;
    }

    public void onToolShopPrepare(boolean isSpringUnlocked) {
        currentBreakPoints.clear();
        if (isSpringUnlocked && !firstPartShown) {
            currentBreakPoints.addAll(atStartBreakPoints);
            firstPartShown = true;
        }
    }

    public void onToolBought(ToolType type) {
        currentBreakPoints.clear();
        if (type == ToolType.SPRING) {
            currentBreakPoints = afterSpringBoughtBreakPoints;
        }
    }

    public boolean isFirstPartShown() {
        return firstPartShown;
    }

    public void setFirstPartShown(boolean firstPartShown) {
        this.firstPartShown = firstPartShown;
    }
}
