Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CS 7 Project 2

Text Adventure Game Part 2

(Survival Mode)

 Spring 2023

Project Summary:

In this project, we will extend the text adventure game we created as part of Project 1. You will

implement a new Survival Mode as part of the game using conditionals and loops. Sample outputs and the pseudocode are included on canvas.

Constraints:

•   There are no constraints for this project.

Step-by-step breakdown:

A.   Like in Project 1, you will start by setting up the player characteristics such as the player name, health, armor, and attack. You can use the same way of setting up as in Project 1 except  for  the  health  which  needs  to  be  random  in  the  range  of  900  to  1000.

B.   Implement STANDARD mode.

I.      First, you will select the game mode

II.      This will be stored in an integer, which can take a value of 0 for Standard mode, and 1 for Survival mode.

III.       If the variable's value is set to 0, i.e., Standard Mode, you will run Project 1. That is set up with three enemies and one player who battles, taking turns. No change from Project 1 is needed.

C.   Implement SURVIVAL mode.

I.      In survival mode, the player will face off against multiple enemies as part of an enemy group for numerous rounds. The number of enemies in an enemy group will be based on the difficulty level of the game.

II.      The  greater  number  of  rounds  the  player  survives,  the  higher  their  score.

III.       In the survival mode, the player can play in multiple difficulty levels 

•   Newbie Difficulty

•   Easy Difficulty

•   Standard Difficulty

•   Hard Difficulty

IV.      Setting up the difficulty level

•   There will be three difficulty levels that you need to consider. Depending on  the  difficulty  level,  enemies  or  players  may  get  certain  perks.  For instance, at higher difficulty levels, enemy armor, and attack will increase by a set % after each round. There is a fourth one that is part of the bonus question. For each difficulty level listed below, take the mentioned actions.

•   Newbie difficulty:

Print You have chosen newbie difficulty??? You disappoint me. Well, you regain all your health after each round. Your enemies wont get stronger as we go on.”

Enemy features:

•   Enemy attack strength remains unchanged .

•   Enemy armor strength remains unchanged.

•   The maximum number of enemies in an enemy group is limited to 3.

Player features:

•   The player gets to attack first.


•   Player health is restored at the start of each round.

•   Easy difficulty:

Print   "You  have  chosen  easy  difficulty.  You  still disappoint me, but at least you are showing courage. You wont be regaining health with each new round, but your enemies wont get stronger. "

Same as the Newbie difficulty level but

•   Maximum enemy group size can go up to 5.

•   Player health is not restored at the start of each round.

•   Standard difficulty:

Print You have chosen standard difficulty. I am still disappointed. You are yet to prove that you are worthy. Your enemies will get stronger though the longer the fight goes.”

•   Enemy attacks will go up by 5% in each new round.

•   Enemy Armor will go up by 5% in each new round.

•   Max enemy group size can go up to 7.

•   The player does not get the first turn to attack.

•   Player health is not restored at the start of each new round .

•   Hard difficulty:

Print You have chosen HARD difficulty. Hahaha, you messed up. Overconfident, are we? Time to send you back to warrior school.



•   Enemy   attacks   will   go   up   by   20%   in   each   new   round.

•   Enemy Armor will go up by 20% in each new round.

•   Maximum enemy group size can go up to 10.

•   The player does not get the first turn to attack.

•   Player health is not restored at the start of each new round .

V.      Simulate a new round

•   A new round will start if the player survived the last round, i.e. if they have positive  health  at the  end  of the  previous  round.  Also, the  maximum number of rounds is 100, so a new round will not start if the player has survived 100 rounds.

•   In each round, the player will fight one enemy group, which is made up of several enemies. Instead of fighting each enemy one by one, the player will fight the whole enemy group simultaneously.

•   The minimum number of enemies possible in an enemy group will be at least two, and the maximum number will be based on the difficulty level selected by the player. The number of enemies in the enemy group will be decided  randomly  in  the  range  of  the  minimum  number  of  enemies possible to the maximum number of enemies possible.

•   After determining the number of enemies in the enemy group, you must calculate the enemy group's health, attack power, and armor level. These will be computed as the sum of the individual enemy attributes BUT also should be adjusted based on the difficulty level. For instance, suppose you have two enemies in the enemy group, both with the same attack power of 5. The final enemy group attack power will be 5 + 5 + (5% of enemy 1 attack power) + (5% of enemy 2 attack power) if playing on the Standard difficulty level since that boosts the enemy attack and armor by 5%.

•   Enemy health, attack, and armor will be initialized in the same way as project 1 using Random with the same bounds.



•   Simulate a confrontation

•   Now the battle starts. Based on the difficulty, determine who goes first. Suppose the player attacks first, then they attack the enemy group, and like how you computed the change in health in Project 1, the enemy group health will be updated . After this, the enemy group attacks the player and the player’s health will be updated. The order is reversed if the player does not attack first.

•   If neither the player nor the enemy is defeated (health <= 0), the confrontation continues until one is defeated.

•   If the enemy is defeated in the confrontation, move to the next round.

Keep  doing this  until the  player  is  defeated  or the  number  of  rounds reached is 100.

•   Once the player is defeated, print out their final score, which is the number of rounds they survived.

Bonus points: Fall-through practice (20 points)

•   The player has found an exploit to unlock a hidden difficulty mode called the GOD (Grudge of the Developer).

•   Players can enter this Mode by entering ANY difficulty other than 0 (newbie), 1 (easy), 2 (standard), and 3 (hard).

•   This difficulty level will be set up like hard difficulty, i.e., similar attack, armor, enemy group size, etc.

•   Once those are set up, next you will be rolling the dice. The higher the number on the dice, the more perks you get.

o Except if you roll a 1. If you roll a one, then

print "Your luck just ran out! The devs have included a failsafe. An enemy group of multiple enemies will swarm you!"


Set the maximum enemy group size to 50.

o Otherwise, if you roll 2, you get to attack first.

o If you roll a 3, your health is restored after each round.

o If you roll a 4, your attack power is set to 100.

o If you roll a 5, your armor is set to 50.

o If you roll a 6, you get 10000 starting health.

•   These are cumulative, so rolling a 6 gets you all the perks from 2 to 6, rolling a 5 gets you all the perks from 2 to 5, and so on.

•   You need to use a Switch case with Fall-through to get full credit.

Important considerations

•   In addition to the print statements mentioned above, look at the sample output to    figure out the other print statements that may be needed to make your output more readable.

•   When updating the enemy attack and armor based on difficulty, consider casting it to  double first; otherwise, it might change to zero. Look at the slides on Operators, which include casting on Canvas. For example, this is how you will update the attack:

int initialEnemyAttack = random.nextInt(5, 11);              System.out.print("Attack: " + initialEnemyAttack + "\n");    double enemyAttack = initialEnemyAttack + (((double)         enemyAttackChange / 100) * initialEnemyAttack);              enemyGroupAttackPower += enemyAttack;                       

Here, enemyAttackChange comes from the difficulty level.

•   Limit the maximum number of rounds to 100.

•   In round 1, you should not restore player health.

•   When a confrontation is taking place, if either the enemy group or the player is    defeated, you should immediately stop the confrontation. For instance, if it is the

player's turn first and they defeat the enemy group, then the enemy group should not get their turn in this confrontation.

•   You are no longer restricted to using only print statements. You can also use println.

•   For random number generation, use a similar approach to Project 1, i.e., use System time as the seed (-5 points if not followed).

Rubric:

•   (5  points) Correctly set  up the  if-else  part of selecting the game  mode  (Standard or Survival).

•   (20 points) Correctly set up (declare, initialize, and update) the variables for the player (5 points), the enemy (5 points), the enemy group (5 points), and difficulty (5 points). Use Random wherever needed (similar to Project 1). Not using System time as a seed for random will result in a 5 points deduction. Note the difficulty variables will be a mix of integers and Booleans.

•   (30 points) Correctly set up the Switch case for difficulty scenarios  (5 points for each difficulty, 10 points for the setup).

•   (20 points) Correctly setup the enemy group stats (health, attack, and armor) (5 points each) using a loop (5 points for correctly setting up the loop).

•   (25 points total) Correctly set up the confrontation – order of attack (5 points), update of health (5 points), check for defeat (10 points), while or do while loop with the correct condition (5 points).

•   (40 points total) Correctly set up the loop for simulating the game (rounds) – update the score (5 points), check and update based on perks (5 points), correctly sequence the code (enemy group setup and confrontation) (20 points), and setup the correct condition (10 points).

•   (10  points)  Readable,  well-formatted  output  with  sufficient  print  statements.  Check sample outputs to ensure you get all the statements you need to print.

Total: 150 points + 20 points for the bonus. Due to the increased difficulty of this project from Project 1, the grade of this project will be scaled appropriately.

Submission:

Create and submit a file called Project2.java with your code. You can include your attempt at bonus points in the same file.