我今天更新了它,但它突然停止了工作。一旦我输入任何文本,它将转到下一行并冻结。我尝试删除我添加的部分,现在它仍然这样做。我将发布下面的代码,但它真的很大[400多行]所以如果你们中的任何人都能弄清楚什么是错误的话需要一些时间来阅读。提前谢谢!
import java.util.*;
public class OpeningGame
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in);
String spooky;
int commonkey = 5;
int money = 0;
int uncommon = 0;
int common = 0;
int rare = 0;
int legendary = 0;
int exotic = 0;
int number = 0;
int keyinput;
int relic = 0;
int rarekey = 0;
String sellterm;
int sell;
int legendarykey = 0;
int rune = 0;
int xp = 0;
int level = 1;
int xpcap = 100;
int doublesell = 1;
int upgradepoint = 0;
String upgradeterm;
int earnupgrade = 1;
int exotickey = 0;
int ancient = 0;
int prestige = 0;
System.out.println("Type case to see your cases. Type open common to open a common case. Type open rare to open a rare case. Type buy common to buy a common key.");
System.out.println("Type money to check money. Type sell to sell your items. Type inventory to see your items. Type ");
System.out.println("Type buy rare to buy a rare key. Type buy legendary to buy a legendary key. Type open legendary to open a legendary case");
do
{
System.out.println(" ");
System.out.print("Enter a keyword: ");
spooky = keyboard.nextLine();
if (spooky.equals("xp"))
{
System.out.println(xp + "/" + xpcap);
}
// COMMON CASE OPENINGS
if (spooky.equals("open common") || spooky.equals("Open Common"))
{
if (commonkey >= 1)
{
number = (int)(Math.random() * 100) + 1;
if (number < 51 && number >= 1)
{
System.out.println("You found a common.");
System.out.println(" ");
common ++;
xp += 10;
}
else if (number < 55 && number >= 51)
{
System.out.println("You found a legendary!");
System.out.println(" ");
legendary ++;
xp += 75;
}
else if (number < 59 && number >= 55)
{
System.out.println("You found an EXOTIC!");
System.out.println(" ");
exotic++;
xp += 250;
}
else if (number < 66 && number >= 59)
{
System.out.println("You found a rare!");
System.out.println(" ");
rare++;
xp += 50;
}
else if (number <= 100 && number >= 66)
{
System.out.println("You found an uncommon");
System.out.println(" ");
uncommon++;
xp += 25;
}
commonkey--;
}
else
{
System.out.println("You do not have any keys. Buy some");
}
}
// RARE CASE OPENINGS
if (spooky.equals("open rare") || spooky.equals("Open Rare"))
{
if (rarekey >= 1)
{
number = (int)(Math.random() * 100) + 1;
if (number < 51 && number >= 1)
{
System.out.println("You found a common.");
System.out.println(" ");
common ++;
xp += 10;
}
else if (number < 80 && number >= 51)
{
System.out.println("You found a legendary!");
System.out.println(" ");
legendary ++;
xp += 75;
}
else if (number < 95 && number >= 80)
{
System.out.println("You found an EXOTIC!");
System.out.println(" ");
exotic++;
xp += 250;
}
else if (number <= 100 && number >= 95)
{
System.out.println("You found a RELIC!!!!");
System.out.println(" ");
relic++;
xp += 1000;
}
rarekey--;
}
else
{
System.out.println("You do not have any keys. Buy some");
}
}
// Legendary case
if (spooky.equals("open legendary") || spooky.equals("Open Legendary"))
{
if (legendarykey >= 1)
{
number = (int)(Math.random() * 100) + 1;
if (number < 25 && number >= 1)
{
System.out.println("You found a rare.");
System.out.println(" ");
rare ++;
xp += 50;
}
else if (number < 51 && number >= 25)
{
System.out.println("You found a legendary!");
System.out.println(" ");
legendary ++;
xp += 75;
}
else if (number < 70 && number >= 51)
{
System.out.println("You found an EXOTIC!");
System.out.println(" ");
exotic++;
xp += 250;
}
else if (number <= 95 && number >= 70)
{
System.out.println("You found a RELIC!!!!");
System.out.println(" ");
relic++;
xp += 1000;
}
else if (number <= 100 && number >= 95)
{
System.out.println("YOU FOUND A RUNE!!!!");
System.out.println(" ");
rune++;
xp += 10000;
}
legendarykey--;
}
else
{
System.out.println("You do not have any keys. Buy some");
}
}
if (spooky.equals("open exotic") || spooky.equals("Open Exotic"))
{
if (exotickey >= 1)
{
number = (int)(Math.random() * 100) + 1;
if (number < 25 && number >= 1)
{
System.out.println("You found a rare.");
System.out.println(" ");
rare ++;
xp += 50;
}
else if (number < 51 && number >= 25)
{
System.out.println("You found a exotic!");
System.out.println(" ");
exotic ++;
xp += 250;
}
else if (number < 70 && number >= 51)
{
System.out.println("You found a RELIC!");
System.out.println(" ");
relic++;
xp += 1000;
}
else if (number <= 95 && number >= 70)
{
System.out.println("You found a RUNE!!!!");
System.out.println(" ");
rune++;
xp += 10000;
}
else if (number <= 100 && number >= 95)
{
System.out.println("YOU FOUND AN ANCIENT!!!!");
System.out.println(" ");
ancient++;
xp += 100000;
}
exotickey--;
}
else
{
System.out.println("You do not have any keys. Buy some");
}
}
if (spooky.equals("buy common") || spooky.equals("Buy Common"))
{
System.out.println("Type how many keys you would like to buy: ");
keyinput = keyboard.nextInt();
if (money >= (5 * keyinput))
{
commonkey = commonkey + keyinput;
money = money - (keyinput * 5);
}
else if (money < (5 * keyinput))
{
System.out.println("You do not have enough money for the keys.");
System.out.println(" ");
}
}
if (spooky.equals("levelcheck"))
{
System.out.println("You are level " + level + ". You are prestige " + prestige + ".");
}
if (spooky.equals("buy rare") || spooky.equals("Buy Rare"))
{
System.out.println("Type how many keys you would like to buy: ");
keyinput = keyboard.nextInt();
if (money >= (250 * keyinput))
{
rarekey = rarekey + keyinput;
money = money - (keyinput * 250);
}
else if (money < (250 * keyinput))
{
System.out.println("You do not have enough money for the keys.");
System.out.println(" ");
}
}
// legendary key
if (spooky.equals("buy legendary") || spooky.equals("Buy Legendary"))
{
System.out.println("Type how many keys you would like to buy: ");
keyinput = keyboard.nextInt();
if (money >= (2500 * keyinput))
{
legendarykey = legendarykey + keyinput;
money = money - (keyinput * 2500);
}
else if (money < (2500 * keyinput))
{
System.out.println("You do not have enough money for the keys.");
System.out.println(" ");
}
}
if (spooky.equals("buy exotic") || spooky.equals("Buy Exotic"))
{
System.out.println("Type how many keys you would like to buy: ");
keyinput = keyboard.nextInt();
if (money >= (250000 * keyinput))
{
exotickey = exotickey + keyinput;
money = money - (keyinput * 250000);
}
else if (money < (250000 * keyinput))
{
System.out.println("You do not have enough money for the keys.");
System.out.println(" ");
}
}
if (spooky.equals("money") || spooky.equals("Money"))
{
System.out.println("You have $" + money + ".");
System.out.println(" ");
}
if (spooky.equals("inventory") || spooky.equals("Inventory"))
{
System.out.println("You have " + common + " commons. You have " + uncommon + " uncommons. You have " + rare + " rares. You have " + legendary + " legendaries. You have " + exotic + " exotics. You have " + relic + " relics. You have " + rune + " runes.");
System.out.println("You have " + ancient + " ancients.");
System.out.println(" ");
}
if (spooky.equals("earn") || spooky.equals("Earn"))
{
System.out.println("+ $1");
money += (1 * earnupgrade);
}
if (spooky.equals("prestige") || spooky.equals("Prestige"))
{
if (level >= 12)
{
level = 1;
money = 500;
prestige++;
}
else
{
System.out.println("You are not level 12. You cannot prestige.");
}
}
do
{
if (xp >= xpcap)
{
level++;
upgradepoint++;
xp = 0;
xpcap = xpcap * 2;
System.out.println("You are now level " + level + "!");
}
}
while (level < 12);
// UPGRADE SHOP
if (spooky.equals("upgrade") || spooky.equals("Upgrade"))
{
System.out.println("Type the name of what upgrade you would like. Use correct capititalization");
System.out.println("Selling Price : Double the selling price on all items. 3 upgrade points.");
System.out.println("Earn Double : Double the money you earn by typing earn. 1 upgrade point.");
upgradeterm = keyboard.nextLine();
if (upgradeterm.equals("Selling Price"))
{
if (upgradepoint >= 3)
{
upgradepoint -= 3;
doublesell = doublesell * 2;
}
else
{
System.out.println("You do not have enough upgrade points");
}
}
if (upgradeterm.equals("Earn Double"))
{
if (upgradepoint >= 1)
{
upgradepoint -= 1;
earnupgrade = earnupgrade * 2;
}
else
{
System.out.println("You do not have enough upgrade points");
}
}
}
// SHOP
if (spooky.equals("sell") || spooky.equals("Sell"))
{
System.out.println("What items would you like to sell: ");
sellterm = keyboard.nextLine();
if (sellterm.equals("common") || sellterm.equals("Common"))
{
money = money + ((3 * common) * doublesell);
System.out.println("+ $" + ((3 * common) * doublesell));
common = 0;
}
else if (sellterm.equals("uncommon") || sellterm.equals("Uncommon"))
{
money = money + ((7 * uncommon) * doublesell);
System.out.println("+ $" + ((7 * uncommon) * doublesell));
uncommon = 0;
}
else if (sellterm.equals("rare") || sellterm.equals("Rare"))
{
money = money + ((25 * rare) * doublesell);
System.out.println("+ $" + ((25 * rare) * doublesell));
rare = 0;
}
else if (sellterm.equals("legendary") || sellterm.equals("Legendary"))
{
money = money + ((100 * legendary) * doublesell);
System.out.println("+ $" + ((100 * legendary) * doublesell));
legendary = 0;
}
else if (sellterm.equals("exotic") || sellterm.equals("Exotic"))
{
money = money + ((500 * exotic) * doublesell);
System.out.println("+ $" + ((500 * exotic) * doublesell));
exotic = 0;
}
else if (sellterm.equals("relic") || sellterm.equals("Relic"))
{
money = money + ((5000 * relic) * doublesell);
System.out.println("+ $" + ((5000 * relic) * doublesell));
relic = 0;
}
else if (sellterm.equals("rune") || sellterm.equals("Rune"))
{
money = money + ((50000 * rune) * doublesell);
System.out.println("+ $" + ((50000 * rune) * doublesell));
rune = 0;
}
else if (sellterm.equals("ancient") || sellterm.equals("Ancient"))
{
money = money + ((100000 * ancient) * doublesell);
System.out.println("+ $" + ((100000 * ancient) * doublesell));
ancient = 0;
}
}
}
while (!spooky.equals("quit"));
}
}