⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 creatonsquest.java

📁 Creaton s Quest是一个有趣的Java角色扮演游戏!很有趣
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*By: Chad Marson
Date Started: May 15
Latest Revised: June 16, 2002
Purpose: A role playing game
*/
import java.io.*;

public class CreatonsQuest {//main class
	
	public static void main (String[] args) throws Exception{//main method		
		int x=0;//stores user choices
		int a=0;//stores user choice to exit game
		int z=0;//stores the monster user fights
		int tem_lvl=0;//stores user level when the begin the game
		double ran;//stores random number
		boolean error=true;//stores wether the user has choosen a valid option
		String enter="";//stores any value in the press enter to continue prompt
		String monster="";//stores monster name
		String name="";//stores users name
		String filehandle="";//stores user name
		String txt=".txt";//stores ".txt" and adds it to user name to access file
		String line="";//stores line from the story
		int points=20;//stores user skill points
		int str=0;//stores users strength
		int def=0;//stores users defence
		int mag=0;//stores users magic
		int lvl=0;//stores user level
		int exp=0;//stoes user exp
		int skill=0;//stores user skills
		while(a==0){//loop to continue game until exit option is selected
		x=0;
		while(error){//loop to ensure a valid option is choosen
			System.out.println("Welcome To Creaton's Quest");
			System.out.println("--------------------------");
			System.out.println("");
			System.out.println("1.) Create new Character");
			System.out.println("2.) Play existing Character");
			System.out.println("3.) Read the Tale");
			System.out.println("4.) Multiplayer Game");
			System.out.print("What do you wish to do? ");
			try{
			x=key.readInt(x);//stores users choice
		}
			catch(NumberFormatException e){//catches invalid option
				System.out.println("Please Choose an option from 1-4");
			}
			if((x==1)||(x==2)||(x==3)||(x==4)){
			error=false;
		}
	}
		if(x==4){
			multi.multi();
		}
		error=true;
		if (x==1){
			newchar();
		}
			
		error=true;
		if(x==2){
			while(error){//loop to ensure valid option is selected
				x=0;
				System.out.print("Please Select Which character you wish to Play: ");
				name=key.readString(name);
				name=name+txt;
				try{
					FileReader File1=new FileReader(name);
					BufferedReader reader=new BufferedReader(File1);
				}
				catch(IOException FileNotFoundException){
					System.out.println("Sorry Character does not exist. Please Select Another Character");
					x=1;
				}
				if(x==0){
				error=false;
				}
				FileReader File1=new FileReader(name);
				BufferedReader reader=new BufferedReader(File1);
				lvl=Integer.parseInt(reader.readLine());
				str=Integer.parseInt(reader.readLine());
				def=Integer.parseInt(reader.readLine());
				mag=Integer.parseInt(reader.readLine());
				exp=Integer.parseInt(reader.readLine());
				skill=Integer.parseInt(reader.readLine());
			}
		}
		if(x==3){
			FileReader file1=new FileReader("story.txt");
			BufferedReader reader5=new BufferedReader(file1);
			x=0;
			while(x<2){//loop to bring in and display story
				line=reader5.readLine();
				System.out.println(line);
				x++;
			}
			System.out.println("Press enter to continue the Tale");
			txt=key.readString(txt);
			x=0;
			while(reader5.ready()){//loop to bring in and display story
				line=reader5.readLine();
				System.out.println(line);
						
			}
		}
			while((!(a==1)&&(lvl>=1))){//loop to play the main game
				FileReader File1=new FileReader(name);
				BufferedReader reader=new BufferedReader(File1);
				lvl=Integer.parseInt(reader.readLine());
				str=Integer.parseInt(reader.readLine());
				def=Integer.parseInt(reader.readLine());
				mag=Integer.parseInt(reader.readLine());
				exp=Integer.parseInt(reader.readLine());
				skill=Integer.parseInt(reader.readLine());
				tem_lvl=lvl;
				lvl=experience.experience(exp,lvl);
				if(!(tem_lvl==lvl)){
					exp=0;
					def=def+50;
				}
				if(exp<0){
					exp=0;
				}
				if(mag<0){
					mag=0;
				}
				if(def<50){
					def=50;
				}
				if(str<0){
					str=0;
				}
				error=true;
				while(error){//loop to ensure user choices valid option
					x=0;
					System.out.println("");
					System.out.println("");
					System.out.println("1.) Training Grounds");
					System.out.println("2.) Snake Pit");
					System.out.println("3.) Goblin Grotto");
					System.out.println("4.) Dragon's Lair");
					System.out.println("5.) Creaton's Castle");
					System.out.println("6.) View Inventory");
					System.out.println("7.) View Abilities");
					System.out.println("8.) Save and Exit");
					System.out.println("9.) Allocate Points");
					System.out.println("Where do you wish to venture?");
					try{
						x=key.readInt(x);
					}
					catch(NumberFormatException e){
					}
					if((x<=9)&&(x>0)){
						error=false;
					}
				}
				error=true;
				if(x==1){
					while(error){
						System.out.println("");
						System.out.println("");
						System.out.println("Welcome to the Training Grounds");
						System.out.println("");
						System.out.println("1.) Butterfly");
						System.out.println("2.) Worm");
						System.out.println("3.) Hornet");
						System.out.println("4.) Scorpion");
						System.out.println("5.) Tyrant Tyranus");
						System.out.print("Choose which monster you wish to test your might against: ");
						try{
							z=key.readInt(z);
						}
						catch(NumberFormatException e){
						}
						if((z<=5)&&(z>0)){
							error=false;
						}
					}
					if(z==1){
						monster="butterfly";
					}
					if(z==2){
						monster="worm";
					}
					if(z==3){
						monster="hornet";
					}
					if(z==4){
						monster="scorpion";
					}
					if(z==5){
						monster="tyrant tyranus";
					}
					combat(skill,exp,lvl,str,def,mag,name,monster);
					z=0;	
				}
				error=true;
				if(x==2){
					while(error){
						System.out.println("");
						System.out.println("");
						System.out.println("Welcome to the Snake Pit");
						System.out.println("");
						System.out.println("1.) RattleSnake");
						System.out.println("2.) Salamander");
						System.out.println("3.) Chameleon");
						System.out.println("4.) asp");
						System.out.println("5.) King Slytheryn");
						System.out.print("Choose which monster you wish to test your might againist: ");
						try{
							z=key.readInt(z);
						}
						catch(NumberFormatException e){
						}
						if((z<=5)&&(z>0)){
							error=false;
						}
					}
					if(z==1){
						monster="rattlesnake";
					}
					if(z==2){
						monster="salamander";
					}
					if(z==3){
						monster="chameleon";
					}
					if(z==4){
						monster="asp";
					}
					if(z==5){
						monster="King Slytheryn";
					}
					combat(skill,exp,lvl,str,def,mag,name,monster);
					z=0;
				}
				
				error=true;
				if(x==3){
					while(error){
						System.out.println("");
						System.out.println("");
						System.out.println("Welcome to the Goblin Grotto");
						System.out.println("");
						System.out.println("1.) Green Goblin");
						System.out.println("2.) Hobgoblin");
						System.out.println("3.) Hemogoblin");
						System.out.println("4.) Elite goblin");
						System.out.println("5.) Hailton");
						System.out.print("Choose which monster you wish to test your might againist: ");
						try{
							z=key.readInt(z);
						}
						catch(NumberFormatException e){
						}
						if((z<=5)&&(z>0)){
							error=false;
						}
					}
					if(z==1){
						monster="green goblin";
					}
					if(z==2){
						monster="hobogoblin";
					}
					if(z==3){
						monster="hemogoblin";
					}
					if(z==4){
						monster="elite goblin";
					}
					if(z==5){
						monster="hailton";
					}
					combat(skill,exp,lvl,str,def,mag,name,monster);
					z=0;
				}
				error=true;
				if(x==4){
					while(error){
						System.out.println("");
						System.out.println("");
						System.out.println("Welcome to the Dragon Castle");
						System.out.println("");
						System.out.println("1.) Dragon Whelp");
						System.out.println("2.) Drake");
						System.out.println("3.) Red Dragon ");
						System.out.println("4.) Singe");
						System.out.println("5.) Hroth'Gar");
						System.out.print("Choose which monster you wish to test your might againist: ");
						try{
							z=key.readInt(z);
						}
						catch(NumberFormatException e){
						}
						if((z<=5)&&(z>0)){
							error=false;
						}
					}
					if(z==1){
						monster="dragon whelp";
					}
					if(z==2){
						monster="drake";
					}
					if(z==3){
						monster="red dragon";
					}
					if(z==4){
						monster="singe";
					}
					if(z==5){
						monster="hroth'gar";
					}
					combat(skill,exp,lvl,str,def,mag,name,monster);
					z=0;
				}
				error=true;
				if(x==5){
					while(error){
						System.out.println("");
						System.out.println("");
						System.out.println("Welcome to Creaton's Castle");
						System.out.println("");
						System.out.println("1.) Black Knight");
						System.out.println("2.) Stone Sentry");
						System.out.println("3.) Balrog");
						System.out.println("4.) Prince Damien Creaton");
						System.out.println("5.) Sir Lucifer Creaton");
						System.out.print("Choose which monster you wish to test your might againist: ");
						try{
							z=key.readInt(z);
						}
						catch(NumberFormatException e){
						}
						if((z<=5)&&(z>0)){
							error=false;
						}
					}
					if(z==1){
						monster="black knight";
					}
					if(z==2){
						monster="stone sentry";
					}
					if(z==3){
						monster="balrog";
					}
					if(z==4){
						monster="prince damien creaton";
					}
					if(z==5){
						monster="sir lucifer creaton";
					}
					combat(skill,exp,lvl,str,def,mag,name,monster);
					z=0;
				
			}
			if(x==6){
				inventory(lvl,str,def,mag,skill);
			}
			if(x==7){
				ability(lvl);
			}
			if(x==8){
				save(lvl,str,def,mag,exp,skill,name);
				a=1;
			}
			if(x==9){
				points(lvl,str,def,mag,exp,skill,name);
			}
		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -