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

public class PracticeResultReporter : IBattleResultReporter
{
	private readonly GameObject m_reportEndAgentObj;

	private readonly PracticeReportEndAgent 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 => GetRewardsList();

	public List<ReceivedReward> VictoryRewards => null;

	public LotteryApplyData LotteryData => Data.PracticeFinish.data.AchievedInfo._lotteryData;

	public MyPageHomeDialogData HomeDialogData => null;

	public bool IsDataExist => true;

	public PracticeResultReporter()
	{
		m_reportEndAgentObj = new GameObject();
		m_reportEndAgent = m_reportEndAgentObj.AddComponent<PracticeReportEndAgent>();
	}

	public void Report(bool isWin)
	{
		int is_win = (isWin ? 1 : 0);
		StartFinishPractice(is_win, delegate
		{
			m_reportEndAgent.Finished();
		});
	}

	public void StartFinishPractice(int is_win, Action callback)
	{
		DataMgr dataMgr = GameMgr.GetIns().GetDataMgr();
		NetworkManager networkManager = Toolbox.NetworkManager;
		PracticeFinishTask practiceFinishTask = new PracticeFinishTask();
		LocalLog.RecordCheckLog(LocalLog.RecordType.CERBERUS, is_win == 1);
		practiceFinishTask.SetParameter(dataMgr.GetSelectDeckId(), is_win, BattleManagerBase.GetIns().BattlePlayer._cumulativeEvolutionCount, BattleManagerBase.GetIns().BattlePlayer.Turn, dataMgr.GetEnemyClassId(), dataMgr.m_EnemyAIDifficulty, dataMgr.GetSelectDeckFormat(), dataMgr.GetPlayerClassId());
		m_reportEndAgent.StartCoroutine(networkManager.Connect(practiceFinishTask, delegate
		{
			callback.Call();
		}, BaseTask.OnRequestFailed, BaseTask.OnFailedErrorCode));
	}

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

	public JsonData GetFinishResponseData()
	{
		return Data.PracticeFinish.data._responseData;
	}

	public List<UserAchievement> GetUserAchievementList()
	{
		return Data.PracticeFinish.data.achieved_achievement_list;
	}

	public List<UserMission> GetUserMissionList()
	{
		return Data.PracticeFinish.data.achieved_mission_list;
	}

	public List<ReceivedReward> GetRewardsList()
	{
		return Data.PracticeFinish.data.Rewards;
	}

	public int GetClassExp()
	{
		return Data.PracticeFinish.data.get_class_chara_experience;
	}
}
