Code Duplication    Length = 17-17 lines in 2 locations

client-ai/ai_client.py 1 location

@@ 244-260 (lines=17) @@
241
def getPlayer():
242
    return db[db.playerID]
243
244
def getDiplomacyWith(contactID):
245
    obj = getPlayer()
246
    dipl = obj.diplomacyRels.get(contactID, None)
247
    if not dipl:
248
        # make default
249
        dipl = IDataHolder()
250
        dipl.type = Const.T_DIPLREL
251
        dipl.pacts = {
252
            Const.PACT_ALLOW_CIVILIAN_SHIPS: [Const.PACT_ACTIVE, Const.PACT_ALLOW_CIVILIAN_SHIPS]
253
        }
254
        dipl.relation = obj.defaultRelation
255
        dipl.relChng = 0
256
        dipl.lastContact = 0
257
        dipl.stats = None
258
        dipl.contactType = Const.CONTACT_NONE
259
        obj.diplomacyRels[playerID] = dipl
260
    return dipl
261
262

client/osci/client.py 1 location

@@ 341-357 (lines=17) @@
338
def getPlayer():
339
    return db[db.playerID]
340
341
def getDiplomacyWith(contactID):
342
    obj = getPlayer()
343
    dipl = obj.diplomacyRels.get(contactID, None)
344
    if not dipl:
345
        # make default
346
        dipl = IDataHolder()
347
        dipl.type = Const.T_DIPLREL
348
        dipl.pacts = {
349
            Const.PACT_ALLOW_CIVILIAN_SHIPS: [Const.PACT_ACTIVE, Const.PACT_ALLOW_CIVILIAN_SHIPS]
350
        }
351
        dipl.relation = obj.defaultRelation
352
        dipl.relChng = 0
353
        dipl.lastContact = 0
354
        dipl.stats = None
355
        dipl.contactType = Const.CONTACT_NONE
356
        obj.diplomacyRels[playerID] = dipl
357
    return dipl
358
359
def getMessages():
360
    # construct list of mailboxes