예제 #1
0
    def _calc_query(self, data, req, timer, force):
        union = data.union.get(True)
        if not force and not union.is_belong_to_target_union(req.union_id):
            #已经不属于对应联盟
            res = union_pb2.QueryUnionRes()
            res.status = 0
            res.ret = union_pb2.UNION_NOT_MATCHED
            res.monarch.user_id = data.id
            res.monarch.union_id = union.union_id

            defer = DataBase().commit(data)
            defer.addCallback(self._query_succeed, req, res, timer)
            return defer
            
        union.update_daily_info(timer.now)

        union_req = internal_union_pb2.InternalQueryUnionReq()
        union_req.user_id = data.id

        #请求 Union 模块,查询联盟情况
        if not force:
            defer = GlobalObject().remote['gunion'].callRemote(
                    "query_union", union.union_id, union_req.SerializeToString())
        else:
            defer = GlobalObject().remote['gunion'].callRemote(
                    "query_union_force", req.union_id, union_req.SerializeToString())
        defer.addCallback(self._update_query_info, data, req, timer)
        return defer
예제 #2
0
 def _query_union_info(self, proxy, data, plunder, rival, req, timer):
     """"""
     union_req = internal_union_pb2.InternalQueryUnionReq()
     union_req.user_id = data.id
     
     defer = GlobalObject().remote['gunion'].callRemote(
             "query_union_summary", rival.union_id, union_req.SerializeToString())
     defer.addCallback(self._pack_query_player_response, data, plunder, rival, req, timer)
     return defer
예제 #3
0
 def _sync_union(self, data, union_id, timer):
     """同步联盟信息
     """
     #请求 Union 模块
     union_req = internal_union_pb2.InternalQueryUnionReq()
     union_req.user_id = data.id
     defer = GlobalObject().remote['gunion'].callRemote(
         "sync_union", union_id, union_req.SerializeToString())
     defer.addCallback(self._calc_sync_result, data, timer)
     return defer
예제 #4
0
    def query_summary(self, union_id, request):
        """查询联盟摘要
        """
        timer = Timer(union_id)

        req = internal_union_pb2.InternalQueryUnionReq()
        req.ParseFromString(request)

        defer = DataBase().get_data(union_id)
        defer.addCallback(self._calc_query_summary, req, timer)
        defer.addErrback(self._query_failed, req, timer)
        return defer
예제 #5
0
    def sync(self, union_id, request):
        """同步联盟信息(内部接口)
        同步是否在联盟中,联盟等级
        """
        timer = Timer(union_id)

        req = internal_union_pb2.InternalQueryUnionReq()
        req.ParseFromString(request)

        defer = DataBase().get_data(union_id)
        defer.addCallback(self._calc_sync, req, timer)
        defer.addErrback(self._sync_failed, req, timer)
        return defer