-
Notifications
You must be signed in to change notification settings - Fork 0
/
GalaxyGen.py
71 lines (61 loc) · 1.83 KB
/
GalaxyGen.py
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
65
66
67
68
69
70
71
import util
def clusgen(name):
'''Generates a dictionary containing 3 System instances'''
import random
cluster = {}
cluster[0]=name
r = random.randint(1,4)
for i in range(1,r+1):
cluster[i]=System(name,i)
cluster = lanecheck(cluster)
return cluster
def eventgen(glist):
'''Randomly generates what happens when a player enters a system'''
import random
for dic in glist:
for key in dic:
if key != 0:
event = random.choice(('Nothing','Combat','Event'))
dic[key].event = event
if event != 'Nothing':
util.ecount +=1
return glist
def galaxygen():
'''Generates a list of clusgen dictionaries'''
if util.debugflag:
print('Generating game world...')
print(util.ecount)
galaxy = []
galaxykeys = []
names = ('Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', 'Iota', 'Kappa')
for name in names:
galaxy.append(clusgen(name))
galaxykeys.append(clusgen(name).keys())
util.ecount = 0
while util.ecount < 10:
galaxy = eventgen(galaxy)
return galaxy
def lanecheck(cluster):
'''Assures at least one System instance has a lane'''
import random
lanecount = 0
for system in cluster:
try:
if cluster[system].lane == 1:
lanecount += 1
if lanecount == 0:
cluster[1].lane = 1
except AttributeError:
continue
return cluster
class System():
import random
event = ''
blurb = 'Descriptive text'
def __init__(self, name, num):
self.name = name + '-'+str(num)
lane = random.randint(0,1)
#galaxy = galaxygen()
#print (galaxy[0]['Alpha-1'].event)
#print (galaxy[0]['Alpha-1'].blurb)
#print (galaxy[0]['Alpha-1'].lane)