Code Duplication    Length = 16-17 lines in 2 locations

server/lib/ige/ospace/IAIEDENPlayer.py 1 location

@@ 105-121 (lines=17) @@
102
        player = tran.db.get(playerID, None)
103
        if player.type in (Const.T_AIPIRPLAYER, Const.T_PIRPLAYER):
104
            dipl = obj.diplomacyRels.get(playerID, None)
105
            if not dipl:
106
                # make default
107
                dipl = IDataHolder()
108
                dipl.type = Const.T_DIPLREL
109
                dipl.pacts = {
110
                        Const.PACT_ALLOW_CIVILIAN_SHIPS: [Const.PACT_ACTIVE, Const.PACT_ALLOW_CIVILIAN_SHIPS],
111
                        Const.PACT_ALLOW_MILITARY_SHIPS: [Const.PACT_ACTIVE, Const.PACT_ALLOW_MILITARY_SHIPS]
112
                }
113
                dipl.relation = Const.REL_FRIENDLY
114
                dipl.relChng = 0
115
                dipl.lastContact = tran.db[Const.OID_UNIVERSE].turn
116
                dipl.contactType = Const.CONTACT_NONE
117
                dipl.stats = None
118
                if playerID != obj.oid:
119
                    obj.diplomacyRels[playerID] = dipl
120
                else:
121
                    log.debug("getDiplomacyWith myself", obj.oid)
122
            return dipl
123
        # this AI battles with overyone
124
        # make default

server/lib/ige/ospace/IPlayer.py 1 location

@@ 759-774 (lines=16) @@
756
            return self.cmd(leader).getDiplomacyWith(tran, leader, objID)
757
        # player is independent
758
        dipl = obj.diplomacyRels.get(playerID, None)
759
        if not dipl:
760
            # make default
761
            dipl = IDataHolder()
762
            dipl.type = Const.T_DIPLREL
763
            dipl.pacts = {
764
                Const.PACT_ALLOW_CIVILIAN_SHIPS: [Const.PACT_ACTIVE, Const.PACT_ALLOW_CIVILIAN_SHIPS]
765
            }
766
            dipl.relation = obj.defaultRelation
767
            dipl.relChng = 0
768
            dipl.lastContact = tran.db[Const.OID_UNIVERSE].turn
769
            dipl.contactType = Const.CONTACT_NONE
770
            dipl.stats = None
771
            if playerID != obj.oid:
772
                obj.diplomacyRels[playerID] = dipl
773
            else:
774
                log.debug("getDiplomacyWith myself", obj.oid)
775
        return dipl
776
777
    @public(Const.AL_OWNER)