-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstargen.py
192 lines (176 loc) · 6.22 KB
/
stargen.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#Procedural star generator for PySmuggler
import utility
class Star:
def atmo_gen(self):
if self.size == 0:
atmosphere = 0
else:
atmosphere = utility.dice(2, 6) - 7 + self.size
if atmosphere > 15:
atmosphere = 15
if atmosphere < 0:
atmosphere = 0
return atmosphere
def hydro_gen(self):
hydrographics = utility.dice(2, 6) - 7 + self.size
if self.size <= 1:
hydrographics = 0
elif self.atmosphere in [0, 1, 10, 11, 12]:
hydrographics -= 4
elif self.atmosphere == 14:
hydrographics -= 2
if hydrographics < 0:
hydrographics = 0
if hydrographics > 10:
hydrographics = 10
return hydrographics
def pop_gen(self):
population = utility.dice(2, 6) - 2
if self.atmosphere >= 10:
population -= 2
elif self.atmosphere == 6:
population += 3
elif self.atmosphere in [5, 8]:
population += 1
if self.hydrographics == 0 and self.atmosphere < 3:
population -= 1
if population < 0:
population = 0
elif population > 10:
population = 10
return population
def gov_gen(self):
government = utility.dice(2, 6) - 7 + self.population
if self.population == 0:
government = 0
if government < 0:
government = 0
if government > 15:
government = 15
return government
def law_gen(self):
law = utility.dice(2, 6) - 7 + self.government
if self.government == 0:
law = 0
if law < 0:
law = 0
if law > 10:
law = 10
return law
def starport_gen(self):
starport_roll = utility.dice(2, 6) - 7 + self.population
starport = "X"
if starport_roll <= 2:
starport = "X"
elif starport_roll in [3, 4]:
starport = "E"
elif starport_roll in [5, 6]:
starport = "D"
elif starport_roll in [7, 8]:
starport = "C"
elif starport_roll in [9, 10]:
starport = "B"
elif starport_roll >= 11:
starport = "A"
if self.population == 0:
starport = "X"
return starport
def gas_gen(self):
if utility.dice(2, 6) >= 5:
return "*"
else:
return " "
def type_gen(self):
if self.hydrographics >= 1 and self.atmosphere in range (1, 9):
return "@"
elif self.hydrographics >= 1 and self.atmosphere >= 10:
return "&"
elif self.hydrographics >= 1 and self.atmosphere <= 1:
return "#"
elif self.hydrographics < 1:
return "0"
elif self.size == 0:
return "*"
else:
return " "
def name_gen(self):
return utility.random_line("./data/worlds.txt")
def scout_gen (self):
roll = utility.dice(2, 6)
if self.starport in ["X", "E"]:
pass
elif self.starport == "D":
if roll >= 7:
return "S"
else:
return ""
elif self.starport == "C":
if roll >= 8:
return "S"
else:
return ""
elif self.starport == "B":
if roll >= 9:
return "S"
else: return ""
elif self.starport == "C":
if roll >= 10:
return "S"
else:
return ""
else:
return ""
def naval_gen (self):
if self.starport in ["A", "B"]:
roll = utility.dice(2, 6)
if roll >= 8:
return "N"
else:
return ""
else:
return ""
def __init__(self, hex_column, hex_row):
if utility.dice(1, 6) >= 4:
self.size = utility.dice(2, 6) - 2
self.atmosphere = self.atmo_gen()
self.hydrographics = self.hydro_gen()
self.population = self.pop_gen()
self.government = self.gov_gen()
self.law = self.law_gen()
self.startype = self.type_gen()
self.gas_giant = self.gas_gen()
self.starport = self.starport_gen()
self.scout = self.scout_gen()
self.naval = self.naval_gen()
self.names = self.name_gen()
self.column = hex_column
self.row = hex_row
else:
self.size = 0
self.atmosphere = 0
self.hydrographics = 0
self.population = 0
self.government = 0
self.law = 0
self.startype = " "
self.gas_giant = " "
self.starport = " "
self.naval = " "
self.scout = self.scout_gen()
self.names = " "
self.column = hex_column
self.row = hex_row
if self.column == 10 and self.row != 10:
self.hex = f"100{self.row}"
elif self.column != 10 and self.row == 10:
self.hex = f"0{self.column}10"
elif self.column == 10 and self.row == 10:
self.hex = "1010"
else:
self.hex = f"0{self.column}0{self.row}"
self.neighbors = [(self.column, self.row - 1), (self.column + 1, self.row - 1), (self.column + 1, self.row),
(self.column, self.row + 1), (self.column - 1, self.row), (self.column - 1, self.row - 1)]
self.second_neighbors = [(self.column, self.row-2), (self.column+1, self.row-2), (self.column+2, self.row-1), (self.column+2, self.row), (self.column+2, self.row+1), (self.column+1, self.row+1), (self.column, self.row+2), (self.column-1, self.row+1), (self.column-2, self.row+1), (self.column-2, self.row), (self.column-2, self.row-1), (self.column-1, self.row-2)]
def name_converter(self):
new_name = f"{self.names: <{7}}".upper()
self.mapname = (new_name[:7]) if len(new_name) > 7 else new_name