package com.hotmail.kalebmarc.textfighter.main;

import com.hotmail.kalebmarc.textfighter.item.FirstAid;
import com.hotmail.kalebmarc.textfighter.item.InstaHealth;
import com.hotmail.kalebmarc.textfighter.item.Power;
import com.hotmail.kalebmarc.textfighter.player.*;

import java.util.Scanner;

public class Cheats {

    //Variables
    private static Scanner cheat = new Scanner(System.in);
    private static boolean enabled = false;
    private static boolean locked = false;

    public static void cheatGateway() {

        //Makes sure cheats aren't locked
        if (locked()) {
            Ui.msg("Cheats are locked off- You cannot use cheats!");
            return;
        }

        if (!enabled()) {
            int confirm = Ui.confirmPopup("If you enable cheats, achievements and xp will be disabled. Are you sure you want to continue?", "Warning");
            if (confirm == 0) {
                Xp.setAll(0, 0, 10);
                enable();
            }
        }
        if (enabled()) Cheats.cheatSelect();
    }

    private static void cheatSelect() {
        Ui.println("*");

        switch (cheat.nextLine()) {
            case "moneylover":
                Coins.set(1000, false);
                Stats.timesCheated++;
                break;
            case "givemeitall":
                Coins.set(5000, false);
                FirstAid.set(5000, false);
                InstaHealth.set(5000, false);
                for (int i = 0; i < Weapon.getWeapons().size(); i++) {
                    Weapon.getWeapons().get(i).setAmmo(5000, false);
                }
                Power.set(5000, false);
                for (int i = 0; i < Weapon.getWeapons().size(); i++) {
                    Weapon.getWeapons().get(i).owns = true;
                }
                Stats.timesCheated++;
                for (int i = 0; i < Food.getFoods().size(); i++)
                    Food.getFoods().get(i).setQuantity(5000);
                Potion.set("Survival", 5000, false);
                Potion.set("Recovery", 5000, false);
                break;
            case "weaponstash":
                for (int i = 0; i < Weapon.arrayWeapon.size(); i++) {
                    Weapon.arrayWeapon.get(i).setAmmo(5000, false);
                }

                Power.set(5000, false);
                for (int i = 0; i < Weapon.getWeapons().size(); i++) {
                    Weapon.getWeapons().get(i).owns = true;
                }
                Stats.timesCheated++;
                break;
            case "nomorepain":
                FirstAid.set(1000, false);
                InstaHealth.set(500, false);
                Potion.set("Survival", 500, false);
                Potion.set("Recovery", 500, false);
                for (int i = 0; i < Food.getFoods().size(); i++)
                    Food.getFoods().get(i).setQuantity(100);
                Stats.timesCheated++;
                break;
            case "healme":
                Health.set(Health.getOutOf());
                Stats.timesCheated++;
                break;
            case "givemeachallenge":
                Enemy.get().setHealth(1000, 1000);
                Stats.timesCheated++;
                break;
            case "lotsofkills":
                Stats.kills = 5000;
                Stats.timesCheated++;
                break;
            case "suicide":
                Health.die();
                Stats.timesCheated++;
                break;
            case "godmode":
                Settings.toggleGodMode();
                Stats.timesCheated++;
                break;
            case "loanshark":
                Loan.setCurrentLoan(0);
                Loan.setNetDue(0);
                Stats.timesCheated++;
                break;
            case "thirstforfood":
                for (int i = 0; i < Food.getFoods().size(); i++)
                    Food.getFoods().get(i).setQuantity(10);
                Stats.timesCheated++;
                break;

        }
    }

    public static boolean enabled() {
        return enabled;
    }

    public static boolean locked() {
        return locked;
    }

    public static void enable() {
        enabled = true;
    }

    public static void lock() {
        locked = true;
    }
}
@@ -1097,16 +1097,48 @@
 (%22*%22);%0A%0A
+        boolean cheated = true;%0A
         
@@ -1240,46 +1240,8 @@
 e);%0A
-                Stats.timesCheated++;%0A
     
@@ -1771,46 +1771,8 @@
   %7D%0A
-                Stats.timesCheated++;%0A
     
@@ -2405,46 +2405,8 @@
   %7D%0A
-                Stats.timesCheated++;%0A
     
@@ -2777,46 +2777,8 @@
 0);%0A
-                Stats.timesCheated++;%0A
     
@@ -2874,46 +2874,8 @@
 ));%0A
-                Stats.timesCheated++;%0A
     
@@ -2985,46 +2985,8 @@
 0);%0A
-                Stats.timesCheated++;%0A
     
@@ -3076,46 +3076,8 @@
 00;%0A
-                Stats.timesCheated++;%0A
     
@@ -3157,46 +3157,8 @@
 ();%0A
-                Stats.timesCheated++;%0A
     
@@ -3250,46 +3250,8 @@
 ();%0A
-                Stats.timesCheated++;%0A
     
@@ -3378,46 +3378,8 @@
 0);%0A
-                Stats.timesCheated++;%0A
     
@@ -3576,63 +3576,120 @@
     
-Stats.timesCheated++;%0A                break;%0A%0A        %7D
+break;%0A            default:%0A                cheated = false;%0A        %7D%0A        if(cheated) Stats.timesCheated++;
 %0A   

Remove code duplication from Cheats.java