Question: Need a program in js to comeplete this prgram Create a prototype Pokemon object Using that prototype Pokemon object, create two pokemon (Pikachu, Butterfree). After

Need a program in js to comeplete this prgram

  1. Create a prototype Pokemon object

  2. Using that prototype Pokemon object, create two pokemon (Pikachu, Butterfree).

  3. After creating two Pokemon, start the battle!

  4. In your battle, write the logic to have the Pokemon alternate attacking each other

  5. After each attack, output the results of the attack. The results should display the updated HP of each pokemon.

  6. If at any point, a Pokemons HP goes to 0, end the battle and show a results message. The message show

    1. BATTLE OVER! Header

    2. The name of the Pokemon who won

    3. The HP of the both Pokemon

When performing the battle, you must use the prototypes class functions.

Sample output of your program:

BATTLE START!

Pikachu (20HP) vs. Butterfree (30HP)

Pikachu attacks!

Butterfree takes 5 damage!

Pikachu: 20/20 HP

Butterfree: 25/30 HP

Butterfree attacks!

Pikachu takes 3 damage!

Pikachu: 17/30 HP

Butterfree: 25/30 HP

Pikachu attacks!

Butterfree takes 5 damage!

Pikachu: 17/20 HP

Butterfree: 20/30 HP

. (etc, etc, etc)

Butterfree attacks!

Butterfree misses!

Pikachu: 7/20 HP

Butterfree: 5/30 HP

.

Pikachu attacks!

Butterfree takes 5 damage!

Butterfree fainted!

BATTLE OVER!

Pikachu wins!

Pikachu: 7/20 HP

Butterfree: 0/30 HP

Pokemon Prototype Object

The Pokemon prototype object has the following properties and functions:

Properties:

Property

Description

name

The name of the Pokmeon (Pikachu, Butterfree, Charizard, etc)

maxHP

A number representing the maximum health points the Pokemon has.

currHP

A number representing the current amount of health points the Pokemon has. Initially, the currentHP equals maxHP.

Whenever the pokemon takes damage, the amount of damage is deducted from the current HP.

attackPower

A number representing the amount of damage the Pokemon can do

isDead

True if the Pokemons current HP <= 0. False otherwise.

Functions

Function

Description

attack

This function determines if the Pokemons attempt to attack is succeeds or misses.

There is a 35% chance that the attack will miss. If the attack misses, the other Pokemon takes 0 damage.

If the attack is successful, return true.

If the attack misses, return false.

takeDamage(amt)

This function reduces the amount of current HP the Pokemon has by the amount specified in the function parameter.

For example, suppose a Pokemon has a current HP of 100.

After calling takeDamage(25), the Pokemons current HP will be reduced to 75.

If the current HP <= 0, then update the isDead property.

displayStats()

Outputs the pokemon name and current hp to the console.

Example:

Pikachu: 15/20 HP

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!