Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Python
import random
import time
skillnumber = []
strengthnumber = []
character1 = raw_input("What would you like to call your character?")
dicefour = [1,2,3,4]
dicesix = [1,2,3,4,5,6]
dicetwelve = [1,2,3,4,5,6,7,8,9,10,11,12]
skill = 10
strength = 10
dicefourscore = random.choice(dicefour)
dicetwelvescore = random.choice(dicetwelve)
attribute = int(input("Please choose an attribute, 1:Strength, 2:Skill"))
if attribute == 1:
        totalscore = dicetwelvescore // dicefourscore
        strength1 = totalscore + strength
        print ("%s's strength level is now %s") % (character1, strength1)
        strengthnumber.append(strength1)
        print ("Let's determine the character's skill level")
        time.sleep(1)
        dicefourscore = random.choice(dicefour)
        dicetwelvescore = random.choice(dicetwelve)
        totalscore = dicetwelvescore // dicefourscore
        skill1 = skill + totalscore
        print ("%s's skill level is now %s") % (character1, skill1)
        skillnumber.append(skill1)
elif attribute == 2:
        totalscore = dicetwelvescore % dicefourscore
        skill1 = skill + totalscore
        print ("%s's skill level is now %s") % (character1, skill1)
        skillnumber.append(skill)
        print ("Let's determine the character's strength level")
        time.sleep(2)
        dicefourscore = random.choice(dicefour)
        dicetwelvescore = random.choice(dicetwelve)
        totalscore = dicetwelvescore // dicefourscore
        strength1 = strength + totalscore
        print ("%s's strength level is now %s") % (character1, strength1)
        strengthnumber.append(strength)
elif attribute != 1 and attribute != 2:
        print ("Could you either choose one of the attributes skill or strength")
character2 = raw_input("What would you like to call your character?")
dicefour = [1,2,3,4]
dicetwelve = [1,2,3,4,5,6,7,8,9,10,11,12]
skill = 10
strength = 10
dicefourscore = random.choice(dicefour)
dicetwelvescore = random.choice(dicetwelve)
attribute = int(input("Please choose an attribute, 1:Strength, 2:Skill"))
if attribute == 1:
        totalscore = dicetwelvescore // dicefourscore
        strength2 = totalscore + strength
        print ("%s's strength level is now %s") % (character2, strength2)
        strengthnumber.append(strength2)
        print ("Let's determine the character's skill level")
        time.sleep(1)
        dicefourscore = random.choice(dicefour)
        dicetwelvescore = random.choice(dicetwelve)
        totalscore = dicetwelvescore // dicefourscore
        skill2 = skill + totalscore
        print ("%s's skill level is now %s") % (character2, skill2)
        skillnumber.append(skill2)
elif attribute == 2:
        totalscore = dicetwelvescore % dicefourscore
        skill2 = skill + totalscore
        print ("%s's skill level is now %s") % (character2, skill2)
        skillnumber.append(skill2)
        print ("Let's determine the character's strength level")
        time.sleep(2)
        dicefourscore = random.choice(dicefour)
        dicetwelvescore = random.choice(dicetwelve)
        totalscore = dicetwelvescore // dicefourscore
        strength2 = strength + totalscore
        print ("%s's strength level is now %s") % (character2, strength2)
        strengthnumber.append(strength2)
elif attribute != 1 and 2:
        print ("Could you either choose one of the attributes skill or strength")
if strength1 < strength2:
      difference = strength2-strength1
      strengthmodifier = difference // 5
      if strengthmodifier == 0:
        strengthmodifier = strengthmodifier + 1
      print (" the strength modifier is %s") % (strengthmodifier)

if strength1 > strength2:
     difference = strength1-strength2
     strengthmodifier = difference // 5
     if strengthmodifier == 0:
        strengthmodifier = strengthmodifier + 1
     print (" the strength modifier is %s") % (strengthmodifier)
if strength1 == strength2:
     print (" The strength modifier is 1")   # problems when modifier is 0
if skill1 == skill2:
    print (" the skill modifier is 1")
if skill1 < skill2:
      difference = skill2-skill1
      skillmodifier = difference // 5
      if skillmodifier == 0:
        skillmodifier = skillmodifier+1
      print (" the skill modifier is %s") % (skillmodifier)
if skill1 > skill2:
     difference = skill1 - skill2
     skillmodifier = difference // 5
     if skillmodifier == 0:
        skillmodifier = skillmodifier + 1
     print (" the skill modifier is %s") % (skillmodifier)

character1dice = random.choice(dicesix)
print character1dice
character2dice = random.choice(dicesix)
print character2dice

while 1 == 1:

    if skill1 < 0:
       skill1 = 0

    if skill2 < 0:
       skill2 = 0

    if strength1 <= 0:
        print ("%s is dead") %(character1)
        break

    if strength2 <= 0:
        print ("%s is dead") %(character2)
        break
    while skill1>=0 and skill2>=0 and strength1>0 and strength2>0:
        if character1dice > character2dice:
            strength1 = strength1 + strengthmodifier
            skill1 = skill1 + skillmodifier
            strength2 = strength2 - strengthmodifier
            skill2 = skill2 - skillmodifier
            print ("%s's strength level is %s") %(character1,strength1)
            print ("%s's skill level is %s") %(character1,skill1)
            print ("%s's strength level is %s") %(character2,strength2)
            print ("%s's skill level is %s") %(character2,skill2)

        if character2dice > character1dice:
            strength2 = strength2 + strengthmodifier
            skill2 = skill2 + skillmodifier
            strength1 = strength1 - strengthmodifier
            skill1 = skill1 - skillmodifier
            print ("%s's strength level is %s") %(character1,strength1)
            print ("%s's skill level is %s") %(character1,skill1)
            print ("%s's strength level is %s") %(character2,strength2)
            print ("%s's skill level is %s") %(character2,skill2)

        if character1dice == character2dice:
            print ("%s's strength level is %s") %(character1,strength1)
            print ("%s's skill level is %s") %(character1,skill1)
            print ("%s's strength level is %s") %(character2,strength2)
            print ("%s's skill level is %s") %(character2,skill2)
Posted
Updated 6-Dec-14 10:16am
v4
Comments
Richard MacCutchan 6-Dec-14 11:24am    
Please edit your question and:
1. Put <pre> tags around your code so it is readable.
2. Remove all the code that is not connected to your problem.
3. Explain exactly what is going wrong and where in your code it occurs.

Please do not expect other people to guess what is happening.
Gomez786 6-Dec-14 11:36am    
I do apologise.
ZurdoDev 6-Dec-14 15:33pm    
You need to debug this and not expect someone to try and read through all of this and figure it out for you.
Andreas Gieriet 6-Dec-14 23:17pm    
Check all subtractions if they can become negative. Also check all additions of you add negative values. Lookout for differences: use abs(a-b).
Cheers
Andi
Sergey Alexandrovich Kryukov 6-Dec-14 23:31pm    
There is nothing wrong with negative skills; I saw many such guys. Very usual thing: every work done by them makes thing worse then if it wasn't done. :-)
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900