Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class Main {
- static Scanner i = new Scanner(System.in);
- static Random r = new Random();
- static String name, option;
- static String items[] = {"[P]otion", "[D]agger", "[T]orch\t"};
- static String mons[] = {"\nA wolf attacks you!\n", "\nA bear attacks you!\n", "\nA spider attacks you!\n", "\nA snake attacks you!\n", "\nA troll attacks you!\n"};
- public static int hp, hpMax, lvl, exp, totalExp, nextLvl, gold, goldDrop, potionCount, q_bearClawCount, monsterDrop, str, dmg, m_dmg, m_hp;
- static int price[] = {25, 50, 100};
- static boolean area, quest, fight, potion, dagger, torch, daggerEquipped, torchEquipped, q_bearClaw, questComplete;
- public static void main(String[] args) throws InterruptedException {
- hp = 10;
- hpMax = 10;
- lvl = 1;
- exp = 0;
- totalExp = 0;
- nextLvl = 35;
- gold = 0;
- potionCount = 0;
- q_bearClawCount = 0;
- str = 5;
- area = true;
- fight = true;
- potion = false;
- dagger = false;
- torch = false;
- daggerEquipped = false;
- torchEquipped = false;
- quest = false;
- q_bearClaw = false;
- questComplete = false;
- System.out.println("DragonWorld\n");
- System.out.print("Name: ");
- name = i.nextLine();
- home();
- }
- public static void home() throws InterruptedException{
- System.out.println("\nYou are in your home.");
- System.out.println("Options: [E]xit, [R]est, [I]nventory, [S]tats");
- option = i.nextLine().toLowerCase();
- while(area == true){
- if(option.equals("e")){
- town();
- }else if(option.equals("r")){
- if(hp < 5){
- hp = hpMax;
- System.out.println("\nYou rested well!");
- option = i.nextLine().toLowerCase();
- }else{
- System.out.println("\nYou don't feel like resting.");
- option = i.nextLine().toLowerCase();
- }
- }else if(option.equals("i")){
- System.out.println("\nInventory:\n" + gold + " gold");
- if(potion == false && dagger == false && torch == false){
- option = i.nextLine().toLowerCase();
- }else{
- if(potion == true){
- System.out.println(items[0] + " x" + potionCount);
- }
- if(dagger == true){
- if(daggerEquipped == true){
- System.out.println(items[1] + " [Equipped]");
- }else{
- System.out.println(items[1]);
- }
- }
- if(torch == true){
- if(torchEquipped == true){
- System.out.println(items[2] + " [Equipped]");
- }else{
- System.out.println(items[2]);
- }
- }
- System.out.println("[E]xit");
- option = i.nextLine().toLowerCase();
- while(area == true){
- if(option.equals("p")){
- if(hp == hpMax){
- System.out.println("\nYou don't need to drink this right now.");
- }else{
- System.out.println("\nYou drink the potion... some HP was restored!");
- hp += 5;
- potionCount -= 1;
- if(hp > hpMax){
- hp = hpMax;
- }
- if(potionCount == 0){
- potion = false;
- }
- home();
- }
- option = i.nextLine().toLowerCase();
- }else if(option.equals("d")){
- if(daggerEquipped == false){
- System.out.println("\nYou equip the dagger.");
- torchEquipped = false;
- daggerEquipped = true;
- str += 3;
- home();
- }else if(daggerEquipped == true){
- System.out.println("\nYou unequip the dagger.");
- daggerEquipped = false;
- str -= 3;
- home();
- }
- }else if(option.equals("t")){
- if(torchEquipped == false && daggerEquipped == true){
- System.out.println("\nYou equip the torch.");
- str -= 3;
- daggerEquipped = false;
- torchEquipped = true;
- home();
- }else if(torchEquipped == true){
- System.out.println("\nYou unequip the torch.");
- torchEquipped = false;
- home();
- }else if(torchEquipped == false){
- System.out.println("\nYou equip the torch.");
- daggerEquipped = false;
- torchEquipped = true;
- home();
- }
- }else if(option.equals("e")){
- home();
- }else{
- option = i.nextLine().toLowerCase();
- }
- }
- }
- }else if(option.equals("s")){
- System.out.println("\nName: " + name + "\nHP: " + hp + "/" + hpMax + "\nStrength: " + str + "\nLvl: " + lvl + "\nNext lvl at: " + exp + "/" + nextLvl + "\nTotal exp: " + totalExp);
- option = i.nextLine().toLowerCase();
- }else{
- option = i.nextLine().toLowerCase();
- }
- }
- }
- public static void town() throws InterruptedException{
- System.out.println("\nYou are in the town.");
- System.out.println("Options: [H]ome, [S]hop, [F]orest");
- option = i.nextLine().toLowerCase();
- while(area == true){
- if(option.equals("h")){
- home();
- }else if(option.equals("s")){
- shop();
- }else if(option.equals("f")){
- forest();
- }else{
- option = i.nextLine().toLowerCase();
- }
- }
- }
- public static void shop() throws InterruptedException{
- System.out.println("\nYou are in the shop.");
- System.out.println("Options: [B]uy, [E]xit");
- option = i.nextLine().toLowerCase();
- while(area == true){
- if(option.equals("b")){
- System.out.println("\nShop keeper: Hello, how can I help you?\nYou have " + gold + " gold.");
- System.out.println("\nItems\t\tPrice");
- for(int x = 0; x < items.length && x < price.length; x++){
- System.out.println(items[x] + "\t" + price[x]);
- }
- System.out.println("[E]xit");
- option = i.nextLine().toLowerCase();
- while(area == true){
- if(option.equals("p")){
- if(gold >= 25){
- gold -= 25;
- System.out.println("\nYou buy a potion.");
- option = i.nextLine().toLowerCase();
- potionCount++;
- potion = true;
- }else{
- System.out.println("\nNot enough money!");
- option = i.nextLine().toLowerCase();
- }
- }else if(option.equals("d")){
- if(dagger == true){
- System.out.println("\nYou already have a dagger!");
- option = i.nextLine().toLowerCase();
- }else if(gold >= 50){
- gold -= 50;
- System.out.println("\nYou buy the dagger.");
- option = i.nextLine().toLowerCase();
- dagger = true;
- }else{
- System.out.println("\nNot enough money!");
- option = i.nextLine().toLowerCase();
- }
- }else if(option.equals("t")){
- if(torch == true){
- System.out.println("\nYou already have a torch!");
- option = i.nextLine().toLowerCase();
- }else if(gold >= 100){
- gold -= 100;
- System.out.println("\nYou buy the torch.");
- option = i.nextLine().toLowerCase();
- torch = true;
- }else{
- System.out.println("\nNot enough money!");
- option = i.nextLine().toLowerCase();
- }
- }else if(option.equals("e")){
- town();
- }else{
- option = i.nextLine().toLowerCase();
- }
- }
- }else if(option.equals("e")){
- town();
- }else{
- option = i.nextLine().toLowerCase();
- }
- }
- }
- public static void forest() throws InterruptedException{
- System.out.println("\nYou are in the forest.");
- System.out.println("Options: [E]ast, [W]est, [N]orth, [S]outh");
- option = i.nextLine().toLowerCase();
- while(area == true){
- if(option.equals("e")){
- forestMonsters();
- System.out.println("\nYou went to the east.");
- System.out.println("You see a small house.");
- System.out.println("Options: [E]nter, [W]est");
- option = i.nextLine().toLowerCase();
- while(area == true){
- if(option.equals("w")){
- forestMonsters();
- forest();
- }else if(option.equals("e")){
- System.out.println("\nYou enter the small house.");
- System.out.println("You see an old woman.");
- System.out.println("Options: [T]alk, [E]xit");
- option = i.nextLine().toLowerCase();
- while(area == true){
- if(option.equals("t")){
- if(quest == true && questComplete == false){
- if(q_bearClaw == true){
- q_bearClawCount = 0;
- System.out.println("\nOld Woman: Wonderful, thank you!");
- System.out.println("\nQuest Complete!\nReward: 50 gold");
- gold += 50;
- questComplete = true;
- forest();
- }else{
- System.out.println("\nOld Woman: Please bring me some bear claws.");
- forest();
- }
- }else if(quest == false){
- System.out.println("\nOld Woman: Hello, young one.");
- System.out.println("Old Woman: What brings you here?");
- System.out.println("Options: [Q]uest, [N]ever mind");
- option = i.nextLine().toLowerCase();
- while(quest == false){
- if(option.equals("q")){
- quest = true;
- System.out.println("\nOld Woman: Please bring me some bear claws.");
- forest();
- }else if(option.equals("n")){
- forest();
- }else{
- option = i.nextLine().toLowerCase();
- }
- }
- }else if(questComplete == true){
- System.out.println("\nOld Woman: I don't need help right now.");
- forest();
- }
- }else if(option.equals("e")){
- forest();
- }else{
- option = i.nextLine().toLowerCase();
- }
- }
- }else{
- option = i.nextLine().toLowerCase();
- }
- }
- }else if(option.equals("w")){
- forestMonsters();
- System.out.println("\nYou went to the west.");
- System.out.println("Options: [E]ast");
- option = i.nextLine().toLowerCase();
- while(area == true){
- if(option.equals("e")){
- forestMonsters();
- forest();
- }else{
- option = i.nextLine().toLowerCase();
- }
- }
- }else if(option.equals("n")){
- forestMonsters();
- System.out.println("\nYou went north.");
- System.out.println("You see a cave.");
- System.out.println("Options: [E]nter, [S]outh");
- option = i.nextLine().toLowerCase();
- while(area == true){
- if(option.equals("e")){
- if(torchEquipped == true){
- cave();
- }else{
- System.out.println("\nIt's too dark to see!");
- option = i.nextLine().toLowerCase();
- }
- }else if(option.equals("s")){
- forestMonsters();
- forest();
- }else{
- option = i.nextLine().toLowerCase();
- }
- }
- }else if(option.equals("s")){
- forestMonsters();
- town();
- }else{
- option = i.nextLine().toLowerCase();
- }
- }
- }
- public static void cave() throws InterruptedException{
- System.out.println("\nYou can now see thanks to the torch.");
- System.out.println("\nYou are in the cave.");
- System.out.println("Options: [F]orward, [B]ackward");
- System.out.println("\nUnder construction!");
- forest();
- }
- public static void forestMonsters() throws InterruptedException{
- int fm = r.nextInt(5);
- if(fm == 1){
- wolf();
- }else if(fm == 2){
- bear();
- }
- }
- public static void caveMonsters(){
- int cm = r.nextInt(5);
- if(cm == 1){
- //spider();
- }else if(cm == 2){
- //snake();
- }else if(cm == 3){
- //troll();
- }
- }
- public static void lvlsystem(){
- totalExp += exp;
- if(exp >= nextLvl){
- exp = 0;
- nextLvl *= 1.2;
- lvl++;
- hp += 3;
- hpMax += 3;
- str += 1;
- System.out.println("\nYou are now level " + lvl + "!");
- }
- }
- public static void wolf() throws InterruptedException{
- fight = true;
- m_hp = 5;
- System.out.println(mons[0]);
- while(fight == true){
- m_dmg = r.nextInt(2);
- goldDrop = 1+r.nextInt(5);
- monsterDrop = 1+r.nextInt(3);
- dmg = r.nextInt(str);
- dmg *= 0.5;
- System.out.println("Wolf (HP:" + m_hp + "/5) does " + m_dmg + " damage");
- hp -= m_dmg;
- System.out.println(name + " (HP:" + hp + "/" + hpMax + ") does " + dmg + " damage\n");
- m_hp -= dmg;
- Thread.sleep(1500);
- if(m_hp <= 0){
- fight = false;
- System.out.println("You killed the wolf\nGained 15 exp\nDrops:\n" + goldDrop + " gold");
- if(monsterDrop == 1){
- System.out.println("Potion x1");
- potion = true;
- potionCount += 1;
- }
- gold += goldDrop;
- exp += 15;
- lvlsystem();
- }else if(hp <= 0){
- fight = false;
- System.out.println("\nYou died!");
- System.out.println("Lost some gold.");
- gold *= 0.5;
- hp = hpMax;
- home();
- }else if(hp <= 0 && m_hp <= 0){
- fight = false;
- System.out.println("\nYou died!");
- System.out.println("Lost some gold.");
- gold *= 0.5;
- hp = hpMax;
- home();
- }
- }
- }
- public static void bear() throws InterruptedException{
- fight = true;
- m_hp = 7;
- System.out.println(mons[1]);
- while(fight == true){
- m_dmg = r.nextInt(3);
- goldDrop = 1+r.nextInt(15);
- dmg = r.nextInt(str);
- dmg *= 0.5;
- System.out.println("Bear (HP:" + m_hp + "/7) does " + m_dmg + " damage");
- hp -= m_dmg;
- System.out.println(name + " (HP:" + hp + "/" + hpMax + ") does " + dmg + " damage\n");
- m_hp -= dmg;
- Thread.sleep(1500);
- if(m_hp <= 0){
- fight = false;
- System.out.println("You killed the bear\nGained 25 exp\nDrops:\n" + goldDrop + " gold");
- if(quest == true && q_bearClaw == false){
- if(q_bearClawCount == 3){
- System.out.println("\nI have the bear claws, I should go to the Old Woman now.");
- q_bearClaw = true;
- }else{
- q_bearClawCount++;
- System.out.println("Bear claw");
- }
- }
- gold += goldDrop;
- exp += 25;
- lvlsystem();
- }else if(hp <= 0){
- fight = false;
- System.out.println("\nYou died!");
- System.out.println("Lost some gold.");
- gold *= 0.5;
- hp = hpMax;
- home();
- }else if(hp <= 0 && m_hp <= 0){
- fight = false;
- System.out.println("\nYou died!");
- System.out.println("Lost some gold.");
- gold *= 0.5;
- hp = hpMax;
- home();
- }
- }
- }
- public static void spider(){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment