Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN C LANGUAGE MONSTER BATTLE $ $ Room 1 Room 2 Room 3 Room 4 Room 5 The project is to create a game in
IN C LANGUAGE
MONSTER BATTLE $ $ Room 1 Room 2 Room 3 Room 4 Room 5 The project is to create a game in which a player goes through a series of rooms in which they can find a prize or a monster to fight. Game Rules: A player will enter the number of rooms (greater than 1) they want to endure. The program will dynamically allocate an array of Rooms and populate it with prizes and monsters. Then, the player will enter each room in which an action will occur: o If the player enters a room with a prize, they will get a random value between 5 and 15, inclusive, added to their hitPeints: If the player enters a room with a monster, the player will lose hitPoints based on the monster's hit points and the player's experience Points. The monster's hitpeints is a random value between 10 and 30, inclusive. The total number of hitPeints lost is equal to the monster's hit Peints minus the player's experience Paints. Should the player's experience Paints be greater than the monster's hitpeints, the player does not lose any hitpeints. Each time a player battles a monster (win or lose), the player will get an increase to their experience Paints If a player's hitrointe goes to zero or below at any point, they automatically lose. . If a player completes all the rooms without their hitfginte going to zero at any time, they win. Task 1 - create and write monsterbattles & monsterbatteri Write the source (c) and header (h) files for the game. The header file will include all the struatis you need, an enum, and the prototypes for the functions below. anum Include the following enum in your header file for determining what the room type is: typedef enum TYPE ( EMPTY, PRIZE, MONSTER | TYPE; structs Character-this struct has two data members hitreinta and exReriencePrints. This struct will mainly represent a monster in the game. In this game, a monster's hitPeinta represents the amount of damage it can inflict on the player and the experience Peinta is the number of experience points the player gains from battling this monster. NOTE that this struct will also be used to represent the player in which case the hitreinta represents their life points. Should this value go to zero or below, they have died. The experience points for a player are used to deflect a monster's attack. Prize-this struct has one data members points. The points value is what is awarded to a player's hitpointa should they enter a room with a prize. Room - this struct represents a room. The game will create an array of these structs. The struct has three data members: type (see the enum above) to determine if this room is empty, has a monster, or a prize. If the room has a prize, then the prize data member will be initialized (see fillBeame()). If the room has a monster, then the monster data member will be initialized (see all Reams () ). If the room is empty, nothing happens with these data members. This struct is provided to you here: typedef struct Room { TYPE type Character monster; Prize Prize } Room; Prototypes See functions in Task 2 below. Write all the prototypes. Task 2 - create and write monstechettles (Monster Battle functions) Write the following functions that use all the structs above. int getRandomNumber( int min, int max ) - This function computes a random number between min and max, inclusive, and returns it. void fill Resma ( Room *rooms, int length ) - This function fills the array of rooms with a prize, monster, or nothing (empty room). There is a 10% chance that this room is empty, a 40% chance that this room has a prize, and 50% chance that this room has a monster in it. To do this, you can use the function getRandomsumber() to generate a random number between 0 and 9, inclusive, and use those values to determine which type to set. o Set the room's type data member to EMPTY, PRIZE, or MONSTER If the type is PRIZE, set the room's prize data member's points data member to a random value between 5 and 15, inclusive. If the type is MONSTER, set the room's monster data member's hitPeinta data member to a random value between 10 and 30, inclusive, using the gatRandomlunksno). If room's monster data member's hitreinta is a multiple of 3, set the room's monster data member's experience Peinta data member to 3. Otherwise, set its experiencePeints to 1. If the type is EMPTY, do not set any other of the room's data members. void enterRegn ( Room Eger, Character player, int *resultar int *resultXP) - This function simulates the character entering a room. o If the room type is EMPTY, print out a message that says the room is empty. Set the dereferenced values of resultar, and assultxp to 0. If the room type is PRIZE, print out a message that says the room has a prize and how many points it has. Set the dereferenced values of resultap to the prize's points and resultXP to 0. o If the room type is MONSTER, print out a message saying that the room has a monster. Do the battle calculations (see the rules above) to figure out how much damage was done (this should be a negative number). Set the dereferenced values of resultar to the total damage and resultXe to the number of experience Peinta awarded by the monster. This function returns nothing. void printCharacter ( Character c ) - This function prints out the Character's data member. It could look like this: Player (HP: 20, XP: 9). Assume it will only be used to print out the player's information. Task 3: Complete the main Download the attached mainos Follow the instructions written in the comments in the main() function. The main() is the driver of the program. It calls the functions above set up the game and to simulate the battles. #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started