コード例 #1
0
ファイル: friend.py プロジェクト: wyrover/sanguo-server
    def someone_refuse_me(self, from_id):
        self.mf.friends.pop(str(from_id))
        self.mf.save()

        msg = protomsg.RemoveFriendNotify()
        msg.id = from_id
        publish_to_char(self.char_id, pack_msg(msg))
コード例 #2
0
ファイル: friend.py プロジェクト: wyrover/sanguo-server
    def someone_cancel_me(self, from_id):
        if from_id not in self.mf.accepting:
            return

        self.mf.accepting.remove(from_id)
        self.mf.save()

        msg = protomsg.RemoveFriendNotify()
        msg.id = from_id
        publish_to_char(self.char_id, pack_msg(msg))
コード例 #3
0
    def someone_refuse_me(self, from_id):
        from_id = int(from_id)
        if from_id in self.mf.pending:
            self.mf.pending.remove(from_id)
        self.mf.save()

        msg = protomsg.RemoveFriendNotify()
        msg.id = from_id
        publish_to_char(self.char_id, pack_msg(msg))

        self.send_friends_amount_notify()
コード例 #4
0
    def someone_terminate_me(self, from_id):
        from_id = int(from_id)
        if from_id not in self.mf.friends:
            return

        self.mf.friends.remove(from_id)
        self.mf.save()

        msg = protomsg.RemoveFriendNotify()
        msg.id = from_id
        publish_to_char(self.char_id, pack_msg(msg))

        self.send_friends_amount_notify()
コード例 #5
0
    def cancel(self, target_id):
        # 取消好友申请
        target_id = int(target_id)
        if target_id not in self.mf.pending:
            raise SanguoException(
                errormsg.FRIEND_NOT_ACK, self.char_id, "Friend Cancel",
                "not ack for character {0}".format(target_id))

        self.mf.pending.remove(target_id)
        self.mf.save()

        target_char_friend = Friend(target_id)
        target_char_friend.someone_cancel_me(self.char_id)

        msg = protomsg.RemoveFriendNotify()
        msg.id = target_id
        publish_to_char(self.char_id, pack_msg(msg))
        self.send_friends_amount_notify()
コード例 #6
0
ファイル: friend.py プロジェクト: wyrover/sanguo-server
    def refuse(self, target_id):
        if target_id not in self.mf.accepting:
            raise SanguoException(
                errormsg.FRIEND_NOT_IN_ACCEPT_LIST,
                self.char_id,
                "Friend Refuse",
                "character {0} not in accept list".format(target_id)
            )

        self.mf.accepting.remove(target_id)
        self.mf.save()

        target_char_friend = Friend(target_id)
        target_char_friend.someone_refuse_me(self.char_id)

        msg = protomsg.RemoveFriendNotify()
        msg.id = target_id
        publish_to_char(self.char_id, pack_msg(msg))
コード例 #7
0
    def terminate(self, target_id):
        # 终止好友关系
        target_id = int(target_id)
        if target_id not in self.mf.friends:
            raise SanguoException(
                errormsg.FRIEND_NOT_OK, self.char_id, "Friend Terminate",
                "character {0} is not friend".format(target_id))

        self.mf.friends.remove(target_id)
        self.mf.save()

        target_char_friend = Friend(target_id)
        target_char_friend.someone_terminate_me(self.char_id)

        msg = protomsg.RemoveFriendNotify()
        msg.id = target_id
        publish_to_char(self.char_id, pack_msg(msg))

        self.send_friends_amount_notify()
コード例 #8
0
ファイル: friend.py プロジェクト: wyrover/sanguo-server
    def cancel(self, target_id):
        t = str(target_id)
        if t not in self.mf.friends or self.mf.friends[t] != FRIEND_ACK:
            raise SanguoException(
                errormsg.FRIEND_NOT_ACK,
                self.char_id,
                "Friend Cancel",
                "not ack for character {0}".format(target_id)
            )

        self.mf.friends.pop(t)
        self.mf.save()

        target_char_friend = Friend(target_id)
        target_char_friend.someone_cancel_me(self.char_id)

        msg = protomsg.RemoveFriendNotify()
        msg.id = target_id
        publish_to_char(self.char_id, pack_msg(msg))
        self.send_friends_amount_notify()
コード例 #9
0
 def send_remove_friend_notify(self, friend_ids):
     for i in friend_ids:
         msg = protomsg.RemoveFriendNotify()
         msg.id = i
         publish_to_char(self.char_id, pack_msg(msg))