Question
write a python combat game Description: The program will pit two fighters against each other. The fighters will fight round after round until one is
write a python combat game
Description:
The program will pit two fighters against each other. The fighters will fight round after round until one is defeated.
Each fighter has 4 attributes (called stats for the rest of this document):
name
combat_rating (called CR for the rest of this document)
armors
attack_dice
These stats are used to determine the outcome of a series of rounds, according to the following rules. The combat is over when one fighter or the other's CR drops to zero or below.
Explanation of stats:
name A string containing the name of the character
combat_rating The health of the fighter. when CR drops to 0 or below, the fighter is defeated.
CR is also used to determine an attack bonus equal to 1/2 the CR.
attack_dice How many dice the fighter gets to roll in an attack.
armor How many points of damage is absorbed / ignored per round
Example fighter:
name: Conan
CR: 10 (the fighter's health. Also used to generate an attack bonus)
armor: 2 (how many points of damage can be absorbed per round)
attack_dice: 5 (how many dice the fighter rolls per attack)
Program flow:
The program should
o Ask the user for the stats of two fighters
o Loop, doing combat rounds, until one fighter or the other is defeated
o Announce the name of the winning fighter
Combat round:
1. Determine attacks
2. Compare attacks to determine the loser
3. Calculate damage
4. Calculate real damage for the fighter that loses
5. Apply the real damage to the fighter's CR.
Details:
1. Each fighter generates an attack value as described below:
The fighter's combat roll is the sum of their dice (the number of dice equals their "dice" stat)
The fighter's CR bonus is 1/2 their CR.
The attack = combat roll + CR bonus
2. If their attacks are exactly equal, nothing happens and the round is over. Otherwise
3. Damage is calculated as the difference between the attacks.
4. "Real damage" = damage minus the loser's armor (but cannot be less than 0)
5. If the real damage is greater than 0, the loser's CR is lowered by that amount
Stated again: these are the same rules, worded a bit differently to help understanding
Steps 1
An attack for a round consists of the fighter's attack dice rolled and added together, plus 1/2 of the fighter's combat rating. Both fighters attacks are generated. Let's say we call them attack1 and attack2.
Step 2:
If attack1 equals attack2, that's it, and the round is over.
Step 3
To determine damage, you take the diffence between the attacks. So damage = the absolute value of attack1 minus attack2.
Steps 4 and 5
The real damage = the damage minus the losing fighter's armor. If real damage > 0, then the fighter who made the lower attack has that damage subtraced from their CR.
Combat continues, round by round, until someone's CR reaches 0 or below. When done the winner will be announced.
Combat round example:
Assuming our example fighter, Conan:
name: Conan
CR: 10
armor: 2
attack_dice: 5
He has an opponent with six attack dice, and the same CR and armor.
Steps 1 Determine attacks
Conan has 5 attack dice. Five random numbers are added together.
Say the random numbers are 2+5+3+6+4 for a total of 22. So his base attack roll = 22
His bonus is 1/2 CR. 1/2 * 10 is 5. So his bonus is 5.
Conan's total attack: 22 + 5 = 27
So Conan's total attack is 27
His opponent's total attack is also calculated. Six random numbers 5+4+5+3+6+4 + CR bonus of 5 = 32.
Step 2 Compare attacks
The attacks are not equal, so the round is not over yet. Conan loses this round.
Step 3: Calculate raw damage
Damage = 32 - 27 = 5 (Use absolute value to make sure damage is a positive value.)
Step 4: Calculate real damage
Real damage = damage minus armor. Damage was 5. Conan's armor is 2.
5 - 2 = 3
Step 6:
The real damage is > 0, so Conan will take damage. Conan takes 3 points of real damage, and his CR lowers from 10 to 7.
Loop, repeating those steps until one (or both) fighter's CR is 0 or less.
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