using LitJson;

namespace Wizard;

public class PracticePuzzleBattleFinish : BaseTask
{
	public class PracticePuzzleBattleFinishParam : BaseParam
	{
		public int puzzle_id;

		public int retry_count;

		public bool is_win;
	}

	public PracticePuzzleBattleFinish()
	{
		base.type = ApiType.Type.PracticePuzzleBattleFinish;
	}

	public void SetParameter(int puzzleId, int retryCount, bool isWin)
	{
		PracticePuzzleBattleFinishParam practicePuzzleBattleFinishParam = new PracticePuzzleBattleFinishParam();
		practicePuzzleBattleFinishParam.puzzle_id = puzzleId;
		practicePuzzleBattleFinishParam.retry_count = retryCount;
		practicePuzzleBattleFinishParam.is_win = isWin;
		base.Params = practicePuzzleBattleFinishParam;
	}

	protected override int Parse()
	{
		int num = base.Parse();
		if (num != 1)
		{
			DeleteRecoveryFileIfBattleAlreadyEnded(num);
			return num;
		}
		Data.PracticePuzzleFinishData = new PracticePuzzleFinishData();
		Data.PracticePuzzleFinishData._responseData = base.ResponseData;
		Data.PracticePuzzleFinishData.class_chara_experience = 0;
		Data.PracticePuzzleFinishData.class_chara_level = 0;
		Data.PracticePuzzleFinishData.get_class_chara_experience = base.ResponseData["data"]["get_class_experience"].ToInt();
		Data.PracticePuzzleFinishData.class_chara_experience = base.ResponseData["data"]["class_experience"].ToInt();
		Data.PracticePuzzleFinishData.class_chara_level = base.ResponseData["data"]["class_level"].ToInt();
		JsonData jsonData = base.ResponseData["data"]["achieved_info"];
		if (jsonData.GetJsonType() == JsonType.Object)
		{
			Data.PracticePuzzleFinishData.AchievedInfo.Read(jsonData);
		}
		PlayerStaticData.UpdateHaveUserGoodsNumByJsonData(base.ResponseData["data"]["reward_list"]);
		return num;
	}
}
