def getAdjacentSystems(currentsystem, sysaway, jumps=(), preferredfaction=''): """returns a tuple in the format ("[lastsystem]",(system1,system2,system3,...))""" if preferredfaction == '': preferredfaction = VS.GetGalaxyProperty(currentsystem, "faction") max = VS.GetNumAdjacentSystems(currentsystem) if ((sysaway <= 0) or (max <= 0)): # _io.message (1,"game","all","Your final destination is %s" % (currentsystem)) return (currentsystem, jumps) else: syslist = [] numadj = VS.GetNumAdjacentSystems(currentsystem) for i in range(numadj): cursys = VS.GetAdjacentSystem(currentsystem, i) if preferredfaction != None: if VS.GetGalaxyProperty(cursys, "faction") != preferredfaction: continue if ((cursys in jumps) or (cursys == VS.getSystemFile())): continue syslist.append(cursys) if not len(syslist): return getAdjacentSystems(currentsystem, 0, jumps) nextsystem = syslist[vsrandom.randrange(0, len(syslist))] # _io.message (1,"game","all","Jump from %s to %s." % (currentsystem,nextsystem)) return getAdjacentSystems(nextsystem, sysaway - 1, jumps + (nextsystem, ))
def isHabitable(system): planetlist = VS.GetGalaxyProperty(system, "planets") if (len(planetlist) == 0): return False planets = planetlist.split(' ') for planet in planets: if planet == "i" or planet == "a" or planet == "am" or planet == "u" or planet == "com" or planet == "bd" or planet == "s" or planet == "o" or planet == "at" or planet == "bs" or planet == "bdm" or planet == "bsm" or planet == "f" or planet == "fm" or planet == "t": return True debug.debug(str(planets) + " Not in Habitable List") return False
def getImportanceOfSystem(sys): if (VS.GetGalaxyProperty(sys,"faction")==VS.GetGalaxyFaction(sys)): return .5 else: return .1
def TakeoverSystem(fac, sys): systemcount[VS.GetGalaxyFaction(sys)] -= 1 VS.SetGalaxyFaction(sys, fac) systemcount[fac] += 1 AddBasesToSystem(fac, sys) genUniverse = -1 if cp >= 0: debug.debug('Purging...') for i in fg_util.AllFactions(): fg_util.PurgeZeroShips(i) systemcount[i] = 0 debug.debug('StartSystemCount') sys = VS.getSystemFile() if (VS.GetGalaxyProperty("Sol/Sol", "jumps") != "" and VS.GetGalaxyProperty("Sol/Sol", "faction") != ""): debug.debug("He's got SOL") sys = "Sol/Sol" ForEachSys(sys, CountSystems) debug.debug(systemcount) debug.debug('EndSystemCount') genUniverse = 0 curfaclist = fg_util.AllFactions() reflist = fg_util.ReadStringList(cp, "FactionRefList") if (reflist != curfaclist): debug.debug('reflist is ' + str(reflist)) debug.debug('curfaclist is ' + str(curfaclist)) fg_util.WriteStringList(cp, "FactionRefList", curfaclist) debug.debug('generating ships... ... ...')
def AllSystems(): sys = VS.getSystemFile() if (VS.GetGalaxyProperty("Sol/Sol", "jumps") != "" and VS.GetGalaxyProperty("Sol/Sol", "faction") != ""): sys = "Sol/Sol" return ReachableSystems(sys)
def GetNumSignificantsForSystem(cursys): numjmp = VS.GetNumAdjacentSystems(cursys) return _tmpint(VS.GetGalaxyProperty(cursys, "num_planets"), 3) + _tmpint( VS.GetGalaxyProperty(cursys, "num_moons"), 4) + _tmpint( VS.GetGalaxyProperty(cursys, "num_gas_giants"), 2) + _tmpint( VS.GetGalaxyProperty(cursys, "num_starbases"), 1) + numjmp