Code Duplication    Length = 16-17 lines in 2 locations

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

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

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

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