package xaero.rotatenjump.game;

import xaero.rotatenjump.game.levels.*;
import xaero.rotatenjump.game.object.Coin;
import xaero.rotatenjump.game.object.Entity;
import xaero.rotatenjump.game.object.Platform;

/**
 * Created by xaero on 10/07/2017.
 */

public class Level {

    public static final Level LEVEL1 = new Level1();
    public static final Level LEVEL2 = new Level2();
    public static final Level LEVEL3 = new Level3();
    public static final Level LEVEL4 = new Level4();
    public static final Level LEVEL5 = new Level5();
    public static final Level LEVEL6 = new Level6();
    public static final Level LEVEL7 = new Level7();
    public static final Level LEVEL8 = new Level8();
    public static final Level LEVELX = new LevelX();

    protected String buttonText;
    protected boolean winOnAttach;//whether you need to survive first to win
    protected int deadlyDepth;
    protected float scoreboardX;
    protected float scoreboardY;
    protected int threeStarTime;

    public void constructLevel(Game game){
        add(game, new Platform(0, -20, 4/*3 + (int) (2 * Math.random())*/, 45, 20f, -1.5f));
        deadlyDepth = 300;
        game.scoreboardX = scoreboardX;
        game.scoreboardY = scoreboardY;
        game.coinTimer = game.coinTimerStartValue = threeStarTime;
        game.coinTier = 2;
    }

    public boolean hasWon(Game game){
        return game.getCoins().size() == 0 && (!winOnAttach || game.getPlayer().getAttached() != null);
    }

    protected void add(Game game, Object object){
        if(object instanceof Platform)
            game.getPlatforms().add((Platform) object);
        else if(object instanceof Coin)
            game.getCoins().add((Coin) object);
        else
            game.getOthers().add((Entity)object);
    }

    public String getButtonText(){
        return buttonText;
    }
}
