Question: I need this in Javascript please, been working on it for a month and have made almost zero progress. Assignment 4: 75 points This assignment
I need this in Javascript please, been working on it for a month and have made almost zero progress.
Assignment 4: 75 points This assignment covers module 6 and module 7, and module 8 topics. To write the programs below you will need to demonstrate an understanding of the following topics: Objects Functions Arrays Random Numbers variables simple data types expressions loops Please refer back to the module lectures if you find you have any gaps in your understanding for these topics.
Introduction Emboldened by your newly learned skills, you decide to face Scarlet Byte alone. Unfortunately, you are defeated swiftly by Scarlet Bytes notorious body guard, Input Error, known for his "Devils Kick", a swift and deadly style which has never been defeated. Returning to Iron Professor you study even harder in a form of fighting known as the "The Eight Deadly Venoms", named after the eight mythological JavaScript features that the fighting style emulates. Now that all his pupils have mastered the Eight Deadly Venoms and Transcended to the Golden Army of Software Way, Iron Professor now plots the final duel with Scarlet Byte. The Golden Army approaches Scarlet Bytes fortress at dawn. With armor gleaming in the sunlight, they sound the battle cry .... JS Rocks!!!! They descend upon Scarlet Bytes Army and the battle begins. To defeat Scarlet Byte, the Golden Army must combine all the Eight Deadly Venoms. Will you emerge victorious, or will the Seven Kingdoms be cast into years of darkness? Let the battle begin.
Create a script called battlejs. In this script code the following: A. Class and Constructor Creation (25 Points) Player Class Create a constructor function or ES6 class for a Player object.
The Player object should have the following properties: Name: Holds the name of the player. Pass into the constructor.
Health: Defaults to 10, do not pass into the constructor, just define and set to 10 in the constructor Strength: Defaults to 2
Weapons: An array of weapons objects. Should be passed into the constructor.
Weapon Class Create a constructor function or ES6 class for a Weapon object. It should have the following properties: Name: Holds the name of the weapon. Passed into the constructor.
Damage: Defaults to a random number between 1 and 5, do not pass into the constructor, just define in the constructor and net it.
Minion Class Create a constructor function or ES6 class for a Minion object. The Minion object should have the following properties: Name: Default to "Minion" Health: Default to 5 Strength: Default to 2 Game Class Create a constructor function or ES6 class for a Game object. Give it the following properties:
Players: An Array to hold the players, Initialize it in the constructor to an empty army
Minions: An Array to hold Scarlet Bytes minions. Initialize it in the constructor to an empty array
B. Methods to add (25 Points) Player Class Add a function to the Player prototype called "applyDamage". The function takes as input an integer and subtracts that amount of points from the players health property. Displays the message "{Player Name} has sustained {damage} amount of damage." Where you see a value inside dB. display the value from the object or calculated value. Add a function to the Player prototype called "isAlive". This function checks if the players health value is greater than 0 and returns true if it is and false if it isn't. Add a function to the Player prototype called "attackWith". This function should use a random number between 7 and 0, to select a weapon from the weapons array property, at that index and retums that weapon.
Minion Class Add a function to the Minion prototype called "applyDamage". The function takes as input an integer and subtracts that amount of points from the minions health property. Displays the message "{Minion Name} has sustained {damage} amount of damage." Where you see a value inside of {1, display the value from the object or calculated value. Add a function to the Minion prototype called "IsAlive". This function checks if the minions health value is greater than 0 and returns true if it is and false if it isn't Add a function to the Minion prototype called "attack". This function takes as input a player and calls the applyDamage of the player, using the minions strength as the input
Weapon Class Add a function to the Weapon prototype called "attack". The function takes as input a player, and a minion. The attack function should implement the following algorithm: Ina loop, while both the player and the minion are alive, do the following: 1. Calculate the actual damage by multiplying the strength of the player times the damage value of the weapon. 2. Call the applyDamage function of the minion object and pass it the actual damage value you just calculated. 3. Call the isAlive function of the minion object. If the minion is dead, exit. If the minion is not dead, call the attack function of the minion and pass it the player object.
Game Class Add a function to the Game class prototype called "createMinions". In this function, use a loop to create 20 minions and populate the minions array property. Add a function to the Game class prototype called 'createPlayers". In this function, do the following: Create a variable called "weaponsCache" and assign it 8 weapons from the Weapons discussion forum. Make sure you create and post your weapon in the forum. Populate the games players array. Use at least 5 of your classmates characters posted to the character discussion board in the course. Make sure you post the code to create a character representing yourseff in the discussion board. For example, when you go to the discussion board, you will see a character for me and you can add that as a line in your createPlayers function. Add a function to the Game class prototype called "play". In this function, implement the following algorithm: Display "Simulating Battle Call the "createMinions" function to create the minions. Call the "createPlayers' function to create the players. While all minions are alive and there are still players alive: Select a random player from the player array Select a random minion from the minon array Call the attackWith Method on the player, to get a weapon to attach with. Call the attack method on the weapon and pass it the current player and current minion. When the loop is completed, display a list of all players currently alive and if there am more players left than minions, display "Congratulations, you have defeated Scarlet Byte."
C. Test Program 15 points :Create an instance of the Game class and call the play function.
5 points: Create a player instance to represent you and post in the forum
5 point Create a weapon instance and post in the forum. Save battle.js in a folder named Assignment_4. Zip that folder and submit in the Assignment 4 Dropbox.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
