This game is similar to a Dungeons and Dragons game. How could I improve the efficiency of the program? For example, where can I add functions, records etc? This is for a school Controlled Assessment so any help would really be appreciated.
import random
play1 = True
str1 = int(input("Enter a value for strength"))
print("you have chosen",str1,)
skl1=int(input("Please enter a value of skill, and then press enter"))
print("you have chosen: ",skl1,)
str2 =int(input("Enter a value for strength"))
print("you have chosen: ",str2,)
skl2=int(input("Please enter a value of skill, and then press enter"))
print("you have chosen: ",skl2,)
strdif=str1-str2
if strdif<0:
strdif=str2-str1
strdif=strdif//5
skldif=skl1-skl2
if skldif<0:
skldif=skl2-skl1
skldif=skldif//5
while play1 == True:
num1=random.randint(1,6)
num2=random.randint(1,6)
if num1>num2:
str1+=strdif
skl1+=skldif
str2-=strdif
skl2-=skldif
if num2>num1:
str2+=strdif
skl2+=skldif
str1-=strdif
skl1-=skldif
if skl1<0:
skl1=0
if skl2<0:
skl2=0
if str1<=0:
play1 = False
print("Character 2 Won the game")
elif str2<=0:
play1 = False
print("Character 1 Won the game")
if str1 > str2:
print("Character 1 won the encounter, now has",str1,"strength and",skl1,"skill")
print("Character 2 lost the encounter, now has",str2,"strength and",skl2,"skill")
else:
print("Character 2 won the encounter, now has",str2,"strength and",skl2,"skill")
print("Character 1 lost the encounter, now has",str1,"strength and",skl1,"skill")