package fanch.multijeu.numbers.activity;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import fanch.multijeu.R;
import fanch.multijeu.common.view.ComboBox;
import fanch.multijeu.numbers.fragment.NumberFragment;

public class SelectNumbersActivity extends AppCompatActivity {
    protected ComboBox mDiff;
    protected String[] mDiffList={ "Très Facile", "Facile", "Moyen", "Difficile",
            "Très difficile"};
    protected int[] mDiffValues={0,1,2,3,4,5};
    protected int mDiffDefault = 0;

    protected ComboBox mTemps;
    protected String[] mTempsList={ "Pas de limite", "15\"", "30\""
            , "45\"", "1'", "1' 30\"", "2'", "3'", "4'", "5'", "10'"};
    protected int[] mTempsValues={-1, 15, 30, 45, 60 ,90 , 120, 180, 240, 300, 600};
    protected int mTempsDefault = 3;

    protected ComboBox mInterface;
    protected String[] mInterfaceList={ "Assistée", "Non assistée"};
    protected NumberFragment.PadStyle[] mInterfaceValues={
            NumberFragment.PadStyle.ASSISTED,
            NumberFragment.PadStyle.NON_ASSISTED};
    protected int mInterfaceDefault = 0;

    protected ComboBox mMode;
    protected String[] mModeList={ "One Shot", "Arcade", "Libre"};
    protected NumberActivity.GameMode[] mModeValues={
            NumberActivity.GameMode.ONE_SHOT,
            NumberActivity.GameMode.SCORE,
            NumberActivity.GameMode.FREE
    };
    protected int mModeDefault = 1;

    protected ComboBox mCorrection;
    protected String[] mCorrectionList={ "Oui", "Non"};
    protected boolean[] mCorrectionValues={true, false};
    protected int mCorrectionDefault = 0;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_numbers);
        mDiff=findViewById(R.id.cb_diff);
        mDiff.setText("Difficulté");
        mDiff.setData(mDiffList,mDiffDefault);

        mTemps=findViewById(R.id.cb_temps);
        mTemps.setText("Temps");
        mTemps.setData(mTempsList,mTempsDefault);


        mInterface=findViewById(R.id.cb_interface);
        mInterface.setText("Interface");
        mInterface.setData(mInterfaceList,mInterfaceDefault);


        mMode=findViewById(R.id.cb_mode);
        mMode.setText("Mode");
        mMode.setData(mModeList, mModeDefault);

        mCorrection=findViewById(R.id.cb_correction);
        mCorrection.setText("Correction");
        mCorrection.setData(mCorrectionList, mCorrectionDefault);

    }

    public static void start(Context c)
    {
        Intent in = new Intent(c, SelectNumbersActivity.class);
        c.startActivity(in);
    }

    public void onStart(View view) {
        NumberActivity.Attrs attrs = new NumberActivity.Attrs();
        attrs.mode=mModeValues[mMode.getSelected()];
        attrs.style=mInterfaceValues[mInterface.getSelected()];
        attrs.time=mTempsValues[mTemps.getSelected()];
        attrs.difficulty=mDiffValues[mDiff.getSelected()];
        attrs.isCorrectable=mCorrectionValues[mCorrection.getSelected()];

        NumberActivity.start(this, attrs);
    }
}
