Code Duplication    Length = 16-18 lines in 2 locations

client-ai/AIs/ais_rebel.py 1 location

@@ 302-319 (lines=18) @@
299
            techID = possibilities[0]
300
            player.rsrchQueue = client.cmdProxy.startResearch(playerID, techID)
301
302
def diplomacyManager():
303
    global client, db, player, playerID
304
#    if not player.voteFor == playerID:
305
#        client.cmdProxy.setVoteFor(playerID, playerID)
306
#    rebels cannot be voted
307
    for contactID in player.diplomacyRels:
308
        dipl = client.getDiplomacyWith(contactID)
309
        for pactID in [Const.PACT_ALLOW_CIVILIAN_SHIPS, Const.PACT_ALLOW_TANKING, Const.PACT_MINOR_SCI_COOP, Const.PACT_MAJOR_SCI_COOP, Const.PACT_MINOR_CP_COOP, Const.PACT_MAJOR_CP_COOP]:
310
            pactSpec = Rules.pactDescrs[pactID]
311
            if dipl.relation < pactSpec.validityInterval[0] or dipl.relation > pactSpec.validityInterval[1]:
312
                # not friendly enough
313
                continue
314
            if pactID in dipl.pacts and dipl.pacts[pactID][0] in [Const.PACT_ACTIVE, Const.PACT_INACTIVE]:
315
                # nothing more to do, move along
316
                continue
317
            # hey, we should enable this pact!
318
            conditions = [pactID]
319
            player.diplomacyRels = client.cmdProxy.changePactCond(playerID, contactID, pactID, Const.PACT_INACTIVE, conditions)
320
321
322
def defenseManager():

client-ai/AIs/ais_renegade.py 1 location

@@ 133-148 (lines=16) @@
130
def attackManager():
131
    pass
132
133
def diplomacyManager():
134
    # renegades are friendly, want to trade, and can help refuel civilian ships
135
    global client, db, player, playerID
136
    for contactID in player.diplomacyRels:
137
        dipl = client.getDiplomacyWith(contactID)
138
        for pactID in [Const.PACT_ALLOW_CIVILIAN_SHIPS, Const.PACT_ALLOW_TANKING, Const.PACT_MINOR_CP_COOP, Const.PACT_MAJOR_CP_COOP]:
139
            pactSpec = Rules.pactDescrs[pactID]
140
            if dipl.relation < pactSpec.validityInterval[0] or dipl.relation > pactSpec.validityInterval[1]:
141
                # not friendly enough
142
                continue
143
            if pactID in dipl.pacts and dipl.pacts[pactID][0] in [Const.PACT_ACTIVE, Const.PACT_INACTIVE]:
144
                # nothing more to do, move along
145
                continue
146
            # hey, we should enable this pact!
147
            conditions = [pactID]
148
            player.diplomacyRels = client.cmdProxy.changePactCond(playerID, contactID, pactID, Const.PACT_INACTIVE, conditions)
149
150
def run(aclient):
151
    global client, db, player, playerID