Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Tony Guillory
- import java.io.*;
- import java.util.*;
- class Game1TG
- {
- public static void main(String args[])throws IOException
- {
- String playerName = "", monsterName = "", npcName = "";
- String className = "", raceName = "", itemName = "";
- int playerLVL = 1, playerEXP = 0, playerClass = 0, playerRace = 0, playerHP = 50, playerDEF = 10;
- int playerSTR = 10, playerDEX = 10, playerCON = 10, playerINT = 10;
- int modSTR = 0, modDEX = 0, modCON = 0, modINT = 0;
- int monsterHP = 0, monsterEXP = 0, monsterDEF = 0, monsterATK = 1;
- int monster, chance = 0, choice;
- int potion = 1, hipotion = 1, numberPotion = 1, numberHiPotion = 1;
- Random roll = new Random();
- Scanner input = new Scanner(System.in);
- System.out.println("What is your character's name?"); // Input Name
- playerName = input.next();
- System.out.println("\nChoose your race: \n"); // Choose your race
- {
- int invalidRace = 1;
- while(invalidRace == 1)
- {
- System.out.println("1 Human \n2 Elf\n3 Dwarf");
- playerRace = input.nextInt();
- switch(playerRace)
- {
- case 1:
- {
- raceName = "Human";
- playerCON = playerCON + 2;
- playerDEF = playerDEF + 5;
- invalidRace = invalidRace -1;
- System.out.println();
- System.out.println("You have chosen Human as your race");
- System.out.println();
- }
- break;
- case 2:
- {
- raceName = "Elf";
- playerDEX = playerDEX + 2;
- modDEX = modDEX + 1;
- playerINT = playerINT + 2;
- modINT = modINT + 1;
- playerSTR = playerSTR - 2;
- modSTR = modSTR -1;
- invalidRace = invalidRace - 1;
- System.out.println();
- System.out.println("You have chosen Elf as your race");
- System.out.println();
- }
- break;
- case 3:
- {
- raceName = "Dwarf";
- playerSTR = playerSTR + 2;
- modSTR = modSTR + 2;
- playerDEX = playerDEX - 2;
- modDEX = modDEX - 1;
- invalidRace = invalidRace -1;
- System.out.println();
- System.out.println("You have chosen Dwarf as your race");
- System.out.println();
- }
- break;
- default:
- {
- System.out.println();
- System.out.println("That is an invalid selection");
- System.out.println();
- break;
- }
- }
- }
- }
- System.out.println("\nChoose your class: \n"); // Choose your class
- {
- int invalidClass = 1;
- while(invalidClass == 1)
- {
- System.out.println("1 Fighter \n2 Mage \n3 Archer");
- playerClass = input.nextInt();
- switch(playerClass)
- {
- case 1:
- {
- className = "Fighter";
- playerClass = 1;
- playerSTR = playerSTR + 8;
- modSTR = modSTR + 4;
- playerDEX = playerDEX - 2;
- modDEX = modDEX - 1;
- playerCON = playerCON + 2;
- modCON = modCON + 1;
- playerINT = playerINT - 4;
- modINT = modINT - 2;
- playerHP = playerCON * 6;
- playerDEF = playerDEF + 7;
- invalidClass = invalidClass - 1;
- System.out.println();
- System.out.println("You have chosen Fighter as your class");
- System.out.println();
- }
- break;
- case 2:
- {
- className = "Mage";
- playerClass = 2;
- playerSTR = playerSTR - 4;
- modSTR = modSTR - 2;
- playerDEX = playerDEX + 2;
- modDEX = modDEX + 1;
- playerCON = playerCON - 2;
- modCON = modCON -1;
- playerINT = playerINT + 12;
- modINT = modINT + 6;
- playerHP = playerCON * 4;
- playerDEF = playerDEF + 2;
- invalidClass = invalidClass - 1;
- System.out.println();
- System.out.println("You have chosen Mage as your class");
- System.out.println();
- }
- break;
- case 3:
- {
- className = "Archer";
- playerClass = 3;
- playerSTR = playerSTR + 2;
- modSTR = modSTR + 1;
- playerDEX = playerDEX + 8;
- modDEX = modDEX + 4;
- playerCON = playerCON - 2;
- modCON = modCON - 1;
- playerINT = playerINT - 4;
- modINT = modINT - 2;
- playerHP = playerCON * 5;
- playerDEF = playerDEF + 5;
- invalidClass = invalidClass - 1;
- System.out.println();
- System.out.println("You have chosen Archer as your class");
- System.out.println();
- }
- break;
- default:
- {
- System.out.println();
- System.out.println("That is an invalid selection");
- System.out.println();
- }
- break;
- }
- }
- }
- int randomEnc = 0;
- while(randomEnc == 1)
- {
- {
- monster = roll.nextInt(1000)+1; // setup phase
- if (monster <= 25)
- {
- monsterHP = 25;
- monsterName = "Rat";
- monsterATK = 3;
- monsterDEF = 5;
- monsterEXP = 50;
- }
- else if (monster > 25 && monster <= 50)
- {
- monsterHP = 35;
- monsterName = "Goblin";
- monsterATK = 4;
- monsterDEF = 7;
- monsterEXP = 100;
- }
- else if (monster > 50 && monster <= 75)
- {
- monsterHP = 45;
- monsterName = "Troll";
- monsterATK = 6;
- monsterDEF = 9;
- monsterEXP = 150;
- }
- else if (monster > 75 && monster <= 100)
- {
- monsterHP = 55;
- monsterName = "Ogre";
- monsterATK = 7;
- monsterDEF = 11;
- monsterEXP = 200;
- }
- else if (monster > 100)
- {
- // no battle
- randomEnc = randomEnc - 1;
- break;
- }
- if (randomEnc == 1)
- {
- System.out.println(playerName + " is attacked by a " + monsterName);
- }
- System.out.println("\nMake your move: \n");
- while(monsterHP > 0 && playerHP > 0 ) //Battle phase
- {
- if(playerClass == 1)
- {
- System.out.println("1 Slash \n2 Thrust \n3 Bash");
- }
- else if(playerClass == 2)
- {
- System.out.println("1 Fire \n2 Ice \n3 Lightning");
- }
- else if(playerClass == 3)
- {
- System.out.println("1 Long Shot \n2 Dagger \n3 Pot Shot");
- }
- choice = input.nextInt();
- switch(choice)
- {
- case 1:
- if(playerClass == 1)
- {
- chance = roll.nextInt(100)+modSTR;
- }
- else if(playerClass == 2)
- {
- chance = roll.nextInt(100)+modINT;
- }
- else if(playerClass == 3)
- {
- chance = roll.nextInt(100)+modDEX;
- }
- if(chance >= 30)
- {
- System.out.println(" \nYou hit the " + monsterName + " for 4hp");
- monsterHP = monsterHP - 4;
- }
- else if(chance < 30)
- {
- System.out.println(" \nYou miss the " + monsterName);
- }
- break;
- case 2:
- if(playerClass == 1)
- {
- chance = roll.nextInt(100)+modSTR;
- }
- else if(playerClass == 2)
- {
- chance = roll.nextInt(100)+modINT;
- }
- else if(playerClass == 3)
- {
- chance = roll.nextInt(100)+modDEX;
- }
- if(chance >= 45)
- {
- System.out.println(" \nYou hit the " + monsterName + " for 5hp");
- monsterHP = monsterHP - 5;
- }
- else if( chance < 45)
- {
- System.out.println(" \nYou miss the " + monsterName);
- }
- break;
- case 3:
- if(playerClass == 1)
- {
- chance = roll.nextInt(100)+modSTR;
- }
- else if(playerClass == 2)
- {
- chance = roll.nextInt(100)+modINT;
- }
- else if(playerClass == 3)
- {
- chance = roll.nextInt(100)+modDEX;
- }
- if(chance >= 75)
- {
- System.out.println(" \nYou hit the " + monsterName + " for 6hp");
- monsterHP = monsterHP - 10;
- }
- else if(chance < 75)
- {
- System.out.println(" \nYou miss the " + monsterName);
- }
- break;
- default:
- System.out.println(" \nWhile wondering why nothing happened the " + monsterName + " attacks you");
- playerHP = playerHP - 5;
- break;
- }
- if(playerHP > 0)
- {
- chance = roll.nextInt(100)+1;
- if(chance >= 45)
- {
- System.out.println("\n" + monsterName + " hits " + playerName + " for " + monsterATK + " hp");
- playerHP = playerHP - monsterATK;
- }
- else if(chance < 45)
- {
- System.out.println("\n" + monsterName + " misses " + playerName);
- }
- {
- System.out.println("\n" + playerName + " has " + playerHP + "hp left");
- System.out.println(" \n" + monsterName + " has " + monsterHP + "hp left");
- System.out.println();
- }
- if(playerHP <= 0 & monsterHP > 0)
- {
- System.out.println("\nThe " + monsterName + " has defeated " + playerName);
- randomEnc = randomEnc - 1;
- }
- else if(playerHP > 0 & monsterHP <= 0)
- {
- System.out.println("\nthe " + monsterName + " is defeated");
- playerEXP = playerEXP + monsterEXP;
- System.out.println( playerName + " gains " + monsterEXP + "Exp");
- randomEnc = randomEnc - 1;
- System.out.println();
- }
- else if(playerHP < 0 & monsterHP < 0)
- {
- System.out.println("\n" + playerName + " and the" + monsterName + " fall from mortal injuries");
- randomEnc = randomEnc - 1;
- }
- }
- }
- }
- if(playerEXP >= 500)
- {
- System.out.println(playerName + " has gained a level ");
- playerLVL = playerLVL + 1;
- playerEXP = playerEXP - playerEXP;
- playerSTR = playerSTR + 5;
- modSTR = modSTR + 1;
- playerDEX = playerDEX + 5;
- modDEX = modDEX + 1;
- playerCON = playerCON + 5;
- modCON = modCON +1;
- playerINT = playerINT + 5;
- modINT = modINT + 1;
- playerHP = playerHP + 50;
- playerDEF = playerDEF + 2;
- System.out.println(playerName +" is level " + playerLVL);
- System.out.println("Str = " + playerSTR + " DEX = " + playerDEX + " Con = " + playerCON + " Int = " + playerINT + " HP = " + playerHP + " Def = " + playerDEF);
- }
- if (playerHP <= 0)
- {
- System.out.println();
- System.out.println("Game Over");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement