/**
DUNGEON CRAWL PROJECT
Programmer: Dan ----
Date started: 9.24.2009
TO DO LIST -----------------------------------------
ADD WEAPONS TO SHOPS
ADD LEVEL BEFORE BUYING WEAPONS
ADD TO DAMAGE METER USING ZEROS AND OTHER MODIFIERS (WITH WEAPONS?)
FIX THE CODE FOR IF DIED TO CORRECT VARIABLES
ADD ROOMS
**/
import java.io.*;
import java.util.*;
import java.lang.*;
public class game extends Thread
{
private static String fightAgain; // variable for if you wanna fight again
private static String fightDec; // what they type.. ex y/n
private static String globalCom = " What would you like to do?\n\n<m>ove | <f>ight | <b>uy | <s>tats | <r>ules | <q>uit";
private static File f1 = new File("stats.txt"); //global stats file
private static Random generator = new Random();
private static String level;
private static String newexp;
/** Chance numbers of monster encounter **/
private static FileOutputStream out; // declare a file output object
private static PrintStream p; // declare a print stream object
private static String weapon[] ={"Dagger", "Sword", "Pitchfork", "Battleaxe", "Spear", "Scimitar", "Warhammer", "Orc Blade", "Greataxe", "Flail"};
private static int weaplvl[] = {1,5,12,26,38,50,64,77,86,94};
private static int weapcost[] = {10,110,460,700,1120,4500,7000, 12000, 20000,42000};
private static String monsters[] = {"Rat", "Goblin", "Skeleton", "Ogre", "Troll", "Orc", "Human", "Chuck Norris"};
private static int monlevelnum[] = {3,8,13,18,26,39,40,63};
private static String monlevel[] = {"3","8","13","18","26","39","40","63"};
private static int monhit[] = {3,5,8,14,17,21,29,40};
private static int mon_hp[] = {12,20,32,43,56,69,82,100};
private static String monexp;
private static String mondmg;
private static int randomNum;
private static Random rand = new Random();
public static String monexp(int w) {
int total_exp=(w)*3/2;
String monexp = Integer.toString(total_exp);
return monexp;
}
public static String mondmg(int d) {
game game = new game();
int monhitlvl = (d)*3 + 1;
String mondmg = Integer.toString(monhitlvl);
return mondmg;
}
public static String userdmg(int d) {
game game = new game();
String mylevel = game.lines(2,2);
int mynumlevel = Integer.parseInt(mylevel);
int total_damangeyou=d*6+mynumlevel;
String userdmg = Integer.toString(total_damangeyou);
return userdmg;
}
public static String gengold(int w) {
int total_gold_earn=(w)*5/2;
String goldEarn = Integer.toString(total_gold_earn);
return goldEarn;
}
public String lines(int start, int end)
{
String info = "";
BufferedReader in;
try
{
in = new BufferedReader (new FileReader("stats.txt"));
for (int i = 0; i < start; i++) { info = in.readLine(); }
for (int i = start; i < end + 1; i++)
{
info = in.readLine();
}
in.close();
}
catch (IOException ioe)
{
System.out.println("An unexpected error occured." + ioe.getMessage());
}//end catch errors
return info;
}
public static void youLose()
{
System.out.println("\t __ __ _ _ _ _ ");
System.out.println("\t \\ \\ / / | (_) | | |");
System.out.println("\t \\ \\_/ /___ _ _ __| |_ ___ __| | |");
System.out.println("\t \\ // _ \\| | | | / _` | |/ _ \\/ _` | |");
System.out.println("\t | || (_) | |_| | | (_| | | __/ (_| |_|");
System.out.println("\t |_| \\___/ \\__,_| \\__,_|_|\\___|\\__,_(_)");
System.out.println("\n\n... You wake back up... and ready for fighting...");
if (f1.exists() == true) {
xp();
}
}
public static void rules()
{
System.out.println(" +---------------------------------------------------------------------+");
System.out.println(" | Rules of the Game |");
System.out.println(" +---------------------------------------------------------------------+");
System.out.println(" In Mystik, it's all about choosing when to fight and answer riddles...,");
System.out.println(" You will go through a series of 10 rooms. Each room has one boss and ");
System.out.println(" one riddle you must solve. Before you reach the riddle, you must defeat");
System.out.println(" the boss. But before you reach the boss, you'll have to go to through ");
System.out.println(" several random encounters. They can be a random battle with monsters,");
System.out.println(" a deadly trap, or maybe even some free loot! As you progress each room");
System.out.println(" you will find that there are more types of monsters you can kill");
System.out.println(" \n The more EXP you earn, the stronger you get and the easier it will be");
System.out.println(" for you to kill monsters and bosses. Along the road of your epic journey");
System.out.println(" you will find it valueable to buy items to aid in your combat. Good luck.");
System.out.println(" ----------------------------------------------------------------------- ");
}
public static void printIntro () // INTRO METHOD ******************************************************
{
game game = new game();
if (f1.exists() == true ) {
String goldEarn = game.lines(1,1);
String mylevel = game.lines(2,2);
int myintlevel = Integer.parseInt(mylevel);
String charexp = game.lines(3,3);
}
System.out.println("\t\t\t Welcome to...\n");
System.out.println("\t\t ___ ___ _ _ _ ");
System.out.println("\t\t | \\/ | | | (_) | ");
System.out.println("\t\t | . . |_ _ ___| |_ _| | __");
System.out.println("\t\t | |\\/| | | | / __| __| | |/ /");
System.out.println("\t\t | | | | |_| \\__ \\ |_| | < ");
System.out.println("\t\t \\_| |_/\\__, |___/\\__|_|_|\\_\\");
System.out.println("\t\t __/ | ");
System.out.println("\t\t |___/ ");
// try
// {
if (f1.exists() == true)
{
xp();
//sleep(500);
System.out.println("\n\t\tName: " + game.lines(0,0));
System.out.println("\t\tLevel: "+ game.lines(2,2));
System.out.println("\t\tEXP: " + game.lines(3,3));
System.out.println("\t\tHealth: " + game.lines(5,5)+"/" + game.lines(6,6));
System.out.println("\t\tRoom " + game.lines(4,4));
System.out.println("\n");
}
// }
//catch (InterruptedException e) { }
}
public static void main(String args[]) throws InterruptedException // MAIN METHOD *******************************************************
{
printIntro();
doMain();
}//end main method
public static void pressEnter() throws InterruptedException
{
System.out.println("Press ENTER to continue...");
try {
System.in.read();
while (System.in.available() > 0)
System.in.read(); //flush the buffer
battle();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void doMain() throws InterruptedException{ // DO MAIN ********************************************************************
game game = new game();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
InputStreamReader istream = new InputStreamReader(System.in) ;
BufferedReader bufRead = new BufferedReader(istream);
try
{
if (f1.exists() == false)
{
System.out.println("\n\nWhat is your name?");
String name = bufRead.readLine();
//print the data entered by the user
System.out.println("\nWelcome to Mystik, " + name +"...\n\nYou feel light headed as you wake up from a room with no doors. You feel cold and sleepy yet you manage to stumble onto your feet.");
Thread.sleep(500);
System.out.println("\nYou then go through the trapdoor and discover a long and trecherous road...\n\n");
out = new FileOutputStream("stats.txt");
p = new PrintStream( out );
p.println(name);
p.println("100"); // gold
p.println("1"); // level
p.println("0"); // exp
p.println("1"); // room
p.println("100"); // current hp
p.println("100"); // max hp
p.close();
}
System.out.println(globalCom);
String choice = bufRead.readLine();
if (choice.equalsIgnoreCase("f"))
{
battle();
}else if (choice.equalsIgnoreCase("s")) {
System.out.println("\n----------------------------------------");
System.out.println("|\tCharacter name: " + game.lines(0,0)+"\t |");
System.out.println("|\tGold: " + game.lines(1,1)+" \t |");
System.out.println("|\tHP: " + game.lines(5,5)+"/" + game.lines(6,6)+"\t\t |");
System.out.println("|\tCurrent Level: "+game.lines(2,2)+" \t |");
System.out.println("|\tEXP: " + game.lines(3,3)+" \t |");
System.out.println("|\tCurrent Room " + game.lines(4,4)+" \t |");
System.out.println("----------------------------------------\n\n");
System.out.println(globalCom);
String statin = bufRead.readLine();
if (statin.equalsIgnoreCase("b") == true)
{
buyItems();
}else if (statin.equalsIgnoreCase("f") == true)
{
battle();
}else if (statin.equalsIgnoreCase("r") == true)
{
rules();
}
}else if (choice.equalsIgnoreCase("b") == true )
{
buyItems();
}else if (choice.equalsIgnoreCase("r") == true )
{
rules();
}else {
quit();
}
//buy stuff
//end stuff
} //end try
catch (IOException ioe)
{
System.out.println("An unexpected error occured.");
}//end catch errors
}
public static void quit() throws InterruptedException {
InputStreamReader istream = new InputStreamReader(System.in) ;
BufferedReader bufRead = new BufferedReader(istream);
System.out.println("Do you really want to quit? Type Y to quit...");
try {
String ansquit = bufRead.readLine();
if (ansquit.equalsIgnoreCase("Y") == true)
{
System.out.println("\nSee ya next time!\n");
}
}
catch (IOException ioe) {
System.out.println("An unexpected error occured.");
}//end catch errors
}
public static void buyItems() throws InterruptedException { // BUY METHOD *******************************************************
game gold = new game();
FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object
String uname = gold.lines(0,0);
String get_gold = gold.lines(1,1);
String lvl = gold.lines(2,2);
String exp = gold.lines(3,3);
String room = gold.lines(4,4);
String currenthp = gold.lines(5,5);
String maxhp = gold.lines(6,6);
int newgold = Integer.parseInt(get_gold);
int getHp = Integer.parseInt(currenthp);
int newf;
InputStreamReader istream = new InputStreamReader(System.in) ;
BufferedReader bufRead = new BufferedReader(istream);
System.out.println("What would you like to buy? (Type <q>uit to go back) \n1. <i>ron sword \n2. <h>eal potion \n");
try {
String buy = bufRead.readLine();
if (buy.equalsIgnoreCase("q") == true) {
System.out.println("\nYou walk out of the store empty handed...\n");
doMain();
}else if (buy.equalsIgnoreCase("i") == true)
{
out = new FileOutputStream("stats.txt");
if (newgold >= 1) {
System.out.println("You bought an iron sword!");
p = new PrintStream( out );
newf = newgold-100;
p.println(uname);
p.println(newf);
p.println(lvl);
p.println(exp);
p.println(room);
p.println(currenthp);
p.println(maxhp);
p.close();
doMain();
}else{
p = new PrintStream( out );
newf = newgold;
p.println(uname);
p.println(newf);
p.println(lvl);
p.println(exp);
p.println(room);
p.println(currenthp);
p.println(maxhp);
p.close();
System.out.println("\nInsufficent funds!\n");
doMain();
}
}
else if (buy.equalsIgnoreCase("h") == true)
{
out = new FileOutputStream("stats.txt");
int cost = 110;
newf = newgold-cost;
if (newf >= 1) {
int hpheal = 20;
int healed_hp = hpheal+getHp;
System.out.println("\nAfter buying the heal potion, you drink it.\nYou were healed for "+hpheal+" HP.");
p = new PrintStream( out );
p.println("Dan");
p.close();
doMain();
}else{
p = new PrintStream( out );
p.println(uname);
p.println(newgold);
p.println(lvl);
p.println(exp);
p.println(room);
p.println(currenthp);
p.println(maxhp);
p.close();
System.out.println("\nInsufficent funds!\n");
}
doMain();
}
else if (buy.equalsIgnoreCase("schtuff") == true)
{
System.out.println("You bought schtuff... You just wasted money becauase you didn't get in back in return!");
doMain();
}else{
System.out.println("You didn't type anything or typed in them item wrong. Therefor you haven't bought anything.");
doMain();
}
}catch (IOException ioe)
{
System.out.println("An unexpected error occured.");
}//end catch errors
}
public static void battleDone() throws InterruptedException{ // BATTLE DONE METHOD *************************************************************
InputStreamReader istream = new InputStreamReader(System.in) ;
BufferedReader bufRead = new BufferedReader(istream);
System.out.println("\n\nBattle has finished.\n\nFight again?\n<Y/N>");
try {
fightAgain = bufRead.readLine();
}
catch (IOException ioe)
{
System.out.println("An unexpected error occured.");
}//end catch errors
if (fightAgain.equalsIgnoreCase("Y"))
{
battle();
}else if (!fightAgain.equalsIgnoreCase("Y"))
{
doMain();
}//end if typed FIGHT
}
public static String get (String[] array) {
int rnd = generator.nextInt(array.length);
return array[rnd];
}
private static Random rd = null;
public static int[] random(int[] src)
{
if(src == null){
return null;
}
rd = new Random();
int[] tmp = new int[src.length];
int num = src.length;
int index;
for(int i = 0;i < src.length;i++)
{
index = Math.abs(rd.nextInt()) % num;
tmp[i] = src[index];
src[index] = src[num - 1];
num--;
}
return tmp;
}
public static void battle() throws InterruptedException // BATTLE METHOD ***********************************************************
{
Random diceRoller = new Random();
Random monsterRoller = new Random();
Random getMonster = new Random();
Random getExp = new Random();
Random runAway = new Random();
int total_rounds = 0;
int running = runAway.nextInt(30);
game gold = new game();
InputStreamReader istream = new InputStreamReader(System.in) ;
BufferedReader bufRead = new BufferedReader(istream);
FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object
String uname = gold.lines(0,0);
String get_gold = gold.lines(1,1);
int intGold = Integer.parseInt(gold.lines(1,1));
String lvl = gold.lines(2,2);
String getexp = gold.lines(3,3);
int exp = Integer.parseInt(gold.lines(3,3));
int lvlnum = Integer.parseInt(gold.lines(2,2));
String room = gold.lines(4,4);
String currenthp = gold.lines(5,5);
int numberhp = Integer.parseInt(currenthp);
String maxhp = gold.lines(6,6);
int getMaxHp = Integer.parseInt(gold.lines(6,6));
int my_hp = numberhp;
int typeMonster = getMonster.nextInt(10);
int monlvl = rand.nextInt(10);
int cmonster = rand.nextInt((9+1)+ monlvl);
String ret = get(monsters);
String glvl = get(monlevel);
game game = new game();
String goldEarn = game.lines(1,1);
String mylevel = game.lines(2,2);
int myintlevel = Integer.parseInt(mylevel);
String charexp = game.lines(3,3);
Random rand = new Random();
if (myintlevel < 10) {
randomNum = rand.nextInt(1);
}else if (myintlevel <15) {
randomNum = rand.nextInt(3);
}else if (myintlevel <20) {
randomNum = rand.nextInt(5);
}else if (myintlevel <25) {
randomNum = rand.nextInt(7);
}
String monsterName = monsters[randomNum];
int monsterLevel = monlevelnum[randomNum];
int monsterHit = monhit[randomNum];
int mon_level = monsterLevel;
int monster_hp = mon_hp[randomNum];
int mydamage = myintlevel;
String monster = monsterName;
int runRisk;
try {
System.out.println("You encountered a Level "+mon_level+" "+monsterName+"!\nWhat do you want to do?\n\n1. <F>ight\n2. <R>un Away");
fightDec = bufRead.readLine();
}
catch (IOException ioe)
{
System.out.println("An unexpected error occured.");
}//end catch errors
if (fightDec.equalsIgnoreCase("r"))
{
//if (runRisk > running) {
System.out.println("\nYou ran away!");
doMain();
//}else{
// fightDec.equalsIgnoreCase("fight");
//}
}else{
if (fightDec.equalsIgnoreCase("f"))
{
// MONSTER INFO ********************************************************************************************************
while (monster_hp > 0 || my_hp > 0)
{ // while either monster or user's hp is 1 or higher... do this
String getuserhit = userdmg(mydamage);
int my_hit = rand.nextInt(Integer.parseInt(getuserhit));
String getmonhit = mondmg(monsterHit);
int monster_hit = rand.nextInt(Integer.parseInt(getmonhit));
int mon_hp = monster_hp - my_hit;
int new_hp = my_hp - monster_hit;
if (mon_hp <= 0)
{ // if monster's hp is below zero.. set to zero
mon_hp = 0;
}
if (new_hp <= 0)
{ // if user's hp is below zero.. set to zero
new_hp = 0;
}
//display monster messages
if (mon_hp > 0)
{
System.out.println(monster+" hit for " + monster_hit + "\nYOUR Old HP: " + my_hp + "\nYOUR New HP: " + new_hp + "\n\n----\n");
}
//end monster messages
if (new_hp > 0)
{
System.out.println("YOU hit for " + my_hit + "\n"+monster+"'s Old HP: " + monster_hp + "\n"+monster+"'s New HP: " + mon_hp + "\n\n----\n");
}
if (mon_hp <= 0)
{
int getHp = Integer.parseInt(currenthp);
int finalHp = new_hp;
;
int newgoldearned = Integer.parseInt(gengold(monsterLevel));
int monsterexpearn = Integer.parseInt(monexp(monsterLevel));
String killMsg = "\nYou gained "+monexp(monsterLevel)+" EXP.\n";
String coinMsg = "You earned "+gengold(monsterLevel)+" gold.\n";
int finalEXP = exp+monsterexpearn;
int finalGold = intGold+newgoldearned;
xp();
try {
System.out.println(killMsg);
System.out.println(coinMsg);
out = new FileOutputStream("stats.txt");
p = new PrintStream( out );
p.println(uname);
p.println(finalGold);
p.println(level);
p.println(finalEXP);
p.println(room);
p.println(finalHp);
p.println(maxhp);
p.close();
}catch (IOException ioe)
{
System.out.println("An unexpected error occured.");
}//end catch errors
System.out.println("Your Final HP " + new_hp + ". You killed the monster! It took " + total_rounds + " times for you to kill it.");
}
int healedHp = getMaxHp;
int coinLose;
int expLose;
String lostExpMsg;
String lostCoinMsg;
int lostEXP;
int lostGold;
int ifLostExp;
if (typeMonster > 5) {
coinLose = 9;
expLose = 16;
lostExpMsg = "\nYou lost "+expLose+" EXP.\n";
lostCoinMsg = "You lost "+coinLose+" gold.\n";
lostEXP = exp-expLose;
lostGold = intGold-coinLose;
}else{
coinLose = 14;
expLose = 20;
lostExpMsg = "\nYou lost "+expLose+" EXP.\n";
lostCoinMsg = "You lost "+coinLose+" gold.\n";
lostEXP = exp-expLose;
ifLostExp = lostEXP;
if (ifLostExp < 0) {
lostEXP = 0;
}else{
lostEXP = exp-expLose;
}
lostGold = intGold-coinLose;
}
if (new_hp <= 0)
{
System.out.println(monster+"'s Final HP " + mon_hp + ". You died! It took " + total_rounds + " times to defeat you.");
youLose();
System.out.println("\n"+lostExpMsg+"\n"+lostCoinMsg);
try {
out = new FileOutputStream("stats.txt");
p = new PrintStream( out );
p.println(uname);
p.println(lostGold);
p.println(level);
p.println(lostEXP);
p.println(room);
p.println(healedHp);
p.println(healedHp);
p.close();
}catch (IOException ioe)
{
System.out.println("An unexpected error occured.");
}//end catch errors
System.out.println("\nYou lay on the ground for a minute, weak and dazed. You accept defeat while the "+monster+" loots your gold. An hour passes by and you have regained full health.\n");
doMain();
}
if (mon_hp <= 0)
{
battleDone();
break;
}
monster_hp = mon_hp;
my_hp = new_hp;
total_rounds++; // add new round to total rounds
} //end while
} // end not running away
}
}//end battle method
public static void xp() {
game exp = new game();
int myExp = Integer.parseInt(exp.lines(3,3));
int myLvl = Integer.parseInt(exp.lines(2,2));
if (myExp > 0 && myExp < 14 && myLvl < 2) {
level = "1";
} else if (myExp > 14 && myExp < 31 && myLvl < 3) {
level = "2";
} else if (myExp > 31 && myExp < 49 && myLvl < 4) {
level = "3";
} else if (myExp > 49 && myExp < 70 && myLvl < 5) {
level = "4";
} else if (myExp > 70 && myExp < 93 && myLvl < 6) {
level = "5";
} else if (myExp > 93 && myExp < 118 && myLvl < 7) {
level = "6";
} else if (myExp > 118 && myExp < 146 && myLvl < 8) {
level = "7";
} else if (myExp > 146 && myExp < 178 && myLvl < 9) {
level = "8";
} else if (myExp > 178 && myExp < 212 && myLvl < 10) {
level = "9";
} else if (myExp > 212 && myExp < 250 && myLvl < 11) {
level = "10";
} else if (myExp > 250 && myExp < 292 && myLvl < 12) {
level = "11";
} else if (myExp > 292 && myExp < 338 && myLvl < 13) {
level = "12";
} else if (myExp > 338 && myExp < 390 && myLvl < 14) {
level = "13";
} else if (myExp > 390 && myExp < 446 && myLvl < 15) {
level = "14";
} else if (myExp > 446 && myExp < 508 && myLvl < 16) {
level = "15";
} else if (myExp > 508 && myExp < 577 && myLvl < 17) {
level = "16";
} else if (myExp > 577 && myExp < 652 && myLvl < 18) {
level = "17";
} else if (myExp > 652 && myExp < 736 && myLvl < 19) {
level = "18";
} else if (myExp > 736 && myExp < 827 && myLvl < 20) {
level = "19";
} else if (myExp > 827 && myExp < 928 && myLvl < 21) {
level = "20";
} else if (myExp > 928 && myExp < 1039 && myLvl < 22) {
level = "21";
} else if (myExp > 1039 && myExp < 1162 && myLvl < 23) {
level = "22";
} else if (myExp > 1162 && myExp < 1297 && myLvl < 24) {
level = "23";
} else if (myExp > 1297 && myExp < 1445 && myLvl < 25) {
level = "24";
} else if (myExp > 1445 && myExp < 1609 && myLvl < 26) {
level = "25";
} else if (myExp > 1609 && myExp < 1789 && myLvl < 27) {
level = "26";
} else if (myExp > 1789 && myExp < 1988 && myLvl < 28) {
level = "27";
} else if (myExp > 1988 && myExp < 2207 && myLvl < 29) {
level = "28";
} else if (myExp > 2207 && myExp < 2448 && myLvl < 30) {
level = "29";
} else if (myExp > 2448 && myExp < 2714 && myLvl < 31) {
level = "30";
} else if (myExp > 2714 && myExp < 3007 && myLvl < 32) {
level = "31";
} else if (myExp > 3007 && myExp < 3330 && myLvl < 33) {
level = "32";
} else if (myExp > 3330 && myExp < 3686 && myLvl < 34) {
level = "33";
} else if (myExp > 3686 && myExp < 4078 && myLvl < 35) {
level = "34";
} else if (myExp > 4078 && myExp < 4511 && myLvl < 36) {
level = "35";
} else if (myExp > 4511 && myExp < 4988 && myLvl < 37) {
level = "36";
} else if (myExp > 4988 && myExp < 5514 && myLvl < 38) {
level = "37";
} else if (myExp > 5514 && myExp < 6094 && myLvl < 39) {
level = "38";
} else if (myExp > 6094 && myExp < 6734 && myLvl < 40) {
level = "39";
} else if (myExp > 6734 && myExp < 7439 && myLvl < 41) {
level = "40";
} else if (myExp > 7439 && myExp < 8218 && myLvl < 42) {
level = "41";
} else if (myExp > 8218 && myExp < 9076 && myLvl < 43) {
level = "42";
} else if (myExp > 9076 && myExp < 10023 && myLvl < 44) {
level = "43";
} else if (myExp > 10023 && myExp < 11068 && myLvl < 45) {
level = "44";
} else if (myExp > 11068 && myExp < 12220 && myLvl < 46) {
level = "45";
} else if (myExp > 12220 && myExp < 13492 && myLvl < 47) {
level = "46";
} else if (myExp > 13492 && myExp < 14895 && myLvl < 48) {
level = "47";
} else if (myExp > 14895 && myExp < 16443 && myLvl < 49) {
level = "48";
} else if (myExp > 16443 && myExp < 18151 && myLvl < 50) {
level = "49";
} else if (myExp > 18151 && myExp < 20036 && myLvl < 51) {
level = "50";
} else if (myExp > 20036 && myExp < 22116 && myLvl < 52) {
level = "51";
} else if (myExp > 22116 && myExp < 24411 && myLvl < 53) {
level = "52";
} else if (myExp > 24411 && myExp < 26945 && myLvl < 54) {
level = "53";
} else if (myExp > 26945 && myExp < 29741 && myLvl < 55) {
level = "54";
} else if (myExp > 29741 && myExp < 32826 && myLvl < 56) {
level = "55";
} else if (myExp > 32826 && myExp < 36232 && myLvl < 57) {
level = "56";
} else if (myExp > 36232 && myExp < 39992 && myLvl < 58) {
level = "57";
} else if (myExp > 39992 && myExp < 44141 && myLvl < 59) {
level = "58";
} else if (myExp > 44141 && myExp < 48721 && myLvl < 60) {
level = "59";
} else if (myExp > 48721 && myExp < 53776 && myLvl < 61) {
level = "60";
} else if (myExp > 53776 && myExp < 59356 && myLvl < 62) {
level = "61";
} else if (myExp > 59356 && myExp < 65516 && myLvl < 63) {
level = "62";
} else if (myExp > 65516 && myExp < 72316 && myLvl < 64) {
level = "63";
} else if (myExp > 72316 && myExp < 79822 && myLvl < 65) {
level = "64";
} else if (myExp > 79822 && myExp < 88108 && myLvl < 66) {
level = "65";
} else if (myExp > 88108 && myExp < 97255 && myLvl < 67) {
level = "66";
} else if (myExp > 97255 && myExp < 107352 && myLvl < 68) {
level = "67";
} else if (myExp > 107352 && myExp < 118500 && myLvl < 69) {
level = "68";
} else if (myExp > 118500 && myExp < 130806 && myLvl < 70) {
level = "69";
} else if (myExp > 130806 && myExp < 144391 && myLvl < 71) {
level = "70";
} else if (myExp > 144391 && myExp < 159389 && myLvl < 72) {
level = "71";
} else if (myExp > 159389 && myExp < 175947 && myLvl < 73) {
level = "72";
} else if (myExp > 175947 && myExp < 194226 && myLvl < 74) {
level = "73";
} else if (myExp > 194226 && myExp < 214406 && myLvl < 75) {
level = "74";
} else if (myExp > 214406 && myExp < 236685 && myLvl < 76) {
level = "75";
} else if (myExp > 236685 && myExp < 261282 && myLvl < 77) {
level = "76";
} else if (myExp > 261282 && myExp < 288437 && myLvl < 78) {
level = "77";
} else if (myExp > 288437 && myExp < 318417 && myLvl < 79) {
level = "78";
} else if (myExp > 318417 && myExp < 351516 && myLvl < 80) {
level = "79";
} else if (myExp > 351516 && myExp < 388058 && myLvl < 81) {
level = "80";
} else if (myExp > 388058 && myExp < 428402 && myLvl < 82) {
level = "81";
} else if (myExp > 428402 && myExp < 472944 && myLvl < 83) {
level = "82";
} else if (myExp > 472944 && myExp < 522120 && myLvl < 84) {
level = "83";
} else if (myExp > 522120 && myExp < 576413 && myLvl < 85) {
level = "84";
} else if (myExp > 576413 && myExp < 636355 && myLvl < 86) {
level = "85";
} else if (myExp > 636355 && myExp < 702535 && myLvl < 87) {
level = "86";
} else if (myExp > 702535 && myExp < 775601 && myLvl < 88) {
level = "87";
} else if (myExp > 775601 && myExp < 856271 && myLvl < 89) {
level = "88";
} else if (myExp > 856271 && myExp < 945335 && myLvl < 90) {
level = "89";
} else if (myExp > 945335 && myExp < 1043668 && myLvl < 91) {
level = "90";
} else if (myExp > 1043668 && myExp < 1152235 && myLvl < 92) {
level = "91";
} else if (myExp > 1152235 && myExp < 1272100 && myLvl < 93) {
level = "92";
} else if (myExp > 1272100 && myExp < 1404440 && myLvl < 94) {
level = "93";
} else if (myExp > 1404440 && myExp < 1550553 && myLvl < 95) {
level = "94";
} else if (myExp > 1550553 && myExp < 1711872 && myLvl < 96) {
level = "95";
} else if (myExp > 1711872 && myExp < 1889981 && myLvl < 97) {
level = "96";
} else if (myExp > 1889981 && myExp < 2086627 && myLvl < 98) {
level = "97";
} else if (myExp > 2086627 && myExp < 2303739 && myLvl < 99) {
level = "98";
} else if (myExp > 2303739 && myExp < 2543449 && myLvl < 100) {
level = "99";
}else{
level = "1";
}
String uname = exp.lines(0,0);
String get_gold = exp.lines(1,1);
int intGold = Integer.parseInt(exp.lines(1,1));
String lvl = exp.lines(2,2);
String getexp = exp.lines(3,3);
int numbexp = Integer.parseInt(exp.lines(3,3));
String room = exp.lines(4,4);
String currenthp = exp.lines(5,5);
int numberhp = Integer.parseInt(currenthp);
String maxhp = exp.lines(6,6);
int getMaxHp = Integer.parseInt(exp.lines(6,6));
try {
out = new FileOutputStream("stats.txt");
p = new PrintStream( out );
p.println(uname);
p.println(get_gold); // gold
p.println(level); // level
if (myExp < 0) {
p.println(0);
}else{
p.println(getexp);
}
p.println(room); // room
p.println(currenthp); // current hp
p.println(maxhp); // max hp
p.close();
}catch (IOException ioe)
{
System.out.println("An unexpected error occured.");
}//end catch errors
}
} //end class header