package de.frajul.endlessroll.entities.shapes;

import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;

import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.textures.Texture;
import de.frajul.endlessroll.entities.textures.TexturePack;

/**
 * Created by Julian on 22.10.2017.
 */

public enum PlayerShape {
    BALL(R.string.playershape_name_ball, R.string.playershape_description_ball,
            R.drawable.playershapes_ball, new EmptyTask()),
    HYPNO_SPIRAL(R.string.playershape_name_hypno_spiral,
            R.string.playershape_description_hypno_spiral, R.drawable.playershapes_hypno_spiral,
            new CollectEnergyTask(3)),
    CLOCK(R.string.playershape_name_clock, R.string.playershape_description_clock,
            R.drawable.playershapes_clock, new CollectStarTask(15)),
    SUN(R.string.playershape_name_sun, R.string.playershape_description_sun,
            R.drawable.playershapes_sun, new CollectEnergyTask(10)),
    SMILEY(R.string.playershape_name_smiley, R.string.playershape_description_smiley,
            R.drawable.playershapes_smiley, new CollectStarTask(30)),
    PACMAN(R.string.playershape_name_pacman, R.string.playershape_description_pacman,
            R.drawable.playershapes_pacman, new CompleteWorldTask(1)),
    WHEEL(R.string.playershape_name_wheel, R.string.playershape_description_wheel,
            R.drawable.playershapes_wheel, new CollectStarTask(45)),
    BLUE(R.string.playershape_name_blue, R.string.playershape_description_blue,
            R.drawable.jury_playershapes_ball_omg_im_blue, new CompleteWorldTask(2));

    @StringRes
    private int nameId;
    @StringRes
    private int descriptionId;
    @DrawableRes
    private int drawableId;
    private Task unlockTask;

    private Texture texture;

    PlayerShape(@StringRes int nameId, @StringRes int descriptionId, @DrawableRes int drawableId, Task unlockTask) {
        this.nameId = nameId;
        this.descriptionId = descriptionId;
        this.drawableId = drawableId;
        this.unlockTask = unlockTask;
    }

    public static void loadAllTextures(TexturePack texturePack) {
        for (PlayerShape playerShape : values())
            playerShape.loadTexture(texturePack);
    }

    private void loadTexture(TexturePack texturePack) {
        if (drawableId == -1)
            return;
        texture = texturePack.loadTexture(drawableId);
    }

    public Task getUnlockTask() {
        return unlockTask;
    }

    @StringRes
    public int getNameId() {
        return nameId;
    }

    @StringRes
    public int getDescriptionId() {
        return descriptionId;
    }

    @DrawableRes
    public int getDrawableId() {
        return drawableId;
    }

    public Texture getTexture() {
        return texture;
    }
}
