Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / For this assignment, you will create a game that will allow your player to battle an enemy in a turn-based fashion

For this assignment, you will create a game that will allow your player to battle an enemy in a turn-based fashion

Computer Science

For this assignment, you will create a game that will allow your player to battle an enemy in a turn-based fashion.

First, you will be using an abstract data type to model the player. You will create a class which has the following traits to create a player object:

Player:

• HP: Health Points. This is the player's health. Starts at 150 and can max at 200.

• PlayerName: This is the player's name.

• WeaponModifier: The value that will multiple the attack. Defaults to 1.

The player will support the following methods:

- WeaponAttack(): This action returns a randomized attack value (int).

- Heal() : This actions allows the player to heal himself by returning an int that increases the HP.

Your player will battle an Enemy for which you will have to create an object. The Enemy object will need to have the following attributes:

Enemy:

HP: Enemy's Health. Will start at 300.

Enemy method:

Attack(): Generates an attack value to attack the player. This is random value from 10 to 20. The values "13" and "17" will be considered a miss and have 0 damage against the player.

You will give the user of your program the option to start a game and enter the player's name.

Then they will enter a loop that will only end when either the player HP goes to 0 or the Enemy HP goes to 0.

On the Players Turn:

Attack Action

The player will choose either an random action or weapon attack.

a) Random Action = This will generate a random number between 1 and 4

a. If 1 or 4 comes out nothing will happen

b. If 2 comes out the player it will call Heal()

c. If 3 comes, you will increase the modifier by +1 each time

b) Weapon Attack= This will call the weapon Attack method

Method Effects:

WeaponAttack(): This will randomize a value from 5 to 10. This will multiply the value rolled times the weapon modifier.

Example: If player rolls a 6 and the weapon modifier is 3, then the final attack will be 6 * 3 (sword modifier in struct) = 12

Heal(): If the player has a potion, this will heal the players HP by 25 points.:

On the Enemy Turn:

On the enemy's turn, call the attack method (remember that a value of 13 and 17 will yield an attack of 0 or a miss). Play the game several times to test its logic. Make sure the following is displayed

1. The player and the enemy's HP must be displayed at all times.

2. When healing, player HP cannot go above the maximum HP.

 

Grading Criteria:

1. Turn based game loop (5 pts)

2. Player implemented as Object with its properties (5 pts)

3. Enemy Implemented as Object with its properties (5pts)

4. Chance/ Attack Action Loop (5 pts)

Answer should be typed format only without insert table or image.
Copied content strictly prohibited remember.

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions