Question: In this assignment, you will partially rewrite and enhance the adventure game that you coded in Assignment 2 to create the 3rd version of the

In this assignment, you will partially rewrite and enhance the adventure game that you coded in Assignment 2 to create the 3rd version of the game. Store your code in a file named AdventureGameV3.java.

The focus of this assignment is: (1) working with arrays; and (2) file input/output. New Features You will add three new features to the original game. 1. Improved Pacing (Note: this is a featured that you implemented in Assignment 3) Improve the pacing of the game by prompting the player to hit a key after each minion (i.e. Goblin/Skeleton) fight. So when the player battles multiple minions, instead of simulating all the fights and printing all the outputs together, the first fight will be simulated and its results printed, but then the user will be prompted to hit the Enter key to continue to the next fight.

In this assignment, you will partially rewrite and enhance the adventure game

that you coded in Assignment 2 to create the 3rd version of

the game. Store your code in a file named AdventureGameV3.java. The focus

ADVENTURE GAME SOLUTION:

import java.util.Scanner; import java.util.Random; public class AdventureGameSolution { public static void main(String[] args) { final int SHORT_SWORD_MIN = 1; final int SHORT_SWORD_MAX = 4; final int LONG_SWORD_MIN = 3; final int LONG_SWORD_MAX = 7; final int JUMP_KICK_MIN = 2; final int JUMP_KICK_MAX = 6; final int AXE_MIN = 2; final int AXE_MAX = 6; final int FIRE_BLAST_MIN = 4; final int FIRE_BLAST_MAX = 10; final int ROGUE_INIT_HP = 55; final int ROGUE_INIT_STRENGTH = 8; final int PALADIN_INIT_HP = 35; final int PALADIN_INIT_STRENGTH = 14; final int CHAN_INIT_HP = 45; final int CHAN_INIT_STRENGTH = 10; final int MINION_INIT_HP = 25; final int GOBLIN_INIT_STRENGTH = 4; final int SKELETON_INIT_STRENGTH = 3; final int WIZARD_INIT_HP = 40; final int WIZARD_INIT_STRENGTH = 8; final int NUM_GOBLINS = 3; final int NUM_SKELETONS = 5; String playerName = ""; int playerHP = 0, playerStrength = 0, playerDamageMin = 0, playerDamageMax = 0; String enemyName = ""; int enemyHP = 0, enemyStrength = 0, enemyDamageMin = 0, enemyDamageMax = 0; int characterChoice = 0, pathChoice = 0, itemChoice = 0, numEnemies = 0; String pathName = ""; int playerDamage, playerATK; int enemyDamage, enemyATK; int playerActionChoice, randomNumAnswer, randomNumGuess; Scanner keyboard = new Scanner(System.in); Random randomNums = new Random(); System.out.println(" Adventure Game - Start! "); System.out.println("Here are the characters:"); System.out.println("1. Rogue 2. Paladin 3. Jackie Chan "); System.out.print("Which character do you choose?: "); characterChoice = keyboard.nextInt(); switch(characterChoice) { case 1: playerName = "Rogue"; playerHP = ROGUE_INIT_HP; playerStrength = ROGUE_INIT_STRENGTH; playerDamageMin = SHORT_SWORD_MIN; playerDamageMax = SHORT_SWORD_MAX; break; case 2: playerName = "Paladin"; playerHP = PALADIN_INIT_HP; playerStrength = PALADIN_INIT_STRENGTH; playerDamageMin = LONG_SWORD_MIN; playerDamageMax = LONG_SWORD_MAX; break; case 3: playerName = "Jackie Chan"; playerHP = CHAN_INIT_HP; playerStrength = CHAN_INIT_STRENGTH; playerDamageMin = JUMP_KICK_MIN; playerDamageMax = JUMP_KICK_MAX; break; } System.out.printf(" You chose: %s ", playerName); System.out.print("The Evil Wizard must be defeated! He is in The Castle. To get to "); System.out.println("The Castle, you must travel through either:"); System.out.println("1. The Forest 2. The Graveyard "); System.out.print("Which path will you take?: "); pathChoice = keyboard.nextInt(); switch(pathChoice) { case 1: pathName = "The Forest"; enemyName = "Goblin"; enemyStrength = GOBLIN_INIT_STRENGTH; enemyDamageMin = AXE_MIN; enemyDamageMax = AXE_MAX; numEnemies = NUM_GOBLINS; break; case 2: pathName = "The Graveyard"; enemyName = "Skeleton"; enemyStrength = SKELETON_INIT_STRENGTH; enemyDamageMin = SHORT_SWORD_MIN; enemyDamageMax = SHORT_SWORD_MAX; numEnemies = NUM_SKELETONS; break; } System.out.printf(" You chose: %s ", pathName); System.out.printf("Once you enter %s, you encounter %d %ss! Time for battle! ", pathName, numEnemies, enemyName); for (int i = 1; i  0 && playerHP > 0) { playerDamage = randomNums.nextInt(playerDamageMax - playerDamageMin + 1) + playerDamageMin; playerATK = playerStrength + playerDamage; enemyHP -= playerATK; System.out.printf("%s attacks with ATK = %d + %d = %d ", playerName, playerStrength, playerDamage, playerATK); System.out.printf("%s HP is now %d - %d = %d ", enemyName, enemyHP + playerATK, playerATK, enemyHP); if (enemyHP  0) System.out.printf("%s defeated %s %d! ", playerName, enemyName, i); else { System.out.printf("--%s is defeated in battle!-- GAME OVER ", playerName); System.exit(0); } } // end of for loop System.out.printf("Your HP is: %d ", playerHP); System.out.println("Please choose a reward. 1. Healing Potion 2. Ring of Strength "); System.out.print("Which item do you choose?: "); itemChoice = keyboard.nextInt(); switch(itemChoice) { case 1: System.out.println(" You chose: Healing Potion "); playerHP += 10; System.out.printf("Your HP has increased to %d + %d = %d! ", playerHP - 10, 10, playerHP); break; case 2: System.out.println(" You chose: Ring of Strength "); playerStrength += 5; System.out.printf("Your Strength has increased to %d + %d = %d! ", playerStrength - 5, 5, playerStrength); } System.out.println("You have now reached The Castle! Time to battle The Evil Wizard! "); enemyName = "Wizard"; enemyHP = WIZARD_INIT_HP; enemyStrength = WIZARD_INIT_STRENGTH; enemyDamageMin = FIRE_BLAST_MIN; enemyDamageMax = FIRE_BLAST_MAX; randomNumAnswer = randomNums.nextInt(6) + 1; System.out.printf("***%s vs The Evil Wizard*** ", playerName); while(playerHP > 0 && enemyHP > 0) { System.out.println("Choose your action: 1. Attack 2. Attempt Spell Cast "); System.out.print("What would you like to do: "); playerActionChoice = keyboard.nextInt(); switch(playerActionChoice) { case 1: playerDamage = randomNums.nextInt(playerDamageMax - playerDamageMin + 1) + playerDamageMin; playerATK = playerStrength + playerDamage; enemyHP -= playerATK; System.out.printf(" %s attacks with ATK = %d + %d = %d ", playerName, playerStrength, playerDamage, playerATK); System.out.printf("%s HP is now %d - %d = %d ", enemyName, enemyHP + playerATK, playerATK, enemyHP); break; case 2: System.out.print("Enter your guess: "); randomNumGuess = keyboard.nextInt(); if (randomNumGuess == randomNumAnswer) { System.out.println(" Correct! "); System.out.printf("The %s's spell is cast successfully! The Wizard's HP is now 0! ", playerName); enemyHP = 0; } else System.out.println(" Incorrect! The spell cast fails! "); break; } if (enemyHP  0) { System.out.printf("--%s wins the battle!-- ", playerName); System.out.println("You win! Congratulations!"); } else { System.out.printf("--%s is defeated in battle!-- GAME OVER ", playerName); } } // end of main } // end of class 

Link to the sample output of program: https://www.dropbox.com/s/bxgwejy64nu2dv9/Assignment4-Fall2017-SampleOutput.pdf?dl=0

Assignment 4: Arrays and File l/O in the Adventure Game Deadline: Friday, November 17 at 11:59 PM Cri In this assignment, you will partially rewrite and enhance the adventure game that you coded in Assignment 2 to create the 3rd version of the game. Store your code in a file named AdventureGameV3.java. The focus of this assignment is: (1) working with arrays; and (2) file input/output. New Features You will add three new features to the original game. 1. Improved Pacing (Note: this is a featured that you implemented in Assignment 3) Improve the pacing of the game by prompting the player to hit a key after each minion (i.e. Goblin/Skeleton) fight. So when the player battles multiple minions, instead of simulating all the fights and printing all the outputs together, the first fight will be simulated and its results printed, but then the user will be prompted to hit the Enter key to continue to the next fight. 2. A New, Powerful Weapon In addition to the option of choosing a Healing Potion or a Ring of Strength, present the player with a third option: Staff of Power. Weapon Name: Staff of Power Damage: 59

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!