Beispiel #1
0
def DeleteLegacyFGLeftovers():
    # Legacy cleanup
    allsys = AllSystems()
    numsys = len(allsys)
    count = 0
    oldpct = 0
    for sys in allsys:
        count += 1
        pct = count*100/len(allsys)
        if pct != oldpct:
            ShowProgress.setProgressBar("loading",pct/100.)
            ShowProgress.setProgressMessage("loading","Resetting old universe (%d%%)" % (pct))
            oldpct = pct
        DeleteLegacyFGs(sys)
def AddSysDict (cursys):
    global _generatedsys, _last_progress_percent
    #pick random fighter from insysenemies with .3 probability OR pick one from the friendlies list.
#       debug.debug('Addsysdict')
    sysfaction=VS.GetGalaxyFaction(cursys)

    numflightgroups = 1+vsrandom.randrange(fg_util.MinNumFlightgroupsInSystem(cursys)-1,fg_util.MaxNumFlightgroupsInSystem(cursys))
    
    #debug.debug("Initializing system %s with %d flightgroups... " % (cursys,numflightgroups))
    progress_percent = (float(_generatedsys) / getSystemCount())
    if progress_percent - _last_progress_percent > 0.01:
        ShowProgress.setProgressBar("loading",progress_percent)
        ShowProgress.setProgressMessage("loading","Generating dynamic universe (%.2f%%)" % (100*progress_percent))
        _last_progress_percent = progress_percent
    _generatedsys += 1

    global fgnames, fglists
    i=0
    AddBasesToSystem(sysfaction, cursys)
    adjsystems=getAdjacentSystemList(cursys)
    for i in xrange(len(faction_ships.factions)):
       thisfac=faction_ships.factions[i]
       thisfactionnr=faction_ships.factionToInt(thisfac)
       rel=VS.GetRelation(sysfaction,thisfac)
       iscit=VS.isCitizen(thisfac)
       if iscit and thisfac.find(sysfaction)!=-1:
          #debug.debug("generating spc civilian for "+cursys+" faction "+thisfac)
          #do somethign special for this military faction
          if thisfac==sysfaction:
              pass
          elif iscit:
              for neighbor in adjsystems:
                 if (VS.GetRelation(thisfac,VS.GetGalaxyFaction(neighbor))>-.05):
                   #fgname=cursys+"->"+neighbor
                   fgname="(CivReg) "+GetNewFGName(thisfac)
                   typenumbertuple=GenerateCivilianFgShips(thisfac,thisfactionnr,True)
                   fg_util.AddShipsToFG (fgname,thisfac,typenumbertuple,cursys)
              fgname="Insystem_"+cursys;
              typenumbertuple=GenerateCivilianFgShips(thisfac,thisfactionnr,False)
       if iscit:
          #debug.debug("generating gen civilian for "+cursys+" faction "+thisfac)
          if VS.GetRelation(thisfac,sysfaction)>-.05:#brave citizens of the new order... 
             fgname=GetNewFGName(thisfac)
             typenumbertuple=GenerateCivilianFgShips(thisfac,thisfactionnr,True)
             fg_util.AddShipsToFG (fgname,thisfac,typenumbertuple,cursys)
    friendlychance=.7
    if cursys in faction_ships.fortress_systems:
        friendlychance=faction_ships.fortress_systems[cursys]
        #debug.debug('enemy chance for '+cursys +'= '+str(friendlychance))
    for i in xrange (numflightgroups): #number of fgs in a system.
        faction=sysfaction
        friendly=0
        if not sysfaction or sysfaction=='unknown' or vsrandom.random()>friendlychance:
            faction=faction_ships.get_rabble_of_no_citizen(sysfaction)#why even have citizens on the list then
        else:            
            faction=faction_ships.get_friend_of_no_citizen(sysfaction)#likewise--- maybe this should be a faction_ships fix
            if (faction==sysfaction):
                friendly=1
            if (sysfaction in faction_ships.production_centers):
                if (cursys in faction_ships.production_centers[sysfaction]):
                    friendly=2
            #if (friendly):
            #    debug.debug(faction+" "+sysfaction+" "+cursys)
        factionnr=faction_ships.factionToInt(faction)
        global maxshipsinfg
        typenumbertuple=GenerateFgShips(vsrandom.randrange(maxshipsinfg)+1,factionnr,friendly)
        fgname=GetNewFGName(faction)
        fg_util.AddShipsToFG (fgname,faction,typenumbertuple,cursys)
    return i
def AddSysDict(cursys):
    global _generatedsys, _last_progress_percent
    #pick random fighter from insysenemies with .3 probability OR pick one from the friendlies list.
    #       debug.debug('Addsysdict')
    sysfaction = VS.GetGalaxyFaction(cursys)

    numflightgroups = 1 + vsrandom.randrange(
        fg_util.MinNumFlightgroupsInSystem(cursys) - 1,
        fg_util.MaxNumFlightgroupsInSystem(cursys))

    #debug.debug("Initializing system %s with %d flightgroups... " % (cursys,numflightgroups))
    progress_percent = (_generatedsys / getSystemCount())
    if progress_percent - _last_progress_percent > 0.01:
        ShowProgress.setProgressBar("loading", progress_percent)
        ShowProgress.setProgressMessage(
            "loading",
            "Generating dynamic universe (%.2f%%)" % (100 * progress_percent))
        _last_progress_percent = progress_percent
    _generatedsys += 1

    global fgnames, fglists
    i = 0
    AddBasesToSystem(sysfaction, cursys)
    adjsystems = getAdjacentSystemList(cursys)
    for i in range(len(faction_ships.factions)):
        thisfac = faction_ships.factions[i]
        thisfactionnr = faction_ships.factionToInt(thisfac)
        rel = VS.GetRelation(sysfaction, thisfac)
        iscit = VS.isCitizen(thisfac)
        if iscit and thisfac.find(sysfaction) != -1:
            #debug.debug("generating spc civilian for "+cursys+" faction "+thisfac)
            #do somethign special for this military faction
            if thisfac == sysfaction:
                pass
            elif iscit:
                for neighbor in adjsystems:
                    if (VS.GetRelation(thisfac, VS.GetGalaxyFaction(neighbor))
                            > -.05):
                        #fgname=cursys+"->"+neighbor
                        fgname = "(CivReg) " + GetNewFGName(thisfac)
                        typenumbertuple = GenerateCivilianFgShips(
                            thisfac, thisfactionnr, True)
                        fg_util.AddShipsToFG(fgname, thisfac, typenumbertuple,
                                             cursys)
                fgname = "Insystem_" + cursys
                typenumbertuple = GenerateCivilianFgShips(
                    thisfac, thisfactionnr, False)
        if iscit:
            #debug.debug("generating gen civilian for "+cursys+" faction "+thisfac)
            if VS.GetRelation(
                    thisfac,
                    sysfaction) > -.05:  #brave citizens of the new order...
                fgname = GetNewFGName(thisfac)
                typenumbertuple = GenerateCivilianFgShips(
                    thisfac, thisfactionnr, True)
                fg_util.AddShipsToFG(fgname, thisfac, typenumbertuple, cursys)
    friendlychance = .7
    if cursys in faction_ships.fortress_systems:
        friendlychance = faction_ships.fortress_systems[cursys]
        #debug.debug('enemy chance for '+cursys +'= '+str(friendlychance))
    for i in range(numflightgroups):  #number of fgs in a system.
        faction = sysfaction
        friendly = 0
        if not sysfaction or sysfaction == 'unknown' or vsrandom.random(
        ) > friendlychance:
            faction = faction_ships.get_rabble_of_no_citizen(
                sysfaction)  #why even have citizens on the list then
        else:
            faction = faction_ships.get_friend_of_no_citizen(
                sysfaction
            )  #likewise--- maybe this should be a faction_ships fix
            if (faction == sysfaction):
                friendly = 1
            if (sysfaction in faction_ships.production_centers):
                if (cursys in faction_ships.production_centers[sysfaction]):
                    friendly = 2
            #if (friendly):
            #    debug.debug(faction+" "+sysfaction+" "+cursys)
        factionnr = faction_ships.factionToInt(faction)
        global maxshipsinfg
        typenumbertuple = GenerateFgShips(
            vsrandom.randrange(maxshipsinfg) + 1, factionnr, friendly)
        fgname = GetNewFGName(faction)
        fg_util.AddShipsToFG(fgname, faction, typenumbertuple, cursys)
    return i