package macampcorp.macamp.game.scheduler;

import android.app.Activity;
import android.content.Intent;

import macampcorp.macamp.activities.BombActivity;
import macampcorp.macamp.activities.EndActivity;
import macampcorp.macamp.activities.HostActivity;
import macampcorp.macamp.game.Game;

public class SpecialTask extends Task {

    public static final int FINISHED_SUCESS=1;
    public static final int FINISHED_FAILED=2;
    public static final int END_SUCCESS=4;
    public static final int END_FAILED=5;
    public static final int BOMB=3;

    protected int mState;

    public SpecialTask(int x) {
        super(TASK_SPECIAL);
        mState=x;
    }

    private static final String[] gStrings={"STATE_NONE", "STATE_FINISHED_SUCESS",
                                              "STATE_FINISHED_FAILED", "STATE_FINISHED_FAILED",
                                                "STATE_END_SUCCESS", "STATE_END_FAILED" };

    public String toString()
    {
        return "[ End, "+gStrings[mState]+" ]";
    }

    @Override
    public int exec(Scheduler s, HostActivity cd, Game g) {
        switch(mState)
        {
            case FINISHED_SUCESS:
                cd.setFinished();
                break;
            case FINISHED_FAILED:
                cd.setFailed();
                break;
            case BOMB:
            {
                Activity act = cd.getActivity();
                Intent in = new Intent(act, BombActivity.class);
                act.startActivityForResult(in, BombActivity.REQUEST_CODE);
            }
            break;

            case END_FAILED:
                EndActivity.start(cd, false);
                //cd.finish();
               // break;

            case END_SUCCESS:
                EndActivity.start(cd, true);
                //cd.finish();
                break;
        }
        return TASK_SPECIAL;
    }
}
