8 from universe
import getAdjacentSystemList,AllSystems
21 return type[
"default"]
31 capitals=faction_ships.capitals[factionnr]
32 fighters=faction_ships.fighters[factionnr]
35 numfighters=faction_ships.fightersPerFG[
"default"]
36 numfighters=faction_ships.fightersPerFG[faction]
42 numcapitals=faction_ships.fightersPerFG[
"default"]
43 numcapitals=faction_ships.PerFG[faction]
46 fighters_per=len(fighters)
49 numtogen=
floatToRand(numfighters/float(len(fighters)))
56 numtogen=
floatToRand(numcapitals/float(len(capitals)))
63 lst.append([hv,ht[hv]])
71 if cpr>0
and (friendly==2
or (friendly==1
and vsrandom.random()<cpr/fpr)):
77 global fgnames,origfgnames,fgoffset
81 origfgnames.append(list(fgnames[-1]))
84 doNotAddBasesTo={
"enigma_sector/heavens_gate":1,
"sol_sector/celeste":1,
"enigma_sector/enigma":1,
"enigma_sector/niven":1,
"Gemini":1,
"Crucible/Cephid_17":1}
86 if (sys
in doNotAddBasesTo):
90 if (sys[0:slash]
in doNotAddBasesTo):
92 if faction
in faction_ships.factions:
93 fsfac= list(faction_ships.factions).
index(faction)
96 numjumppoints=VS.GetNumAdjacentSystems(sys);
101 if (numjumppoints<7):
103 elif numjumppoints==7:
111 for i
in xrange(numbases):
112 whichbase = faction_ships.bases[fsfac][
vsrandom.randrange(0,len(faction_ships.bases[fsfac]))]
113 if whichbase
in shiplist:
114 nums[shiplist.index(whichbase)]+=1
116 shiplist.append(whichbase)
119 for i
in xrange(len(shiplist)):
120 tn+=[ (shiplist[i],nums[i])]
127 global numericalfaction,fgnames,origfgnames,fgoffset
128 if(factionnr>=len(fgnames)):
129 debug.error(
"Faction "+faction+
" unable to create fgname")
132 return "Alpha_"+
str(numericalfaction)
133 if (
not len(fgnames[factionnr])):
135 fg_util.origoffset=fgoffset[factionnr]
137 fgoffset[factionnr]+=1
139 fgname=fgnames[factionnr][k]
140 del fgnames[factionnr][k]
144 _last_progress_percent = -1
146 global _generatedsys, _last_progress_percent
149 sysfaction=VS.GetGalaxyFaction(cursys)
155 if progress_percent - _last_progress_percent > 0.01:
158 _last_progress_percent = progress_percent
161 global fgnames, fglists
165 for i
in xrange(len(faction_ships.factions)):
166 thisfac=faction_ships.factions[i]
168 rel=VS.GetRelation(sysfaction,thisfac)
169 iscit=VS.isCitizen(thisfac)
170 if iscit
and thisfac.find(sysfaction)!=-1:
173 if thisfac==sysfaction:
176 for neighbor
in adjsystems:
177 if (VS.GetRelation(thisfac,VS.GetGalaxyFaction(neighbor))>-.05):
181 fg_util.AddShipsToFG (fgname,thisfac,typenumbertuple,cursys)
182 fgname=
"Insystem_"+cursys;
186 if VS.GetRelation(thisfac,sysfaction)>-.05:
189 fg_util.AddShipsToFG (fgname,thisfac,typenumbertuple,cursys)
191 if cursys
in faction_ships.fortress_systems:
192 friendlychance=faction_ships.fortress_systems[cursys]
194 for i
in xrange (numflightgroups):
197 if not sysfaction
or sysfaction==
'unknown' or vsrandom.random()>friendlychance:
201 if (faction==sysfaction):
203 if (sysfaction
in faction_ships.production_centers):
204 if (cursys
in faction_ships.production_centers[sysfaction]):
212 fg_util.AddShipsToFG (fgname,faction,typenumbertuple,cursys)
229 return systemcount[fac]
231 fac =VS.GetGalaxyFaction(sys)
232 if fac
in systemcount:
236 systemcount[
None] += 1
238 systemcount[VS.GetGalaxyFaction(sys)]-=1
239 VS.SetGalaxyFaction(sys,fac)
247 global genUniverse, hasUniverse
263 if (reflist !=curfaclist):
270 debug.warn(
'save using legacy FG format... resetting universe to reformat')
283 for i
in xrange(len(fgnames)):
284 fg_util.origfgoffset=fgoffset[i]
300 sys = VS.getSystemFile()
301 if not VS.GetNumAdjacentSystems(sys):