103 lines
2.3 KiB
Python
Executable File
103 lines
2.3 KiB
Python
Executable File
#!/usr/bin/python
|
|
import random
|
|
import string
|
|
import getopt
|
|
import sys
|
|
|
|
def total(s):
|
|
toReturn =0
|
|
for i in s:
|
|
toReturn += int(string.strip(string.split(i)[0]))
|
|
return toReturn
|
|
|
|
def cloneArray(a):
|
|
b = []
|
|
for x in a:
|
|
b.append(x)
|
|
return b
|
|
|
|
def average(s):
|
|
toReturn =0
|
|
for i in s:
|
|
toReturn += i
|
|
return toReturn/len(s)
|
|
|
|
def allAboveTen(s):
|
|
#print "allAboveTen got ", str(s)
|
|
for i in s:
|
|
score = i
|
|
if ( score < 10):
|
|
#print "score was below ten : ", score
|
|
return False
|
|
return True
|
|
|
|
def suggest(l):
|
|
x = cloneArray(l)
|
|
s = []
|
|
for i in x:
|
|
s.append(int(string.strip(string.split(i)[0])))
|
|
|
|
if ( average(s[0:3]) > average(s[3:6]) and
|
|
average(s[0:3]) > average([s[1], s[3], s[4]]) ):
|
|
|
|
if ( s[5] > 15 and (average([s[2], s[1], s[3]]) < 13)):
|
|
return "Paladin"
|
|
elif ( average([s[2], s[1], s[3]]) > 13 and
|
|
s[4] > 12 ):
|
|
return "Ranger"
|
|
return "Fighter"
|
|
|
|
elif ( average(s[0:3]) > average(s[3:6]) and
|
|
average(s[0:3]) < average([s[1], s[3], s[4]]) ):
|
|
return "Rogue"
|
|
|
|
elif ( average(s[0:3]) < average(s[3:6]) ):
|
|
|
|
if ( s[3] > s[5] and s[3] > s[4] ):
|
|
return "Wizard"
|
|
elif ( s[3] > s[5] and s[3] < s[4]
|
|
and average([s[4], s[5], s[0]]) > 12):
|
|
return "Cleric"
|
|
elif ( s[3] < s[5]):
|
|
return "Sorceror"
|
|
return "Spellcaster"
|
|
|
|
elif ( average(s) < 11):
|
|
return "Slaad bait"
|
|
else:
|
|
return "No suggestion"
|
|
|
|
def signIntStr(i):
|
|
if ( i <= 9 ) :
|
|
return " " + str((i-10)/2)
|
|
else:
|
|
return " +" + str((i-10)/2)
|
|
|
|
if ( __name__ == "__main__" ):
|
|
sets = []
|
|
abilities = ["strength", "dexterity", "constitution", "intelligence", "wisdom", "charisma"]
|
|
currTotal = 0
|
|
currNum = 0
|
|
|
|
for setnum in range(0,3):
|
|
sets.append([])
|
|
currTotal = 0
|
|
for i in range(0,6):
|
|
if ( sys.argv.count("-a") > 0 or sys.argv.count("--aboveAverage") > 0):
|
|
while ( currNum < 9 ):
|
|
currNum = random.choice(range(3,18))
|
|
else:
|
|
currNum = random.choice(range(3,18))
|
|
sets[setnum].append(string.center(str(currNum) + signIntStr(currNum), 15))
|
|
currTotal += currNum
|
|
currNum = 0
|
|
sets[setnum].append(string.center(str(currTotal), 15))
|
|
|
|
print " "*20 + string.center(suggest(sets[0]), 15) + string.center(suggest(sets[1]), 15) + string.center(suggest(sets[2]), 15)
|
|
|
|
for i in range(0,6):
|
|
print string.center(abilities[i], 20) + sets[0][i] + sets[1][i] + sets[2][i]
|
|
|
|
print "-"*65
|
|
print string.center("totals", 20) + sets[0][6] + sets[1][6] + sets[2][6]
|