using System;
using System.Collections.Generic;
using Cute;
using LitJson;
using UnityEngine;
using Wizard;
using Wizard.Battle.Tutorial;
using Wizard.Lottery;

public class TutorialResultReporter : IBattleResultReporter
{
	private readonly GameObject m_reportEndAgentObj;

	private readonly TutorialReportEndAgent m_reportEndAgent;

	public bool IsEnd => m_reportEndAgent.IsEnd;

	public int ClassExp => GetClassExp();

	public List<UserAchievement> UserAchievement => GetUserAchievementList();

	public List<UserMission> UserMission => GetUserMissionList();

	public List<ReceivedReward> MissionRewards => null;

	public List<ReceivedReward> VictoryRewards => null;

	public LotteryApplyData LotteryData => LotteryApplyData.EmptyData();

	public MyPageHomeDialogData HomeDialogData => null;

	public bool IsDataExist => true;

	public TutorialResultReporter()
	{
		m_reportEndAgentObj = new GameObject();
		m_reportEndAgent = m_reportEndAgentObj.AddComponent<TutorialReportEndAgent>();
	}

	public void Report(bool isWin)
	{
		int tutorial_step = 0;
		if (isWin && Data.SelectedStoryInfo.IsTutorial)
		{
			if (Data.Load.data._userTutorial.tutorial_step == 1)
			{
				tutorial_step = 11;
			}
			else if (Data.Load.data._userTutorial.tutorial_step == 11)
			{
				tutorial_step = 21;
			}
			else if (Data.Load.data._userTutorial.tutorial_step == 21)
			{
				tutorial_step = 31;
				PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.FIRST_TIPS_AFTER_ROTATION_USER_FLAG, 1);
			}
			bool isSkip = BattleManagerBase.GetIns() is TutorialBattleMgrBase tutorialBattleMgrBase && tutorialBattleMgrBase.IsUseTutorialSkip;
			StartTutorialUpdateTaskData(tutorial_step, isSkip, delegate
			{
				m_reportEndAgent.Finished();
			});
		}
		else
		{
			m_reportEndAgent.Finished();
		}
	}

	public void StartTutorialUpdateTaskData(int tutorial_step, bool isSkip, Action callback)
	{
		FinishTutorialReport(tutorial_step);
		TutorialUpdateTask tutorialUpdateTask = new TutorialUpdateTask();
		tutorialUpdateTask.SetParameter(tutorial_step, isSkip);
		m_reportEndAgent.StartCoroutine(Toolbox.NetworkManager.Connect(tutorialUpdateTask, delegate
		{
			callback.Call();
		}, BaseTask.OnRequestFailed, BaseTask.OnFailedErrorCode));
	}

	public JsonData GetFinishResponseData()
	{
		return null;
	}

	public List<UserAchievement> GetUserAchievementList()
	{
		return new List<UserAchievement>();
	}

	public List<UserMission> GetUserMissionList()
	{
		return new List<UserMission>();
	}

	public void Destroy()
	{
		UnityEngine.Object.Destroy(m_reportEndAgentObj);
	}

	public int GetClassExp()
	{
		return 0;
	}

	private void FinishTutorialReport(int tutorial_step)
	{
		if (tutorial_step == 31)
		{
			AdjustManager.TutorialCompleteEvent();
		}
	}
}
