Ejemplo n.º 1
0
 def isStoryRelevant(self, strin):
     """Is the event in this string relevant to the current
 system and dockedat faction?"""
     varlist = self.sTovarlist(strin)
     limit = False
     if varlist[self.EVENT_TYPE_INDEX] in [
             self.TYPE_BATTLE, self.TYPE_DESTROYED
     ]:
         limit = 1
     else:
         return True
     event_sys = varlist[self.EVENT_SYSTEM_INDEX]
     syslist = [VS.getSystemFile()]
     done_syslist = list()
     while limit >= 0:
         if event_sys in syslist:
             return True
         else:
             done_syslist += syslist
             new_syslist = list()
             for syst in syslist:
                 for i in range(VS.GetNumAdjacentSystems(syst)):
                     sy = VS.GetAdjacentSystem(syst, i)
                     if sy not in done_syslist:
                         new_syslist.append(sy)
             syslist = new_syslist
             limit -= 1
     return False
Ejemplo n.º 2
0
 def launch_new_wave(self):
     un = VS.getPlayer()
     if (vsrandom.randrange(0,4)==0):
         if (un):
             currentsystem = VS.getSystemFile()
             numadj=VS.GetNumAdjacentSystems(currentsystem)
             if (numadj):
                 cursys=VS.GetAdjacentSystem(currentsystem,vsrandom.randrange(0,numadj))
             else:
                 cursys = 'enigma_sector/heavens_gate'
             debug.info("TJ: jumping to "+cursys)
             un.JumpTo(cursys)
         else:
             debug.info("TJ: jumping to [ERROR: you are null]")
     side = vsrandom.randrange(0,2)
     faction="confed"
     ai = vsrandom.randrange(0,6)
     if (0 and ai==0):
         ai = "printhello.py"
     else:
         ai = "default"
     if (side==0):
         faction=faction_ships.get_enemy_of("confed")
     else:
         faction=faction_ships.get_friend_of("confed")
     launched = launch.launch_wave_around_unit ("Shadow",faction,faction_ships.getRandomFighter(faction),ai,vsrandom.randrange(1,10),100.0,2000.0,VS.getPlayer(),'')
     if (vsrandom.randrange(0,10)==0):
         launch.launch_wave_around_unit ("ShadowCap",faction,faction_ships.getRandomCapitol(faction),ai,1,2000.0,4000.0,VS.getPlayer(),'')
Ejemplo n.º 3
0
 def launch_new_wave(self):
     un = VS.getPlayer()
     if (vsrandom.randrange(0, 4) == 0):
         if (un):
             currentsystem = VS.getSystemFile()
             numadj = VS.GetNumAdjacentSystems(currentsystem)
             if (numadj):
                 cursys = VS.GetAdjacentSystem(
                     currentsystem, vsrandom.randrange(0, numadj))
             else:
                 cursys = 'enigma_sector/heavens_gate'
             debug.info("TJ: jumping to " + cursys)
             un.JumpTo(cursys)
         else:
             debug.warn("TJ: jumping to [ERROR: you are null]")
         return
     else:
         siglist = universe.significantUnits()
         if len(siglist) == 0:
             debug.info("TJ: siglist empty")
             return
         sig = siglist[vsrandom.randrange(0, len(siglist))]
         if (not sig):
             debug.info("TJ: sig null")
             return
         debug.info("TJ: autopiloting to " + sig.getName())
         un.AutoPilotTo(sig, True)
         un.SetTarget(sig)
Ejemplo n.º 4
0
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, ))
Ejemplo n.º 5
0
def attackFlightgroup (fgname, faction, enfgname, enfaction,iscap):
    global dnewsman_
    if (iscap):
        battlename=dnewsman_.TYPE_FLEETBATTLE
        (leader,enleader)=iscap.split(",")
    else:
        battlename = dnewsman_.TYPE_BATTLE
        leader = fg_util.getFgLeaderType(fgname,faction)
        enleader = fg_util.getFgLeaderType(enfgname,enfaction)
    sys = fg_util.FGSystem (fgname,faction)
    ensys = fg_util.FGSystem (enfgname,enfaction)
    if (sys==ensys):
        if (0 and VS.systemInMemory(sys)):
            VS.pushSystem(sys)
            LaunchEqualShips (fgname,faction,enfgname,enfaction)
            VS.TargetEachOther (fgname,faction,enfgname,enfaction)
            VS.popSystem()
        #debug.debug('duke '+fgname + ' '+enfgname)
        SimulatedDukeItOut (fgname,faction,enfgname,enfaction)
    elif (sys!='nil' and ensys!='nil'):
        #pursue other flightgroup
        import universe
        adjSystemList=universe.getAdjacentSystemList(sys)
        if ensys in adjSystemList:
            fg_util.TransferFG (fgname,faction,ensys)
        else:
            return 0
    else:
        return 0 #debug.debug('nil DRAW error')
    if (fg_util.NumShipsInFG(fgname,faction)==0):
        if (fg_util.NumShipsInFG(enfgname,enfaction)==0):
            dnewsman_.writeDynamicString([str(Director.getSaveData(0,"stardate",0)),battlename,dnewsman_.STAGE_END,faction,enfaction,dnewsman_.SUCCESS_DRAW,str(getImportanceOfSystem(sys)),sys,dnewsman_.KEYWORD_DEFAULT,fgname,leader,enfgname,enleader])
        else:
            dnewsman_.writeDynamicString([str(Director.getSaveData(0,"stardate",0)),battlename,dnewsman_.STAGE_END,faction,enfaction,dnewsman_.SUCCESS_LOSS,str(getImportanceOfSystem(sys)),sys,dnewsman_.KEYWORD_DEFAULT,fgname,leader,enfgname,enleader])
        return 0
    elif (fg_util.NumShipsInFG(enfgname,enfaction)==0):
        dnewsman_.writeDynamicString([str(Director.getSaveData(0,"stardate",0)),battlename,dnewsman_.STAGE_END,faction,enfaction,dnewsman_.SUCCESS_WIN,str(getImportanceOfSystem(sys)),sys,dnewsman_.KEYWORD_DEFAULT,fgname,leader,enfgname,enleader])
        return 0
    if (vsrandom.randrange(0,4)==0):
        #FIXME  if it is advantageous to stop attacking only!!
        #FIXME add a stop attacking news report?  -- this should now be fixed, as a draw is reported (not heavilly tested)
        #CAUSES TOO MUCH NEWS#Director.pushSaveString(0,"dynamic_news",dynamic_news.makeVarList([str(Director.getSaveData(0,"stardate",0)),battlename,"end",faction,enfaction,"0",str(getImportanceOfSystem(sys)),sys,"all",fgname,leader,enfgname,enleader]))
        return 0
    if (vsrandom.randrange(0,4)==0 and enfgname!=fg_util.BaseFGInSystemName(ensys)):
        #FIXME  if it is advantageous to run away only
        #FIXME add a retreat news report?  -- this should now be fixed, as a draw is reported (not heavilly tested)
        #CAUSES TOO MUCH NEWS#Director.pushSaveString(0,"dynamic_news",dynamic_news.makeVarList([str(Director.getSaveData(0,"stardate",0)),battlename,"end",faction,enfaction,"-1",str(getImportanceOfSystem(sys)),sys,"all",fgname,leader,enfgname,enleader]))
        num=VS.GetNumAdjacentSystems(ensys)
        if (num>0):
            ensys=VS.GetAdjacentSystem(ensys,vsrandom.randrange(0,num))
            fg_util.TransferFG (fgname,faction,ensys)
    return 1
Ejemplo n.º 6
0
def moveSurroundingCapshipsToSiege(fac,sys):
    suc=0
    for i in xrange(VS.GetNumAdjacentSystems(sys)):
        asys=VS.GetAdjacentSystem(sys,i)
        for fg in fg_util.AllFGsInSystem(fac,asys):
            if fg_util.CapshipInFG(fg,fac):
                suc=1
                fg_util.TransferFG(fg,fac,sys)
    if (not suc):
        for fg in fg_util.AllFGsInSystem(fac,sys):
            if (fg_util.CapshipInFG(fg,fac)):
                suc=1
    return suc
Ejemplo n.º 7
0
def neighborFaction(sys,fac):
    for i in xrange(VS.GetNumAdjacentSystems(sys)):
        asys=VS.GetAdjacentSystem(sys,i)
        if (VS.GetGalaxyFaction(asys)==fac):
            return True
    return False
Ejemplo n.º 8
0
def getAdjacentSystemList(tothissystem):
    list_2 = []
    max = VS.GetNumAdjacentSystems(tothissystem)
    for i in range(max):
        list_2.append(VS.GetAdjacentSystem(tothissystem, i))
    return list_2