Answered step by step
Verified Expert Solution
Question
1 Approved Answer
DescriptionIn this program, you are going to create a text based game where the player is fighting a dragon. This program will heavily use the
DescriptionIn this program, you are going to create a text based game where the player is fighting a dragon. This program will heavily use the random module, branching and while loops. This will work in turns and keep going until either the dragon or the player has or less health and has thus been defeated. The player always goes first and when it is the dragons turn, if it has any health remaining, then it will take its action.Since you are using the random module, you need to ask the user for a random seed one time at the beginning of the program so that there are reproducible results. Your prompt for input should beEnter a seed number: and should end with a colon, a space, and a newline.Since the dragon is stronger than the player, the dragon starts with health, and the player starts with health.The player has two actions they can take. You will get the action from input. The player can either attack the dragon or heal themselves. The input for attack is a and the input for heal is h On any other input for the player action, then the player is confused and will not do anything.At the beginning of the players turn, you should ask the player for their input with the following prompt:What do you want to doa: attack, h: heal, anythingelse: do nothing The prompt to the user should end with a blank space and newline.Player Actions:When the player attacks, display a message stating you attacked the dragon:You attacked the dragon!Then generate a random number between and simulating a sided die.If the roll is a then the attack misses and the players turn is over. Display the following message:Your attack missed!If the roll is between and then the attack hits. Generate a random number between and now rolling a sided die for how much damage the attack does. Display the damage amount and then subtract the damage from the dragons health. For example, if you rolled a you would display:Your attack did damage to the dragon.If the sided die roll is a then the attack hits a weak point on the dragon. Generate two random numbers, both between and from the sided die and add them together. The combined total is the damage the attack does. Display the damage amount and then subtract the total damage from the dragons health. For example, if your sided dice rolled a and then a :You found a weak point on the dragon!Your attack did damage to the dragon.When the player heals, generate a random number between and That is the amount to add to the players health. You do not need to worry about a maximum health. For example, if your random number came out to be you would display: You restored health.If anything else is gotten from input, then the player is confused and will not know what to do and it will be the dragons turn. Display the following: You're dazed from the fight and take a moment to gather yourself.Dragon Actions:For the dragons turn, first check if its health is greater than Only if the dragons health is greater than should the dragon have a turn and do the following:Generate a random number between and for the dragons action dragons have a hard time using keyboardsOn a the dragon will laugh at the player in arrogance and not do anything else. Display: The dragon laughs at you arrogantly and does nothing else.On a the dragon will swing its tail at the player. The damage also needs to be rolled for randomly. The damage will be between and which you will then remove from the players health. For example, if the dragon damage was a : The dragon swings its tail at you dealing damage to you.On a the dragon will swipe its claw at the player. This will do between and damage to the player that needs to be randomly generated and then removed from the players health. Display: The dragon swipes at you with its claw dealing damage to you. if the random number between and turned out to be a After the player and dragon have had their turns, display both the dragons and the players health. This should be displayed even if the dragon already has or less health. Display the following:Health BannerPlayer Health: Dragon Health: Note: There is an extra blank line after the dragon health.Once the player or the dragon has or less health, the loop should stop and then:If the player has or less health, display:The Dragon Won!If the dragon has or less health, display:The Player Won!
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