package com.holdit.feedthemax;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import static com.holdit.feedthemax.MainActivity.rbt1qu;
import static com.holdit.feedthemax.R.id.rbt1price;
import static com.holdit.feedthemax.R.id.rbt2price;
import static com.holdit.feedthemax.R.id.rbt3price;

/**
 * Created by Antek on 2017-05-10.
 * Activity started after robot button pressed
 */

public class RobotsActivity extends AppCompatActivity {



    @Override
    public void onCreate(Bundle savedInstanceState){

        super.onCreate(savedInstanceState);
        setContentView(R.layout.robots_layout);

        //final MainActivity mact = new MainActivity();

        RelativeLayout rbt1rl = (RelativeLayout) findViewById(R.id.rbt1rl);
        RelativeLayout rbt2rl = (RelativeLayout) findViewById(R.id.rbt2rl);
        RelativeLayout rbt3rl = (RelativeLayout) findViewById(R.id.rbt3rl);
        final TextView rbt1prc = (TextView) findViewById(rbt1price);
        rbt1prc.setText(MainActivity.rbt1price + "C");
        final TextView rbt2prc = (TextView) findViewById(rbt2price);
        rbt2prc.setText(MainActivity.rbt2price + "C");
        final TextView rbt3prc = (TextView) findViewById(rbt3price);
        rbt3prc.setText(MainActivity.rbt3price + "C");

        rbt1rl.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                if (MainActivity.cookies >= MainActivity.rbt1price) {

                    MainActivity.cookies -= MainActivity.rbt1price;
                    MainActivity.cps ++;
                    MainActivity.rbt1qu++;
                    MainActivity.rbt1price = (int) (100 * Math.pow(1.15, MainActivity.rbt1qu));
                    rbt1prc.setText(MainActivity.rbt1price + "C");

                }

            }
        });

        rbt2rl.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                if (MainActivity.cookies >= MainActivity.rbt2price) {

                    MainActivity.cookies -= MainActivity.rbt2price;
                    MainActivity.cps += 8;
                    MainActivity.rbt2qu++;
                    MainActivity.rbt2price = (int) (1100 * Math.pow(1.15, MainActivity.rbt2qu));
                    rbt2prc.setText(MainActivity.rbt2price + "C");

                }

            }
        });

        rbt3rl.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                if (MainActivity.cookies >= MainActivity.rbt3price) {

                    MainActivity.cookies -= MainActivity.rbt3price;
                    MainActivity.cps += 47;
                    MainActivity.rbt3qu++;
                    MainActivity.rbt3price = (int) (12000 * Math.pow(1.15, MainActivity.rbt3qu));
                    rbt3prc.setText(MainActivity.rbt3price + "C");

                }

            }
        });

    }

}
