コード例 #1
0
    def _calc_boss_reward_result(self, union_response, data, req, timer):
        res = union_boss_pb2.QueryUnionBossBoxRes()
        res.status = 0

        union_res = internal_union_pb2.InternalUnionBossBossRewardRes()
        union_res.ParseFromString(union_response)

        if union_res.status != 0:
            raise Exception("accept union boss reward failed")

        if union_res.ret != union_pb2.UNION_OK:
            res.ret = union_res.ret
            return self._boss_reward_succeed(data, req, res, timer)

        item_id = 0
        item_num = 0
        for member in union_res.box.members:
            if member.user_id == data.id:
                item_id = member.item_id
                item_num = member.item_num

        if item_id != 0:
            item_business.gain_item(data, [(item_id, item_num)], "boss reward", log_formater.BOsS_REWARD)

        res.ret = union_pb2.UNION_OK
        res.box.CopyFrom(union_res.box)

        defer = DataBase().commit(data)
        defer.addCallback(self._boss_reward_succeed, req, res, timer)
        return defer
コード例 #2
0
 def _query_boss_reward_failed(self, err, req, timer):
     logger.fatal("Query union boss box reward failed[reason=%s]" % err)
     res = union_boss_pb2.QueryUnionBossBoxRes()
     res.status = -1
     response = res.SerializeToString()
     logger.notice("Query union boss box reward failed"
             "[user_id=%d][req=%s][res=%s][consume=%d]" %
             (timer.id, req, res, timer.count_ms()))
     return response
コード例 #3
0
    def _calc_query_boss_reward(self, data, req, timer):
        union = data.union.get(True)
        if union is None or not union.is_belong_to_target_union(req.union_id):
            res = union_boss_pb2.QueryUnionBossBoxRes()
            res.status = 0
            res.ret = union_pb2.UNION_NOT_MATCHED
            return self._query_boss_reward_succeed(data, req, res, timer)

        user = data.user.get(True)
        union_req = internal_union_pb2.InternalUnionBossBossRewardReq()
        union_req.user_id = data.id
        union_req.user_name = user.name
        union_req.icon_id = user.icon_id
        union_req.boss_step = req.box_id

        defer = GlobalObject().remote['gunion'].callRemote(
            "query_unionboss_reward", req.union_id, union_req.SerializeToString())
        defer.addCallback(self._calc_query_boss_reward_result, data, req, timer)
        return defer
コード例 #4
0
    def _calc_query_boss_reward_result(self, union_response, data, req, timer):
        res = union_boss_pb2.QueryUnionBossBoxRes()
        res.status = 0

        union_res = internal_union_pb2.InternalUnionBossBossRewardRes()
        union_res.ParseFromString(union_response)

        if union_res.status != 0:
            raise Exception("accept union boss reward failed")

        if union_res.ret != union_pb2.UNION_OK:
            res.ret = union_res.ret
            return self._query_boss_reward_succeed(data, req, res, timer)

        res.ret = union_pb2.UNION_OK
        res.box.CopyFrom(union_res.box)

        defer = DataBase().commit(data)
        defer.addCallback(self._query_boss_reward_succeed, req, res, timer)
        return defer