using LitJson;
using Wizard;
using Wizard.Battle.Recovery;

public class FinishTaskBase : BaseTask
{
	protected int classId;

	protected const string data_str = "data";

	public bool IsResponseDataExist(JsonData response)
	{
		JsonData jsonData = response["data"];
		if (jsonData == null || jsonData.Count == 0)
		{
			return false;
		}
		return true;
	}

	public BattleFinishParam SettingFinishBattleParameter(int class_id, int total_turn, int evolve_count, int enemy_evolve_count, int battle_result, int is_retire)
	{
		DataMgr dataMgr = GameMgr.GetIns().GetDataMgr();
		BattleManagerBase ins = BattleManagerBase.GetIns();
		classId = class_id;
		BattleFinishParam battleFinishParam = CreateBattleFinishParam(class_id, total_turn, evolve_count, enemy_evolve_count, battle_result, is_retire);
		PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.SELF_DISCONNECT_OPEN_STATUS_TO_REPLACE_LOG, 0f);
		if (battle_result == 0 && dataMgr.RecoveryData == null && RecoveryRecordManagerBase.IsExistsAINetworkRecoveryFile())
		{
			dataMgr.SetRecoveryData(RecoveryOperationInfo.ReadRecoveryFile(OperationRecorderBase.RecordDirectoryPath + "recovery_ai_network.json"));
		}
		JsonData recoveryData = dataMgr.RecoveryData;
		if (recoveryData != null)
		{
			battleFinishParam.recovery_data = recoveryData.ToJson();
		}
		BattlePlayerPair battlePlayerPair = ins.GetBattlePlayerPair(isPlayer: true);
		BattleCardBase selfClass = ins.GetBattlePlayer(isPlayer: true).Class;
		battleFinishParam.mission = dataMgr.MissionNecessaryInformation.GetMissionNecessaryInfo(battlePlayerPair, selfClass);
		base.Params = battleFinishParam;
		return battleFinishParam;
	}

	protected virtual BattleFinishParam CreateBattleFinishParam(int class_id, int total_turn, int evolve_count, int enemy_evolve_count, int battle_result, int is_retire)
	{
		return new BattleFinishParam
		{
			class_id = class_id,
			total_turn = total_turn,
			evolve_count = evolve_count,
			enemy_evolve_count = enemy_evolve_count,
			battle_result = battle_result,
			is_retire = is_retire
		};
	}

	protected bool IsEffectiveErrorCode(int code)
	{
		if (resultCode != 1 && resultCode != 3502)
		{
			return true;
		}
		return false;
	}
}
