while True:
     shards = client.listShards(generate_token(700))
     print shards
     count = 0
     for skey in shards:
         shard = shards[skey]
         if shard['invasion'] != None:
             count = count + 1
     for skey in shards:
         shard = shards[skey]
         if shard['invasion'] == None:
             if shard['name'] in superDistricts:
                 typ = int(float(random.random()) * 4.0)
                 suit = int(float(random.random()) *
                            4.0) + 4  # Bias the cogs to be big
                 client.startInvasion(generate_token(700), int(skey),
                                      typ, suit, 0, 0)
                 count = count + 1
                 print 'Calling invasion for %s with %d,%d' % (
                     shard['name'], typ, suit)
     if count < 3:
         for skey in shards:
             shard = shards[skey]
             if shard['invasion'] == None and not shard[
                     'name'] in safeHarbor:
                 r = random.random()
                 if r < BaseInvasionChance and not shard[
                         'name'] in superDistricts:
                     typ = int(float(random.random()) * 4.0)
                     suit = int(float(random.random()) * 8.0)
                     client.startInvasion(generate_token(700),
                                          int(skey), typ, suit, 0, 0)
Пример #2
0
        while True:
            shards = client.listShards(generate_token(700))
            print shards
            count = 0
            for skey in shards:
                shard = shards[skey]
                if shard['invasion'] != None:
                    count = count + 1
            for skey in shards:
                shard = shards[skey]
                if shard['invasion'] == None:
                    if shard['name'] in superDistricts:
                        typ = int(float(random.random()) * 4.0)
                        suit = int(float(random.random()) * 4.0) + 4  # Bias the cogs to be big
                        client.startInvasion(generate_token(700), int(skey), typ, suit, 0, 0)
                        count = count + 1
                        print 'Calling invasion for %s with %d,%d'%(shard['name'],typ,suit)
            if count < 3:
                for skey in shards:
                    shard = shards[skey]
                    if shard['invasion'] == None and not shard['name'] in safeHarbor:
                        r = random.random()
                        if r < BaseInvasionChance and not shard['name'] in superDistricts:
                            typ = int(float(random.random()) * 4.0)
                            suit = int(float(random.random()) * 8.0)
                            client.startInvasion(generate_token(700), int(skey), typ, suit, 0, 0)
                            print 'Calling invasion for %s with %d,%d'%(shard['name'],typ,suit)
            print "tick..(was %d)\n"%(count)
            time.sleep(60)
    except Exception, e: