local this = {}

function this:req_CSProtoRogueLikeGetReward(guid, args, callback)
  args = args or {}
  local data = {
    guid = guid,
    arg1 = args[1],
    arg2 = args[2]
  }
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeGetReward, data, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc then
      if callback then
        callback()
      end
      if not table.isEmpty(self.data.rewardStorage) then
        self:call(self.event.showRewardPage)
      end
    end
  end)
end

function this:req_CSProtoRogueLikeEndReward(callback)
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeEndReward, nil, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc and callback then
      callback()
    end
  end)
end

function this:req_CSProtoRogueLikeLockRewardPool(guid, callback)
  local data = {guid = guid}
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeLockRewardPool, data, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc and callback then
      callback()
    end
  end)
end

function this:req_CSProtoRogueLikeDealEcho(type, args, callback)
  local data = {
    type = type,
    arg1 = args[1],
    arg2 = args[2]
  }
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeDealEcho, data, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc then
      if callback then
        callback()
      end
      if not table.isEmpty(self.data.rewardStorage) then
        self:call(self.event.showRewardPage)
      end
    end
  end)
end

function this:req_CSProtoRogueLikePaidRewards(callback)
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikePaidRewards, nil, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc and callback then
      callback()
    end
  end)
end

function this:req_CSProtoRogueLikeDoTrigger(type, args, callback)
  local data = {type = type, args = args}
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeDoTrigger, data, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc and callback then
      callback()
    end
  end)
end

function this:req_CSProtoRogueLikeNodeInitReward(eventGuid, callback)
  local data = {
    guid = eventGuid,
    pos = L_PlayerManager:getMainControlEntityPos() * 100
  }
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeNodeInitReward, data, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc and callback then
      callback()
    end
  end)
end

function this:req_CSProtoRogueLikeNodeNewRole(param, callback)
  local data = {
    guid = param.guid,
    pos = L_PlayerManager:getMainControlEntityPos() * 100,
    type = param.type,
    arg = param.arg
  }
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeNodeNewRole, data, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc and callback then
      callback()
    end
  end)
end

function this:req_CSProtoRogueLikeNodeInteractCheck(param, callback)
  local data = {
    guid = param.guid,
    pos = L_PlayerManager:getMainControlEntityPos() * 100,
    res = param.res
  }
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeNodeInteractCheck, data, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc and callback then
      callback()
    end
  end)
end

function this:req_CSProtoRogueLikeNodeSelectDialog(param, callback)
  local data = {
    guid = param.guid,
    pos = L_PlayerManager:getMainControlEntityPos() * 100,
    index = param.index
  }
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeNodeSelectDialog, data, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc then
      if callback then
        callback()
      end
      self:checkAndStartStory()
    end
  end)
end

function this:req_CSProtoRogueLikeShopRefresh(param, callback)
  local data = {
    guid = param.guid,
    pos = L_PlayerManager:getMainControlEntityPos() * 100,
    res = param.res
  }
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeShopRefresh, data, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc and callback then
      callback()
    end
  end)
end

function this:req_CSProtoRogueLikeShopHaggle(param, callback)
  local data = {
    guid = param.guid,
    pos = L_PlayerManager:getMainControlEntityPos() * 100,
    res = param.res
  }
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeShopHaggle, data, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc and callback then
      callback()
    end
  end)
end

function this:req_CSProtoRogueLikeStartDialog(eventGuid, callback)
  local data = {
    guid = eventGuid,
    pos = L_PlayerManager:getMainControlEntityPos() * 100
  }
  L_Net:sendMessage(MsgGenCode.CSProtoRogueLikeStartDialog, data, function(rspData, errorCode)
    if errorCode == L_Const.errorCode.ErrCodeSucc then
      if callback then
        callback()
      end
      self:checkAndStartStory()
    end
  end)
end

return this
