-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStatsAssignment
More file actions
64 lines (49 loc) · 1.58 KB
/
StatsAssignment
File metadata and controls
64 lines (49 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import random
# Rolls the stats
def roll():
stat = []
stat.append(random.randint(1,18))
stat.append(random.randint(1,18))
stat.append(random.randint(1,18))
stat.append(random.randint(1,18))
stat.append(random.randint(1,18))
stat.append(random.randint(1,18))
return stat
# Finds the main stats from the inputed list
def mainStats(statList):
# Calculates the highest stat
statDefList = ["STR", "DEX", "CON", "INT", "WIS", "CHA"]
highestStat = 0
secondStat = 0
# Skips STR since it will always be the first stat compared to
for i in range(1,6):
if statList[i] > statList[highestStat]:
highestStat = i
# Calculates the 2nd highest stat
# Removes the highest stat from the new list
secondaryStatList = list(statList)
secondaryStatList.pop(highestStat)
statDefList2 = list(statDefList)
statDefList2.remove(statDefList[highestStat])
for i in range(1,5):
if secondaryStatList[i] > secondaryStatList[secondStat]:
secondStat = i
return [statDefList[highestStat], statDefList2[secondStat]]
# Contains the main chunk of code
def mainSys():
# Initialises point buy equivalence variable
pbe = 0
# Rolls stats until the point buy equivalence is equal to the standard 27
while pbe != 27:
stats = roll()
pbe = 0
for i in stats:
if i < 14:
singlePbe = i - 8
else:
singlePbe = 2*(i - 13)+5
pbe = pbe + singlePbe
return stats
# Runs the system
if __name__ == "__main__":
mainSys()