Esempio n. 1
0
def LaunchEqualShips (fgname, faction, enfgname, enfaction):
    debug.debug("DYNAMO*3")
    land=fg_util.LandedShipsInFG(fgname,faction)
    launch=fg_util.ShipsInFG(fgname,faction)
    enland=fg_util.LandedShipsInFG(enfgname,enfaction)
    enlaunch=fg_util.ShipsInFG(enfgname,enfaction)
    numenland=countTn(enland)
    numenlaunch=countTn(enlaunch)
    numland=countTn(land)
    numlaunch=countTn(launch)
    if (numenland==0 or numland==0 or (numlaunch==0 and numenlaunch==0) ):
        return
    if (numlaunch/numland > numenlaunch/numenland):
        LaunchMoreShips (fgname,faction,land,int((numland*numenlaunch/numenland)-numlaunch))
    else:
        LaunchMoreShips (enfgname,enfaction,enland,int((numenland*numlaunch/numland)-numenlaunch))
Esempio n. 2
0
    def Preprocess(self):
        debug.debug("Entering Preprocess()")
        self._preprocess = 1
        self._dyn_nr_ships = []
        self._nr_ships = self.num
        import faction_ships
        if self.dynfg != '':
            import fg_util
            tn = fg_util.ShipsInFG(self.dynfg, self.faction)
            debug.info('Dynamically launching from SaveString flightgroup ' +
                       self.dynfg + ' with ships: ' + str(tn) + ' faction ' +
                       self.faction)
            knum = 0
            if (tn != [] and self.type != ''):
                for i in range(len(tn)):
                    if (tn[i][0] == self.type):
                        knum = tn[i][1]
                        if (knum > self.num):
                            knum = self.num
                        self._dyn_nr_ships = [(self.type, knum)]
                        del tn[i]
                        break
##          if (tn==[]):
##          print 'Dyn-Launch: tn==[]'
##          self.dynfg=''
            elif (tn == []):
                debug.info("Dyn-Launch: tn==" + str(tn) + ", dynfg=='" +
                           str(self.dynfg) + "' getting random fighter")
                self.type = faction_ships.getRandomFighterInt(
                    faction_ships.factionToInt(self.faction))
                self.fg = self.dynfg
                self.dynfg = ''
            if self.forcetype and len(
                    self._dyn_nr_ships) == 0 and self.type != '':
                self._dyn_nr_ships = [(self.type, 1)]
                knum = 1
            for i in tn:
                if (knum >= self.num):
                    break
                if (self.capitalp or (not faction_ships.isCapital(i[0]))):
                    if (i[1] > self.num - knum):
                        i = (i[0], self.num - knum)
                    self._dyn_nr_ships += [i]
                    knum += i[1]
            self._nr_ships = self.num - knum