Need help with your Discussion

Get a timely done, PLAGIARISM-FREE paper
from our highly-qualified writers!

glass
pen
clip
papers
heaphones

Grossmont College Calculate Damage in Dungeons and Dragons Python Code

Grossmont College Calculate Damage in Dungeons and Dragons Python Code

Grossmont College Calculate Damage in Dungeons and Dragons Python Code

Question Description

Project: Python

In this project, you will create a simple program to roll some dice and calculate damage in the style of Dungeons and Dragons, a popular roleplaying game.

What you need to know

One of the main components of the game is the dice roll. This allows for randomization and adds variations to the game. Die sides are denoted by d3, d6, d20, etc., with the number referring to the number of sides that the die has. Since we are using a computer, we can have a die like d1000 (meaning a 1000-sided die) which would not be possible in real life. We can also roll multiple dice.

For example, 1d6 means a six-sided die that can output anything from 1, 2, 3, 4, 5, or 6.

2d6 means two six-sided dice that can output the sum of two dice throws (e.g., 2 through 12). If the first roll is 3 and the second roll is 2, the sum is 5.

Use the starter code

Please find the starter code here: https://repl.it/@bus101/Final-project-starter-code Copy the code into your own account. Make sure that you don’t change any of the provided code.

You will need “random” to generate random numbers (e.g., the die roll).

What you need to create

Function: get_roll(rollstring)

This function takes an input parameter as a string that looks like “1d3”, “3d5”, etc. The function should return an integer simulating those dice rolls. In the case of “3d5”, for example, the function will generate a random number between 1 and 5, three times, and return the total as an integer.

Function: get_damage(attack, defense)

This function gets the value of damage based on roll strings. If the defense roll is greater than the attack roll, damage is 0. Otherwise, return attack minus defense, as an integer.

Function: main_menu()

In this function, ask the user how many rolls they want to take. Next, ask the user to input the attack dice and the defense dice for roll 1, roll 2, etc., up to the number of rolls they entered.

Finally, display each roll round and the damage from that round.

This function does not need to return anything.

Sample output

Each group of output is from a separate run of the program. The program only needs to run once each time.

How many rolls do you want to take? 3

Input attack and defense roll 1: 1d3,1d3

Input attack and defense roll 2: 1d6,1d3

Input attack and defense roll 3: 1d6,1d10

Attack:1d3, Defense:1d3 : Damage: 0

Attack:1d6, Defense:1d3 : Damage: 2

Attack:1d6, Defense:1d10 : Damage: 0

How many rolls do you want to take? 2

Input attack and defense roll 1: 100d5,150d3

Input attack and defense roll 2: 99d6,100d7

Attack:100d5, Defense:150d3 : Damage: 0

Attack:99d6, Defense:100d7 : Damage: 0

How many rolls do you want to take? 5

Input attack and defense roll 1: 500d5,500d5

Input attack and defense roll 2: 600d6,600d6

Input attack and defense roll 3: 123d456,123d123

Input attack and defense roll 4: 1d10000000,1d100000000000

Input attack and defense roll 5: 1d1,1d1

Attack:500d5, Defense:500d5 : Damage: 0

Attack:600d6, Defense:600d6 : Damage: 0

Attack:123d456, Defense:123d123 : Damage: 20058

Attack:1d10000000, Defense:1d100000000000 : Damage: 0

Attack:1d1, Defense:1d1 : Damage: 0

How to submit your Python code

If you do not see a “Share” button in the top right, please turn off any ad blockers.

When you are done with your code, click “Share” in the top right. You will see an info box pop up like the screenshot below. At the bottom of the box, click “Copy repl link”. Please do not use the “Invite someone with a join link” feature.

Create a new text submission in iLearn. Paste your link into the text box (not the comments box) and submit.

Note: if you change the title of your repl after submitting, your link will no longer be valid. You will need to create a new link (see steps above) and submit again. I recommend making the title of your repl something simple like “[first name] [last name] Project” and leaving it like that.

Resources

You will need to learn additional Python concepts on your own. I will provide updated resources here that will help.

Here’s how to use these resources: https://www.loom.com/share/f46abf6088ca48b2967e39c454ec4022

Functions (Dr. Chuck):

https://www.youtube.com/watch?v=5Kzw-0-DQAk

https://www.youtube.com/watch?v=AJVNYRqn8kM

Lists (Dr. Chuck):

https://www.youtube.com/watch?v=ljExWqnWQvo

https://www.youtube.com/watch?v=bV1FQUBIApM

https://www.youtube.com/watch?v=GxADdpo6EP4

Using the split() function: https://www.w3schools.com/python/ref_string_split.asp

(Hint: if the roll string is “1d5”, what separator should you use to split the string into the number of dice and number of sides?)

randint() function: https://www.w3schools.com/python/ref_random_randint.asp

The following textbooks are for reference only. You don’t need to read them all the way through.

Python for Everybody (Dr. Chuck’s book): http://do1.dr-chuck.com/pythonlearn/EN_us/pythonlearn.pdf

Think Python: http://greenteapress.com/thinkpython2/thinkpython2.pdf

New material Dec 5

This is another good instructor

Functions: https://www.youtube.com/watch?v=NSbOtYzIQI0

Lists: https://www.youtube.com/watch?v=tw7ror9x32s

For loops: https://www.youtube.com/watch?v=OnDr4J2UXSA

While loops: https://www.youtube.com/watch?v=6TEGxJXLAWQ

Dictionaries: https://www.youtube.com/watch?v=ZEZdys-fHDw

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Order Solution Now

Our Service Charter


1. Professional & Expert Writers: Essay Noon only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Essay Noon are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Essay Noon are known for the timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Essay Noon, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

We Can Write It for You! Enjoy 20% OFF on This Order. Use Code SAVE20

Stuck with your Assignment?

Enjoy 20% OFF Today
Use code SAVE20