import javax.swing.*;
import javax.swing.border.Border;

import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.math.*;
import java.net.*;

public class ClickerGame extends JPanel {

    // colour pallet (default aseprite colour pallet)
    //private Color Black = new Color(0, 0, 0);
    private Color DarkBlueGrey = new Color(34, 32, 52);
    private Color DarkPurpleGrey = new Color(69, 40, 60);
    private Color DarkBrown = new Color(102, 57, 49);
    //private Color Brown = new Color(143, 86, 59);
    //private Color Orange = new Color(223, 113, 38);
    //private Color Beige = new Color(217, 160, 102);
    //private Color WhitePerson = new Color(238, 195, 154);
    //private Color Yellow = new Color(251, 242, 54);
    //private Color InnerLimeSkin = new Color(153, 229, 80);
    //private Color Lime = new Color(106, 190, 48);
    private Color PineYeastGreen = new Color(55, 148, 110);
    //private Color GrassGreen = new Color(75, 105, 47);
    //private Color DarkGreen = new Color(82, 75, 36);
    private Color MurckyGreen = new Color(50, 60, 57);
    private Color OxidizedBlue = new Color(63, 63, 116);
    //private Color LightOxidizedBlue = new Color(48, 96, 130);
    //private Color Sky = new Color(91, 110, 255);
    private Color WinterBlue = new Color(99, 115, 255);
    //private Color SteelBlue = new Color(95, 205, 228);
    //private Color LightSteelBlue = new Color(203, 219, 252);
    private Color White = new Color(255, 255, 255);
    //private Color GreyHighlight = new Color(155, 173, 183);
    //private Color GreyLight = new Color(132, 126, 135);
    //private Color Grey = new Color(105, 106, 106);
    //private Color DarkGrey = new Color(89, 86, 82);
    //private Color Muroon = new Color(188, 66, 138);
    //private Color AppleBrown = new Color(172, 50, 50);
    //private Color FleshPink = new Color(217, 87, 99);
    //private Color Pink = new Color(215, 123, 186);
    //private Color Sand = new Color(143, 151, 74);
    //private Color DarkSand = new Color(138, 111, 48);

    // images

    private URL ShopLogoURL = Clicker.class.getResource("Images/TheShopLogo.png");
    private ImageIcon ShopLogo = new ImageIcon(ShopLogoURL);
    private URL FarmsLogoURL = Clicker.class.getResource("Images/FarmsLogo.png");
    private ImageIcon FarmsLogo = new ImageIcon(FarmsLogoURL);

    // Images Nom Button Animation
    // URL url = Clicker.class.getResource("/NomIcon.png");

    private URL nom1 = Clicker.class.getResource("Images/Nom1.png");
    private URL nom2 = Clicker.class.getResource("Images/Nom2.png");
    private URL nom3 = Clicker.class.getResource("Images/Nom3.png");
    private URL nom4 = Clicker.class.getResource("Images/Nom4.png");
    private URL nom5 = Clicker.class.getResource("Images/Nom5.png");
    private URL nom6 = Clicker.class.getResource("Images/Nom6.png");
    private URL nom7 = Clicker.class.getResource("Images/Nom7.png");

    private ImageIcon frame1 = new ImageIcon(nom1);
    private ImageIcon frame2 = new ImageIcon(nom2);
    private ImageIcon frame3 = new ImageIcon(nom3);
    private ImageIcon frame4 = new ImageIcon(nom4);
    private ImageIcon frame5 = new ImageIcon(nom5);
    private ImageIcon frame6 = new ImageIcon(nom6);
    private ImageIcon frame7 = new ImageIcon(nom7);

    // Images Buttons
    private URL infoURL = ClickerGame.class.getResource("Images/InfoButton.png");
    private URL shopURL = ClickerGame.class.getResource("Images/ShopButton.png");
    private URL farmsURL = ClickerGame.class.getResource("Images/FarmsButton.png");

    private ImageIcon infoIcon = new ImageIcon(infoURL);
    private ImageIcon shopIcon = new ImageIcon(shopURL);
    private ImageIcon farmsIcon = new ImageIcon(farmsURL);

    // Images Upgrades and Farms
    private URL Upgrade1 = ClickerGame.class.getResource("Images/MouseUpgrade1(Buff).png");
    private URL Upgrade2 = ClickerGame.class.getResource("Images/MouseUpgrade2(Void).png");
    private URL Upgrade3 = ClickerGame.class.getResource("Images/MouseUpgrade3(ShoeGaze).png");
    private URL Upgrade4 = ClickerGame.class.getResource("Images/MouseUpgrade4(GregSummoner).png");
    private URL Upgrade5 = ClickerGame.class.getResource("Images/MouseUpgrade5(indonesia).png");

    private URL Farm1 = ClickerGame.class.getResource("Images/Farm1(StrawHat).png");
    private URL Farm2 = ClickerGame.class.getResource("Images/Farm2(BioChamber).png");
    private URL Farm3 = ClickerGame.class.getResource("Images/Farm3(NuclearReactor).png");
    private URL Farm4 = ClickerGame.class.getResource("Images/Farm4(LosPollosHermanos).png");
    private URL Farm5 = ClickerGame.class.getResource("Images/Farm5(TheKingInYellow).png");

    private URL[] Farms = new URL[5];

    // private URL nomNomNom =
    // ClickerGame.class.getResource("Images/NomButtonGif.gif");
    // private ImageIcon nomGif = new ImageIcon(nomNomNom);

    // constructor

    private BigInteger noms;
    private BigInteger Record = BigInteger.ZERO;
    private int currentLevel;
    private final int MAXLEVEL = 12;
    private int currentClick = 0;

    // all this describing something i moved to farm.java

    // THEBOOT is for when the player has clicked a certain amount of times and has
    // farms
    // if they have farms, a random farm group will be selected, all the farms in
    // that group will roll a number 1-10,
    // if the number is greater than or equal to THEBOOT of their current game
    // level, then the farm gives one vote
    // if over half vote "yes" then they lose one farm, if all vote "yes", they lose
    // half the farms

    private final int MAXMUGRADE = 5;
    private final int MAXFARM = 10;

    private JPanel gamPanel;
    private JPanel statsPanel;
    private JPanel shopPanel;
    private JPanel farmsUpgradPanel;
    private JPanel newGameWorldRecordPanel;
    private JTextField nomsCounter;
    private JTextField recordCounter;
    private JButton nomButton;
    private JTextField MU1Counter;
    private JTextField MU2Counter;
    private JTextField MU3Counter;
    private JTextField MU4Counter;
    private JTextField MU5Counter;
    private JTextField levelCounter;
    private ActionListener newGamListener = new NewGameListener();
    private ActionListener nomListener = new nomListener();
    private ActionListener shopListener = new shopListener();
    private ActionListener farmListener = new farmListener();
    private ActionListener gameListener = new gameListener();
    private ActionListener infoListener = new infoListener();

    private int numMU1 = 0;
    private int numMU2 = 0;
    private int numMU3 = 0;
    private int numMU4 = 0;
    private int numMU5 = 0;
    private int totNumU;

    private int numF1 = 0;
    private int numF2 = 0;
    private int numF3 = 0;
    private int numF4 = 0;
    private int numF5 = 0;
    private int totNumF;

    private BigInteger buffCost = BigInteger.valueOf(100);
    private BigInteger voidCost = BigInteger.valueOf(1000);
    private BigInteger shoeGazeCost = BigInteger.valueOf(100000000);
    private BigInteger gregSummonerCost = new BigInteger("10000000000000000000");
    private BigInteger indonesiaCost = new BigInteger("1000000000000000000000000000000000");

    private BigInteger StawHatCost = BigInteger.valueOf(10000);
    private BigInteger BioChamberCost = BigInteger.valueOf(10000000);
    private BigInteger ReactorCost = BigInteger.valueOf(10000000000L);
    private BigInteger PollosHermanosCost = new BigInteger("10000000000000000000000000000000000");
    private BigInteger KingInYellowCost = new BigInteger("100000000000000000000000000000000000000000000");

    private int currentState;

    private Border lineBorder = BorderFactory.createLineBorder(Color.black);

    private Farm FarmCell1 = new Farm(0, Farm1, "Straw Hat");
    private Farm FarmCell2 = new Farm(0, Farm2, "Bio Chamber");
    private Farm FarmCell3 = new Farm(0, Farm3, "Nuclear Reactor");
    private Farm FarmCell4 = new Farm(0, Farm4, "Los Pollos Hermanos");
    private Farm FarmCell5 = new Farm(0, Farm5, "The King In Yellow");

    private Farm[] Farmscells = new Farm[5];

    public ClickerGame() {
        this.noms = BigInteger.valueOf(0);
        this.Farms[0] = this.Farm1;
        this.Farms[1] = this.Farm2;
        this.Farms[2] = this.Farm3;
        this.Farms[3] = this.Farm4;
        this.Farms[4] = this.Farm5;
        this.totNumU = 0;

        this.Farmscells[0] = this.FarmCell1;
        this.Farmscells[1] = this.FarmCell2;
        this.Farmscells[2] = this.FarmCell3;
        this.Farmscells[3] = this.FarmCell4;
        this.Farmscells[4] = this.FarmCell5;

        this.currentLevel = 1;

        this.currentState = 0;

        setLayout(new BorderLayout());

        this.gamPanel = new JPanel();
        this.gamPanel.setLayout(new BorderLayout());
        this.gamPanel.setSize(440, 240);
        this.gamPanel.setBorder(lineBorder);

        this.statsPanel = new JPanel();
        this.statsPanel.setLayout(new BoxLayout(this.statsPanel, BoxLayout.X_AXIS));
        this.statsPanel.setSize(700, 130);
        this.statsPanel.setBackground(MurckyGreen);
        this.statsPanel.setBorder(lineBorder);

        ScrollPane Johnathan = new ScrollPane();
        Johnathan.setSize(130, 500);
        this.shopPanel = new JPanel();
        this.shopPanel.setLayout(new BoxLayout(this.shopPanel, BoxLayout.Y_AXIS));
        this.shopPanel.setSize(130, 500);
        this.shopPanel.setBackground(OxidizedBlue);
        this.shopPanel.setBorder(lineBorder);

        this.farmsUpgradPanel = new JPanel();
        this.farmsUpgradPanel.setLayout(new BoxLayout(this.farmsUpgradPanel, BoxLayout.Y_AXIS));
        this.farmsUpgradPanel.setSize(130, 500);
        this.farmsUpgradPanel.setBackground(OxidizedBlue);
        this.farmsUpgradPanel.setBorder(lineBorder);

        this.newGameWorldRecordPanel = new JPanel();
        this.newGameWorldRecordPanel.setLayout(new FlowLayout());
        this.newGameWorldRecordPanel.setSize(700, 130);

        // game
        this.gameMode0();

        // north
        JLabel nomsLabel = new JLabel("Noms: ");
        nomsLabel.setForeground(White);

        this.nomsCounter = new JTextField("" + this.noms);
        this.nomsCounter.setEditable(false);
        this.nomsCounter.setSize(700, 30);
        JLabel level = new JLabel("Level: ");
        level.setForeground(WinterBlue);
        this.levelCounter = new JTextField("" + this.currentLevel);
        this.levelCounter.setEditable(false);

        JButton infoJButton = new JButton();
        infoJButton.setSize(30, 30);
        infoJButton.setOpaque(false);
        infoJButton.setContentAreaFilled(false);
        infoJButton.setBorderPainted(false);
        infoJButton.setFocusPainted(false);
        infoJButton.addActionListener(infoListener);
        infoJButton.setIcon(infoIcon);

        this.statsPanel.add(nomsLabel);
        this.statsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
        this.statsPanel.add(this.nomsCounter);
        this.statsPanel.add(level);
        this.statsPanel.add(levelCounter);
        this.statsPanel.add(infoJButton);

        // east
        JButton Shop = new JButton();

        Shop.setIcon(shopIcon);
        Shop.setSize(30, 30);
        Shop.setOpaque(false);
        Shop.setContentAreaFilled(false);
        Shop.setBorderPainted(false);
        Shop.setFocusPainted(false);
        Shop.addActionListener(shopListener);

        JLabel john = new JLabel("Shop");
        john.setForeground(White);
        this.shopPanel.add(john);
        this.shopPanel.add(Shop);

        // south
        JLabel Record = new JLabel("Record: ");
        this.recordCounter = new JTextField(this.formatNoms(this.Record));
        this.recordCounter.setEditable(false);
        JButton newGameButton = new JButton("New Game");
        newGameButton.addActionListener(newGamListener);
        this.newGameWorldRecordPanel.add(Record);
        this.newGameWorldRecordPanel.add(recordCounter);
        this.newGameWorldRecordPanel.add(newGameButton);
        // west

        JButton Farms = new JButton();

        JLabel UpgradesJLabel = new JLabel("Upgrades");
        UpgradesJLabel.setForeground(White);
        this.farmsUpgradPanel.add(UpgradesJLabel);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ImageIcon MU5 = new ImageIcon(Upgrade5);
        JLabel MUpgrade5 = new JLabel();
        MUpgrade5.setSize(90, 90);
        MUpgrade5.setIcon(MU5);
        this.farmsUpgradPanel.add(MUpgrade5);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));
        this.MU5Counter = new JTextField("" + this.numMU5);
        this.MU5Counter.setEditable(false);
        this.farmsUpgradPanel.add(this.MU5Counter);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ImageIcon MU4 = new ImageIcon(Upgrade4);
        JLabel MUpgrade4 = new JLabel();
        MUpgrade4.setSize(90, 90);
        MUpgrade4.setIcon(MU4);
        this.farmsUpgradPanel.add(MUpgrade4);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));
        this.MU4Counter = new JTextField("" + this.numMU4);
        this.MU4Counter.setEditable(false);
        this.farmsUpgradPanel.add(this.MU4Counter);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ImageIcon MU3 = new ImageIcon(Upgrade3);
        JLabel MUpgrade3 = new JLabel();
        MUpgrade3.setSize(90, 90);
        MUpgrade3.setIcon(MU3);
        this.farmsUpgradPanel.add(MUpgrade3);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));
        this.MU3Counter = new JTextField("" + this.numMU3);
        this.MU3Counter.setEditable(false);
        this.farmsUpgradPanel.add(this.MU3Counter);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ImageIcon MU2 = new ImageIcon(Upgrade2);
        JLabel MUpgrade2 = new JLabel();
        MUpgrade2.setSize(90, 90);
        MUpgrade2.setIcon(MU2);
        this.farmsUpgradPanel.add(MUpgrade2);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));
        this.MU2Counter = new JTextField("" + this.numMU2);
        this.MU2Counter.setEditable(false);
        this.farmsUpgradPanel.add(this.MU2Counter);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ImageIcon MU1 = new ImageIcon(Upgrade1);
        JLabel MUpgrade1 = new JLabel();
        MUpgrade1.setSize(90, 90);
        MUpgrade1.setIcon(MU1);
        this.farmsUpgradPanel.add(MUpgrade1);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));
        this.MU1Counter = new JTextField("" + this.numMU1);
        this.MU1Counter.setEditable(false);
        this.farmsUpgradPanel.add(this.MU1Counter);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        Farms.setIcon(farmsIcon);
        Farms.setSize(30, 30);
        Farms.setOpaque(false);
        Farms.setContentAreaFilled(false);
        Farms.setBorderPainted(false);
        Farms.setFocusPainted(false);
        Farms.addActionListener(farmListener);

        JLabel FarmsJLabel = new JLabel("Farms");
        FarmsJLabel.setForeground(White);
        this.farmsUpgradPanel.add(FarmsJLabel);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));
        this.farmsUpgradPanel.add(Farms);
        this.farmsUpgradPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        Johnathan.add(this.farmsUpgradPanel);

        add(this.statsPanel, BorderLayout.NORTH);
        add(this.newGameWorldRecordPanel, BorderLayout.SOUTH);
        add(this.shopPanel, BorderLayout.EAST);
        add(Johnathan, BorderLayout.WEST);
        add(this.gamPanel, BorderLayout.CENTER);

        makeTimer();
    }

    // getters and setters

    public void makeTimer() {
        int delay = 1000;
        ActionListener taskPerformer = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                ClickerGame.this.farmMitosis();
                ClickerGame.this.levelUp();
                ClickerGame.this.revolt(ClickerGame.this.getCurrentLevel());
                if (ClickerGame.this.noms.compareTo(ClickerGame.this.Record) > 0) {
                    ClickerGame.this.Record = ClickerGame.this.noms;
                    if (ClickerGame.this.recordCounter != null) {
                        ClickerGame.this.recordCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.Record));
                    }
                }
                ClickerGame.this.levelCounter.setText("" + ClickerGame.this.currentLevel);
                ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
            }
        };
        new javax.swing.Timer(delay, taskPerformer).start();
    }

    public void setGameState(int gs) {
        this.currentState = gs;
    }

    public int getGameState() {
        return this.currentState;
    }

    public int getCurrentLevel() {
        return this.currentLevel;
    }

    public void checkNumU() {
        this.totNumU = this.numMU1 + this.numMU2 + this.numMU3 + this.numMU4 + this.numMU5;
    }

    public void checkNumF() {
        this.totNumF = this.numF1 + this.numF2 + this.numF3 + this.numF4 + this.numF5;
    }

    private String formatNoms(BigInteger n) {
        if (n == null)
            return "0";
        BigInteger longMax = BigInteger.valueOf(Long.MAX_VALUE);
        if (n.compareTo(longMax) <= 0) {
            return n.toString();
        }
        String s = n.toString();
        int len = s.length();
        if (len <= 3)
            return s;

        int sig = 3;
        String digits = s.substring(0, Math.min(sig, s.length()));
        StringBuilder sb = new StringBuilder();
        sb.append(digits.charAt(0));
        if (digits.length() > 1) {
            sb.append('.');
            sb.append(digits.substring(1));
        }
        sb.append("e+");
        sb.append(len - 1);
        return sb.toString();
    }

    public void revolt(int currentLevel) {
        if (this.getNumF() <= 0) {
            return;
        }

        if (this.currentClick < 100) {
            return;
        }

        this.currentClick = 0;

        ArrayList<Integer> available = new ArrayList<Integer>();
        for (int i = 0; i < this.Farmscells.length; i++) {
            if (this.Farmscells[i].getNumFarms() > 0) {
                available.add(i);
            }
        }

        if (available.isEmpty()) {
            return;
        }

        Random r = new Random();
        int index = available.get(r.nextInt(available.size()));

        this.Farmscells[index].revolt(currentLevel);

        switch (index) {
            case 0:
                this.numF1 = this.Farmscells[0].getNumFarms();
                this.Farmscells[0].setNumFarms(this.numF1);
                javax.swing.JOptionPane.showMessageDialog(ClickerGame.this,
                        "Some Straw Hats have revolted!",
                        "Check Farms", javax.swing.JOptionPane.WARNING_MESSAGE);
                break;
            case 1:
                this.numF2 = this.Farmscells[1].getNumFarms();
                this.Farmscells[1].setNumFarms(this.numF2);
                javax.swing.JOptionPane.showMessageDialog(ClickerGame.this,
                        "Some Bio Chambers have broken!",
                        "Check Farms", javax.swing.JOptionPane.WARNING_MESSAGE);
                break;
            case 2:
                this.numF3 = this.Farmscells[2].getNumFarms();
                this.Farmscells[2].setNumFarms(this.numF3);
                javax.swing.JOptionPane.showMessageDialog(ClickerGame.this,
                        "There was a nuclear meltdown",
                        "Check Farms", javax.swing.JOptionPane.WARNING_MESSAGE);
                break;
            case 3:
                this.numF4 = this.Farmscells[3].getNumFarms();
                this.Farmscells[3].setNumFarms(this.numF4);
                javax.swing.JOptionPane.showMessageDialog(ClickerGame.this,
                        "Your Cook has blown up the CEO!",
                        "Check Farms", javax.swing.JOptionPane.WARNING_MESSAGE);
                break;
            case 4:
                this.numF5 = this.Farmscells[4].getNumFarms();
                this.Farmscells[4].setNumFarms(this.numF5);
                javax.swing.JOptionPane.showMessageDialog(ClickerGame.this,
                        "The eugenics people sent your followers to the assylum, recrute more",
                        "Check Farms", javax.swing.JOptionPane.WARNING_MESSAGE);
                break;
        }

        this.checkNumF();
        this.nomsCounter.setText(this.formatNoms(this.noms));
        if (this.getGameState() == 2) {
            this.farmVisualizer();
        }
    }

    public void levelUp() {
        BigInteger Quota1 = BigInteger.valueOf(1000);
        BigInteger Quota2 = BigInteger.valueOf(1000000);
        BigInteger Quota3 = BigInteger.valueOf(1000000000);
        BigInteger Quota4 = BigInteger.valueOf(1000000000000L);
        BigInteger Quota5 = BigInteger.valueOf(1000000000000000L);
        BigInteger Quota6 = new BigInteger("1000000000000000000");
        BigInteger Quota7 = new BigInteger("1000000000000000000000");
        BigInteger Quota8 = new BigInteger("1000000000000000000000000");
        BigInteger Quota9 = new BigInteger("1000000000000000000000000000");
        BigInteger Quota10 = new BigInteger("1000000000000000000000000000000");
        BigInteger Quota11 = new BigInteger("1000000000000000000000000000000000");

        if (this.currentLevel < this.MAXLEVEL) {
            if (this.noms.compareTo(Quota1) >= 0 && this.currentLevel == 1) {
                this.currentLevel = 2;
            } else if (this.noms.compareTo(Quota2) >= 0 && this.currentLevel == 2) {
                this.currentLevel = 3;
            } else if (this.noms.compareTo(Quota3) >= 0 && this.currentLevel == 3) {
                this.currentLevel = 4;
            } else if (this.noms.compareTo(Quota4) >= 0 && this.currentLevel == 4) {
                this.currentLevel = 5;
            } else if (this.noms.compareTo(Quota5) >= 0 && this.currentLevel == 5) {
                this.currentLevel = 6;
            } else if (this.noms.compareTo(Quota6) >= 0 && this.currentLevel == 6) {
                this.currentLevel = 7;
            } else if (this.noms.compareTo(Quota7) >= 0 && this.currentLevel == 7) {
                this.currentLevel = 8;
            } else if (this.noms.compareTo(Quota8) >= 0 && this.currentLevel == 8) {
                this.currentLevel = 9;
            } else if (this.noms.compareTo(Quota9) >= 0 && this.currentLevel == 9) {
                this.currentLevel = 10;
            } else if (this.noms.compareTo(Quota10) >= 0 && this.currentLevel == 10) {
                this.currentLevel = 11;
            } else if (this.noms.compareTo(Quota11) >= 0 && this.currentLevel == 11) {
                this.currentLevel = 12;
            }
        }
    }

    public int getNumU() {
        this.checkNumU();
        return this.totNumU;
    }

    public int getNumF() {
        this.checkNumF();
        return this.totNumF;
    }

    public void gameMode0() {
        this.setGameState(0);
        this.gamPanel.removeAll();
        this.nomButton = new JButton();
        this.gamPanel.setBackground(DarkBlueGrey);
        this.nomButton.setIcon(frame1);
        this.nomButton.setOpaque(false);
        this.nomButton.setContentAreaFilled(false);
        this.nomButton.setBorderPainted(false);
        this.nomButton.setFocusPainted(false);
        this.nomButton.addActionListener(nomListener);
        this.gamPanel.add(this.nomButton, BorderLayout.SOUTH);

        if (this.getGameState() != 0) {
            this.nomButton.setEnabled(false);
        }

        this.revalidate();
    }

    public void openShop() {
        this.setGameState(1);
        this.gamPanel.removeAll();
        this.gamPanel.setBackground(DarkBrown);

        ScrollPane Shoping = new ScrollPane();
        Shoping.setBackground(OxidizedBlue);
        // huh, snoop dog, what
        Shoping.setSize(420, 350);
        JPanel ShopingPanel = new JPanel();
        ShopingPanel.setLayout(new BoxLayout(ShopingPanel, BoxLayout.Y_AXIS));

        ShopingPanel.setBackground(PineYeastGreen);
        JLabel SL = new JLabel();
        SL.setIcon(ShopLogo);

        ShopingPanel.add(SL);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        JLabel L = new JLabel("Upgrades");
        ShopingPanel.add(L);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ShopItem Buff = new ShopItem(this.Upgrade1, "Buff: Increase your strength 10 fold (with steroids) (* 10)",
                new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        if (ClickerGame.this.numMU1 >= MAXMUGRADE) {
                            return;
                        } else if (ClickerGame.this.noms.compareTo(ClickerGame.this.buffCost) >= 0) {
                            ClickerGame.this.noms = ClickerGame.this.noms.subtract(ClickerGame.this.buffCost);
                            ClickerGame.this.numMU1++;
                            ClickerGame.this.checkNumU();
                            ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                            ClickerGame.this.revalidate();
                        } else {
                            return;
                        }
                    }
                }, this.buffCost);
        if (this.numMU1 >= MAXMUGRADE) {
            Buff.Sold();
        } else if (this.noms.compareTo(this.buffCost) < 0) {
            Buff.NoMoney();
        }
        Buff.getBuyButton().addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (ClickerGame.this.noms.compareTo(ClickerGame.this.buffCost) < 0) {
                            Buff.NoMoney();
                        } else if (ClickerGame.this.numMU1 >= MAXMUGRADE) {
                            Buff.Sold();
                        } else {
                            Buff.InStock();
                        }
                        if (ClickerGame.this.MU1Counter != null)
                            ClickerGame.this.MU1Counter.setText("" + ClickerGame.this.numMU1);
                    }
                });
            }
        });
        ShopingPanel.add(Buff);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ShopItem Void = new ShopItem(this.Upgrade2, "Void: The Black Fluff will help you (+ 100)",
                new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        if (ClickerGame.this.numMU2 >= MAXMUGRADE) {
                            return;
                        } else if (ClickerGame.this.noms.compareTo(ClickerGame.this.voidCost) >= 0) {
                            ClickerGame.this.noms = ClickerGame.this.noms.subtract(ClickerGame.this.voidCost);
                            ClickerGame.this.numMU2++;
                            ClickerGame.this.checkNumU();
                            ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                            ClickerGame.this.revalidate();
                        } else {
                            return;
                        }
                    }
                }, this.voidCost);
        if (this.numMU2 >= MAXMUGRADE) {
            Void.Sold();
        } else if (this.noms.compareTo(this.voidCost) < 0) {
            Void.NoMoney();
        }
        Void.getBuyButton().addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (ClickerGame.this.noms.compareTo(ClickerGame.this.voidCost) < 0) {
                            Void.NoMoney();
                        } else if (ClickerGame.this.numMU2 >= MAXMUGRADE) {
                            Void.Sold();
                        } else {
                            Void.InStock();
                        }
                        if (ClickerGame.this.MU2Counter != null)
                            ClickerGame.this.MU2Counter.setText("" + ClickerGame.this.numMU2);
                    }
                });
            }
        });
        ShopingPanel.add(Void);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ShopItem ShoeGaze = new ShopItem(this.Upgrade3,
                "Boot: Put on some majic boots; increase your power 100 fold (* 100)",
                new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        if (ClickerGame.this.numMU3 >= MAXMUGRADE) {
                            return;
                        } else if (ClickerGame.this.noms.compareTo(ClickerGame.this.shoeGazeCost) >= 0) {
                            ClickerGame.this.noms = ClickerGame.this.noms.subtract(ClickerGame.this.shoeGazeCost);
                            ClickerGame.this.numMU3++;
                            ClickerGame.this.checkNumU();
                            ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                            ClickerGame.this.revalidate();
                        } else {
                            return;
                        }
                    }
                }, this.shoeGazeCost);
        if (this.numMU3 >= MAXMUGRADE) {
            ShoeGaze.Sold();
        } else if (this.noms.compareTo(this.shoeGazeCost) < 0) {
            ShoeGaze.NoMoney();
        }
        ShoeGaze.getBuyButton().addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (ClickerGame.this.noms.compareTo(ClickerGame.this.shoeGazeCost) < 0) {
                            ShoeGaze.NoMoney();
                        } else if (ClickerGame.this.numMU3 >= MAXMUGRADE) {
                            ShoeGaze.Sold();
                        } else {
                            ShoeGaze.InStock();
                        }
                        if (ClickerGame.this.MU3Counter != null)
                            ClickerGame.this.MU3Counter.setText("" + ClickerGame.this.numMU3);
                    }
                });
            }
        });
        ShopingPanel.add(ShoeGaze);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ShopItem Pentagram = new ShopItem(this.Upgrade4,
                "Demonic Majic: Mr Boss let us use his 1/4 of hell to frack for demonic majic to help us take over the world :3 (^ 2)",
                new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        if (ClickerGame.this.numMU4 >= MAXMUGRADE) {
                            return;
                        } else if (ClickerGame.this.noms.compareTo(ClickerGame.this.gregSummonerCost) >= 0) {
                            ClickerGame.this.noms = ClickerGame.this.noms.subtract(ClickerGame.this.gregSummonerCost);
                            ClickerGame.this.numMU4++;
                            ClickerGame.this.checkNumU();
                            ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                            ClickerGame.this.revalidate();
                        } else {
                            return;
                        }
                    }
                }, this.gregSummonerCost);
        if (this.numMU4 >= MAXMUGRADE) {
            Pentagram.Sold();
        } else if (this.noms.compareTo(this.gregSummonerCost) < 0) {
            Pentagram.NoMoney();
        }
        Pentagram.getBuyButton().addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (ClickerGame.this.noms.compareTo(ClickerGame.this.gregSummonerCost) < 0) {
                            Pentagram.NoMoney();
                        } else if (ClickerGame.this.numMU4 >= MAXMUGRADE) {
                            Pentagram.Sold();
                        } else {
                            Pentagram.InStock();
                        }
                        if (ClickerGame.this.MU4Counter != null)
                            ClickerGame.this.MU4Counter.setText("" + ClickerGame.this.numMU4);
                    }
                });
            }
        });
        ShopingPanel.add(Pentagram);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ShopItem indonesia = new ShopItem(this.Upgrade5, "Indonesia: 1700 islands, all to you (+ 1700)",
                new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        if (ClickerGame.this.numMU5 >= MAXMUGRADE) {
                            return;
                        } else if (ClickerGame.this.noms.compareTo(ClickerGame.this.indonesiaCost) >= 0) {
                            ClickerGame.this.noms = ClickerGame.this.noms.subtract(ClickerGame.this.indonesiaCost);
                            ClickerGame.this.numMU5++;
                            ClickerGame.this.checkNumU();
                            ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                            ClickerGame.this.revalidate();
                        } else {
                            return;
                        }
                    }
                }, this.indonesiaCost);
        if (this.numMU5 >= MAXMUGRADE) {
            indonesia.Sold();
        } else if (this.noms.compareTo(this.indonesiaCost) < 0) {
            indonesia.NoMoney();
        }
        indonesia.getBuyButton().addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (ClickerGame.this.noms.compareTo(ClickerGame.this.indonesiaCost) < 0) {
                            indonesia.NoMoney();
                        } else if (ClickerGame.this.numMU5 >= MAXMUGRADE) {
                            indonesia.Sold();
                        } else {
                            indonesia.InStock();
                        }
                        if (ClickerGame.this.MU5Counter != null)
                            ClickerGame.this.MU5Counter.setText("" + ClickerGame.this.numMU5);
                    }
                });
            }
        });
        ShopingPanel.add(indonesia);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        JLabel S = new JLabel("Farms");
        ShopingPanel.add(S);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ShopItem BasicFarm = new ShopItem(this.Farms[0], "Straw Hat: the most basic of farms (100 noms per second)",
                new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        if (ClickerGame.this.numF1 >= MAXFARM) {
                            return;
                        } else if (ClickerGame.this.noms.compareTo(ClickerGame.this.StawHatCost) >= 0) {
                            ClickerGame.this.noms = ClickerGame.this.noms.subtract(ClickerGame.this.StawHatCost);
                            ClickerGame.this.numF1++;
                            ClickerGame.this.checkNumF();
                            ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                            ClickerGame.this.revalidate();
                        } else {
                            return;
                        }
                    }
                }, this.StawHatCost);
        if (this.numF1 >= MAXFARM) {
            BasicFarm.Sold();
        } else if (this.noms.compareTo(this.StawHatCost) < 0) {
            BasicFarm.NoMoney();
        }
        BasicFarm.getBuyButton().addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (ClickerGame.this.noms.compareTo(ClickerGame.this.StawHatCost) < 0) {
                            BasicFarm.NoMoney();
                        } else if (ClickerGame.this.numF1 >= MAXFARM) {
                            BasicFarm.Sold();
                        } else {
                            BasicFarm.InStock();
                        }
                        ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                    }
                });
            }
        });
        ShopingPanel.add(BasicFarm);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ShopItem Bio = new ShopItem(this.Farms[1],
                "Bio Chamber: usfull tool that doubles production (doubles noms per second)",
                new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        if (ClickerGame.this.numF2 >= MAXFARM) {
                            return;
                        } else if (ClickerGame.this.noms.compareTo(ClickerGame.this.BioChamberCost) >= 0) {
                            ClickerGame.this.noms = ClickerGame.this.noms.subtract(ClickerGame.this.BioChamberCost);
                            ClickerGame.this.numF2++;
                            ClickerGame.this.checkNumF();
                            ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                            ClickerGame.this.revalidate();
                        } else {
                            return;
                        }
                    }
                }, this.BioChamberCost);
        if (this.numF2 >= MAXFARM) {
            Bio.Sold();
        } else if (this.noms.compareTo(this.BioChamberCost) < 0) {
            Bio.NoMoney();
        }
        Bio.getBuyButton().addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (ClickerGame.this.noms.compareTo(ClickerGame.this.BioChamberCost) < 0) {
                            Bio.NoMoney();
                        } else if (ClickerGame.this.numF2 >= MAXFARM) {
                            Bio.Sold();
                        } else {
                            Bio.InStock();
                        }
                        ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                    }
                });
            }
        });
        ShopingPanel.add(Bio);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ShopItem Reactor = new ShopItem(this.Farms[2],
                "Nuclear Reactor: Speeds up the prossess to have one of these (^2)",
                new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        if (ClickerGame.this.numF3 >= MAXFARM) {
                            return;
                        } else if (ClickerGame.this.noms.compareTo(ClickerGame.this.ReactorCost) >= 0) {
                            ClickerGame.this.noms = ClickerGame.this.noms.subtract(ClickerGame.this.ReactorCost);
                            ClickerGame.this.numF3++;
                            ClickerGame.this.checkNumF();
                            ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                            ClickerGame.this.revalidate();
                        } else {
                            return;
                        }
                    }
                }, this.ReactorCost);
        if (this.numF3 >= MAXFARM) {
            Reactor.Sold();
        } else if (this.noms.compareTo(this.ReactorCost) < 0) {
            Reactor.NoMoney();
        }
        Reactor.getBuyButton().addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (ClickerGame.this.noms.compareTo(ClickerGame.this.ReactorCost) < 0) {
                            Reactor.NoMoney();
                        } else if (ClickerGame.this.numF3 >= MAXFARM) {
                            Reactor.Sold();
                        } else {
                            Reactor.InStock();
                        }
                        ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                    }
                });
            }
        });
        ShopingPanel.add(Reactor);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ShopItem Pollos = new ShopItem(this.Farms[3],
                "Los Pollos Hermanos: Why not open up some super labs in an industrial laundry mat (100000 noms per second)",
                new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        if (ClickerGame.this.numF4 >= MAXFARM) {
                            return;
                        } else if (ClickerGame.this.noms.compareTo(ClickerGame.this.PollosHermanosCost) >= 0) {
                            ClickerGame.this.noms = ClickerGame.this.noms.subtract(ClickerGame.this.PollosHermanosCost);
                            ClickerGame.this.numF4++;
                            ClickerGame.this.checkNumF();
                            ClickerGame.this.nomsCounter.setText(ClickerGame.this.noms.toString());
                            ClickerGame.this.revalidate();
                        } else {

                            return;
                        }
                    }
                }, this.PollosHermanosCost);
        if (this.numF4 >= MAXFARM) {
            Pollos.Sold();
        } else if (this.noms.compareTo(this.PollosHermanosCost) < 0) {
            Pollos.NoMoney();
        }
        Pollos.getBuyButton().addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (ClickerGame.this.noms.compareTo(ClickerGame.this.PollosHermanosCost) < 0) {
                            Pollos.NoMoney();
                        } else if (ClickerGame.this.numF4 >= MAXFARM) {
                            Pollos.Sold();
                        } else {
                            Pollos.InStock();
                        }
                        ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                    }
                });
            }
        });
        ShopingPanel.add(Pollos);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        ShopItem King = new ShopItem(this.Farms[4],
                "The King in Yellow: give them the yellow sign(*1000) ",
                new java.awt.event.ActionListener() {
                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        if (ClickerGame.this.numF5 >= MAXFARM) {
                            return;
                        } else if (ClickerGame.this.noms.compareTo(ClickerGame.this.KingInYellowCost) >= 0) {
                            ClickerGame.this.noms = ClickerGame.this.noms.subtract(ClickerGame.this.KingInYellowCost);
                            ClickerGame.this.numF5++;
                            ClickerGame.this.checkNumF();
                            ClickerGame.this.nomsCounter.setText(ClickerGame.this.noms.toString());
                            ClickerGame.this.revalidate();
                        } else {
                            return;
                        }
                    }
                }, this.KingInYellowCost);
        if (this.numF5 >= MAXFARM) {
            King.Sold();
        } else if (this.noms.compareTo(this.KingInYellowCost) < 0) {
            King.NoMoney();
        }
        King.getBuyButton().addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (ClickerGame.this.noms.compareTo(ClickerGame.this.KingInYellowCost) < 0) {
                            King.NoMoney();
                        } else if (ClickerGame.this.numF5 >= MAXFARM) {
                            King.Sold();
                        } else {
                            King.InStock();
                        }
                        ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));
                    }
                });
            }
        });
        ShopingPanel.add(King);
        ShopingPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        Shoping.add(ShopingPanel);
        JButton exit = new JButton("Exit");
        exit.addActionListener(gameListener);
        this.gamPanel.add(Shoping, BorderLayout.CENTER);
        this.gamPanel.add(exit, BorderLayout.SOUTH);

        this.revalidate();
    }

    public void farmVisualizer() {
        this.setGameState(2);
        this.gamPanel.removeAll();
        this.gamPanel.setBackground(DarkPurpleGrey);

        ScrollPane FarmPane = new ScrollPane();
        FarmPane.setBackground(OxidizedBlue);
        // huh, snoop dog, what
        FarmPane.setSize(420, 350);
        JPanel FarmPanel = new JPanel();
        FarmPanel.setLayout(new BoxLayout(FarmPanel, BoxLayout.Y_AXIS));

        FarmPanel.setBackground(PineYeastGreen);

        JLabel FL = new JLabel();
        FL.setIcon(this.FarmsLogo);
        FarmPanel.add(FL);
        FarmPanel.add(Box.createRigidArea(new Dimension(0, 5)));

        this.Farmscells[0].setNumFarms(numF1);
        this.Farmscells[1].setNumFarms(numF2);
        this.Farmscells[2].setNumFarms(numF3);
        this.Farmscells[3].setNumFarms(numF4);
        this.Farmscells[4].setNumFarms(numF5);

        for (int i = 0; i < this.Farmscells.length; i++) {
            String forg = this.Farmscells[i].getFarmName();
            JLabel s = new JLabel(forg);
            FarmPanel.add(s);
            FarmPanel.add(this.Farmscells[i]);
            FarmPanel.add(Box.createRigidArea(new Dimension(0, 5)));
        }
        JButton exit = new JButton("Exit");
        exit.addActionListener(gameListener);
        FarmPane.add(FarmPanel);
        this.gamPanel.add(FarmPane, BorderLayout.CENTER);
        this.gamPanel.add(exit, BorderLayout.SOUTH );

        

        this.revalidate();
    }

    public void forceMitosis() {
        BigInteger newPower = BigInteger.ONE;
        this.currentClick++;
        if (this.numMU2 > 0) {
            newPower = newPower.add(BigInteger.valueOf(100L).multiply(BigInteger.valueOf(this.numMU2)));
        }

        if (this.numMU5 > 0) {
            newPower = newPower.add(BigInteger.valueOf(1700L).multiply(BigInteger.valueOf(this.numMU5)));
        }

        if (this.numMU1 > 0) {
            newPower = newPower.multiply(BigInteger.valueOf(10).pow(this.numMU1));
        }

        if (this.numMU3 > 0) {
            newPower = newPower.multiply(BigInteger.valueOf(100).pow(this.numMU3));
        }

        for (int i = 0; i < this.numMU4; i++) {
            newPower = newPower.pow(2);
        }

        this.noms = this.noms.add(newPower);

    }

    public void farmMitosis() {
        if (this.getNumF() == 0) {
            return;
        }

        BigInteger production = BigInteger.ZERO;

        if (this.numF1 > 0) {
            production = production.add(BigInteger.valueOf(100L).multiply(BigInteger.valueOf(this.numF1)));
        }

        if (this.numF2 > 0) {
            production = production.add(BigInteger.valueOf(10000L).multiply(BigInteger.valueOf(this.numF2)));
        }

        if (this.numF3 > 0) {
            production = production.add(BigInteger.valueOf(1000000L).multiply(BigInteger.valueOf(this.numF3)));
        }

        if (this.numF4 > 0) {
            production = production.add(BigInteger.valueOf(100000L).multiply(BigInteger.valueOf(this.numF4)));
        }

        if (this.numF5 > 0) {
            production = production.add(BigInteger.valueOf(1000000000L).multiply(BigInteger.valueOf(this.numF5)));
        }

        if (this.numMU2 > 0) {
            production = production.add(BigInteger.valueOf(100L).multiply(BigInteger.valueOf(this.numMU2)));
        }

        if (this.numMU5 > 0) {
            production = production.add(BigInteger.valueOf(1700L).multiply(BigInteger.valueOf(this.numMU5)));
        }

        if (this.numMU1 > 0) {
            production = production.multiply(BigInteger.valueOf(10).pow(this.numMU1));
        }

        if (this.numMU3 > 0) {
            production = production.multiply(BigInteger.valueOf(100).pow(this.numMU3));
        }

        for (int i = 0; i < this.numMU4; i++) {
            production = production.pow(2);
        }

        this.noms = this.noms.add(production);
    }

    // action listeners

    private void resetGame() {
        if (this.noms.compareTo(this.Record) > 0) {
            this.Record = this.noms;
            this.recordCounter.setText(this.formatNoms(this.Record));
        }

        this.noms = BigInteger.ZERO;
        this.currentLevel = 1;
        this.currentClick = 0;
        this.numMU1 = 0;
        this.numMU2 = 0;
        this.numMU3 = 0;
        this.numMU4 = 0;
        this.numMU5 = 0;
        this.numF1 = 0;
        this.numF2 = 0;
        this.numF3 = 0;
        this.numF4 = 0;
        this.numF5 = 0;
        this.totNumU = 0;
        this.totNumF = 0;

        if (this.nomsCounter != null)
            this.nomsCounter.setText(this.formatNoms(this.noms));
        if (this.MU1Counter != null)
            this.MU1Counter.setText("0");
        if (this.MU2Counter != null)
            this.MU2Counter.setText("0");
        if (this.MU3Counter != null)
            this.MU3Counter.setText("0");
        if (this.MU4Counter != null)
            this.MU4Counter.setText("0");
        if (this.MU5Counter != null)
            this.MU5Counter.setText("0");
        if (this.levelCounter != null)
            this.levelCounter.setText("" + this.currentLevel);

        for (Farm farmCell : this.Farmscells) {
            farmCell.setNumFarms(0);
        }
        this.gameMode0();
    }

    private class NewGameListener implements java.awt.event.ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            ClickerGame.this.resetGame();
            ClickerGame.this.revalidate();
        }
    }

    private class nomListener implements java.awt.event.ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            ClickerGame.this.forceMitosis();
            ClickerGame.this.nomsCounter.setText(ClickerGame.this.formatNoms(ClickerGame.this.noms));

            if (ClickerGame.this.nomButton != null) {
                // Animate through frames 1-7
                ImageIcon[] frames = {
                        ClickerGame.this.frame1, ClickerGame.this.frame2, ClickerGame.this.frame3,
                        ClickerGame.this.frame4, ClickerGame.this.frame5, ClickerGame.this.frame6,
                        ClickerGame.this.frame7
                };

                final int[] frameIndex = { 0 };
                javax.swing.Timer animTimer = new javax.swing.Timer(100, new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (ClickerGame.this.nomButton != null && frameIndex[0] < frames.length) {
                            ClickerGame.this.nomButton.setIcon(frames[frameIndex[0]]);
                            frameIndex[0]++;
                        } else {
                            if (ClickerGame.this.nomButton != null) {
                                ClickerGame.this.nomButton.setIcon(ClickerGame.this.frame1);
                            }
                            ((javax.swing.Timer) evt.getSource()).stop();
                        }
                    }
                });
                animTimer.setRepeats(true);
                animTimer.start();
            }
        }
    }

    private class shopListener implements java.awt.event.ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            ClickerGame.this.openShop();
        }
    }

    private class farmListener implements java.awt.event.ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            ClickerGame.this.farmVisualizer();
        }
    }

    private class gameListener implements java.awt.event.ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            ClickerGame.this.gameMode0();
        }
    }

    private class infoListener implements java.awt.event.ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (ClickerGame.this.getGameState() == 0) {
                javax.swing.JOptionPane.showMessageDialog(ClickerGame.this,
                        "Welcome to nom clicker, your goal is to take over the world with noms."
                                + "\n What is a nom you ask, they are a very simple muti-cellualr life form, \n"
                                + "they have eyes, a digestive tract, and a brain only capible of feeling love anger and hunger.\n"
                                + " you must click the mother of all noms to mitosis some off of them, you can force mitosis noms with farms,\n"
                                + " and use 'upgrages' (its literaly just witch craft) to improve your mitosis yealds per click \n"
                                + "the upgrades and farms are calculated in reverse pemdos",
                        "Welcome", javax.swing.JOptionPane.INFORMATION_MESSAGE);
            } else if (ClickerGame.this.getGameState() == 1) {
                javax.swing.JOptionPane.showMessageDialog(ClickerGame.this,
                        "Welcome to the Shop, this is where you all your farms and upgrades \n"
                                + "Upgrades improve your clicking power and farms force mitosis noms for you or make energy for other farms \n"
                                + "remember to check on your farms, because sometimes they revolt and you lose them, \n"
                                + "when they revolt you lose one or half of them"
                                + "* None of the farms or upgrades are balanced, you will get absurd numbers",
                        "Welcome to the Shop", javax.swing.JOptionPane.INFORMATION_MESSAGE);
            } else if (ClickerGame.this.getGameState() == 2) {
                javax.swing.JOptionPane.showMessageDialog(ClickerGame.this,
                        "Welcome to the farm hole, this is where you can check on your farms and noms per second \n"
                                + "every day these farms will be forcing mitosis on noms to help YOU take over the world, but it is a grouling task \n"
                                + "every few clicks your farmers will hold a vote in secressy and if they choose to they will revolt \n"
                                + "a revolt can be one farm leaving or half of them, the higher YOUR level is the more work they have to do, \n"
                                + "so keep an eye on your farms (they are replacable)",
                        "Welcome to Your Farms", javax.swing.JOptionPane.INFORMATION_MESSAGE);
            } else {
                javax.swing.JOptionPane.showMessageDialog(ClickerGame.this,
                        "Something has gone horribly wronge with the game state system and WE ARE ALL GOING TO DIE BECAUSE OF IT, THE NOMS HAB+VE BREACHED CONTAINMEN. GET OUT NOW",
                        "yippi", javax.swing.JOptionPane.ERROR_MESSAGE);
            }

        }
    }

}