``````import random #allows a random value to be produced

a = input("Enter name for character 1") #variable verified, reports information to user
b = input("Enter name for character 2") #variable verified, reports information to user

c = int(input("Enter value for first strength for character 1")) #variable verified, reports information to user
d = int(input("Enter value for first strength for character 2")) #variable verified, reports information to user

cc = int(input("Enter value for first skill for character 1")) #variable verified, reports information to user
dd = int(input("Enter value for first skill for character 2")) #variable verified, reports information to user

print("Strength for", a, ":", c, ", Skill :", cc)
print("Strength for", b, ":", d, ", Skill :", dd)

if c > d : #conditional expression provides different arguments
difference = c-d

else : #conditional expression provides different arguments
difference = d-c

strengthmodifier = round(difference/5, 0)

print("The difference in strength is:", difference)

if cc > dd : #conditional expression provides different arguments
difference2 = cc-dd

else : #conditional expression provides different arguments
difference2 = dd-cc

skillmodifier = round(difference2/5, 0)

print("The difference in skill is:", difference2)

dice =  random.randrange(1,7)
dice2 = random.randrange(1,7)

print (a, "rolls:", dice)
print (b, "rolls:", dice2)

if dice > dice2 :#conditional expression provides different arguments
print(a, "receives both strength and skill modifier.")
print("New strength:", c, "+", strengthmodifier)
print("New skill:", cc, "+", skillmodifier)

elif dice < dice2: #conditional expression provides different arguments
print(b, "receives both strength and skill modifier.")
print("New strength:", d, "+", strengthmodifier)
print("New skill:", dd, "+", skillmodifier)

else : #conditional expression provides different arguments
print("Dice throw was even. Neither player receive any modifiers.")
``````

okay, I am stuck how to do this?
Each player throws a 6 sided dice.
• If the scores on both dice are the same, no changes are made
• If the scores are not the same, the player with the highest score adds the ‘strength
modifier’ to the strength value and the ‘skill modifier’ to the skill value for their
character
• The player with the lower score on the dice subtracts these modifiers from the
strength and skill values for their character
• If a skill value becomes negative, then it is stored as zero
• If a strength value becomes zero or negative, then the character dies.
btw, my code is fully functioning, but I don't know how to do the above. any clues?

code written in pyscriper

2
Contributors
2
Replies
27
Views
4 Years
Discussion Span
Last Post by Schol-R-LEA

not expecting anyone to write code for me, just need a starting point. e.g. how to do: 'if a skill value becomes negative, then it is stored as zero'.

Probably the simplest way is to use the standard function `max()`:

``````skill = max(0, skill - change)
``````

I notcied that you aren't using any functions for this so far. I know that it is stilla relatively short game, but I can promise you that dividing the program into functions (and classes) is going to be neccessary as things progress, and it is best to start planning how to organize the program sooner rather than later.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.