Answered step by step
Verified Expert Solution
Link Copied!

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 0 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 20 health, and the player starts with 10 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 do?{a: attack, h: heal, anything_else: 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 1 and 6, simulating a 6 sided die.If the roll is a 1, then the attack misses and the players turn is over. Display the following message:Your attack missed!If the roll is between 2 and 5, then the attack hits. Generate a random number between 1 and 4(now rolling a 4 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 3, you would display:Your attack did 3 damage to the dragon.If the 6 sided die roll is a 6, then the attack hits a weak point on the dragon. Generate two random numbers, both between 1 and 4(from the 4 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 4 sided dice rolled a 2 and then a 3:You found a weak point on the dragon!Your attack did 5 damage to the dragon.When the player heals, generate a random number between 3 and 8. 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 7, you would display: You restored 7 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 0. Only if the dragons health is greater than 0 should the dragon have a turn and do the following:Generate a random number between 1 and 3 for the dragons action (dragons have a hard time using keyboards).On a 1, 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 2, the dragon will swing its tail at the player. The damage also needs to be rolled for randomly. The damage will be between 1 and 3 which you will then remove from the players health. For example, if the dragon damage was a 1: The dragon swings its tail at you dealing 1 damage to you.On a 3, the dragon will swipe its claw at the player. This will do between 3 and 5 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 4 damage to you. if the random number between 3 and 5 turned out to be a 4.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 0 or less health. Display the following:Health BannerPlayer Health: 10Dragon Health: 17Note: There is an extra blank line after the dragon health.Once the player or the dragon has 0 or less health, the loop should stop and then:If the player has 0 or less health, display:The Dragon Won!If the dragon has 0 or less health, display:The Player Won!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

1. Identify and control your anxieties

Answered: 1 week ago