using System;
using BackupParamAccessor;
using PlayerStatus;
using UnityEngine;

namespace Schedule
{
	public class ResultTrainingTask : ResultBaseTask
	{
		public ResultTrainingTask(WorkResultSlot slot, int workId, ResultWorkMgr.ResultType resultType)
		{
			base.Init(slot, workId, resultType);
			this.CalcParam();
			this.UpdateIcon();
		}

		public int lv
		{
			get
			{
				return ScheduleAPI.NoonWorkPlayToLv(ScheduleAPI.NoonWorkPlayCount(base.maid, base.id));
			}
		}

		public int revision
		{
			get
			{
				return ScheduleAPI.NoonWorkLvToRevision(this.lv);
			}
		}

		public bool communicationBonus
		{
			get
			{
				bool result = false;
				if (this.resultType == ResultWorkMgr.ResultType.Daytime)
				{
					result = GameMain.Instance.CharacterMgr.status.scheduleSlot[base.slot.slotId].noon_communication;
				}
				else if (this.resultType == ResultWorkMgr.ResultType.Night)
				{
					result = GameMain.Instance.CharacterMgr.status.scheduleSlot[base.slot.slotId].night_communication;
				}
				return result;
			}
		}

		public ScheduleData.WorkSuccessLv successLv
		{
			get
			{
				ScheduleData.WorkSuccessLv result = ScheduleData.WorkSuccessLv.Miss;
				if (this.resultType == ResultWorkMgr.ResultType.Daytime)
				{
					result = GameMain.Instance.CharacterMgr.status.scheduleSlot[base.slot.slotId].noon_success_level;
				}
				else if (this.resultType == ResultWorkMgr.ResultType.Night)
				{
					result = GameMain.Instance.CharacterMgr.status.scheduleSlot[base.slot.slotId].night_success_level;
				}
				return result;
			}
		}

		protected void CalcParam()
		{
			if (base.slot.textureBank != null)
			{
				this._icon = base.slot.textureBank.GetTexture(ScheduleCSVData.AllData[base.id].icon);
			}
			if (base.maid.status.GetFlag("_communication") > 0)
			{
				this.uppedParams.likability = 5;
				this.uppedParamsWithoutCommunicationBonus.likability = 5;
			}
			if (base.maid != null && base.maid.status.selectedJobClass != null && base.maid.status.selectedJobClass.level == base.maid.status.selectedJobClass.expSystem.GetMaxLevel())
			{
				this.maidLvMax = true;
				if (this.uppedParams.maidClassLv > 0)
				{
					this.maidLvCompletion = true;
				}
			}
		}

		protected override void CalcParam(SCENE_ID baseId)
		{
			Params backupParams = BackupParamAccessor.GetBackupParams(base.slot.slotId, baseId - 1);
			Params backupParams2 = BackupParamAccessor.GetBackupParams(base.slot.slotId, baseId);
			Params backupParams3 = BackupParamAccessor.GetBackupParams(base.slot.slotId, baseId + 1);
			this.uppedParamsWithoutCommunicationBonus = backupParams2 - backupParams;
			this.uppedParams = backupParams3 - backupParams;
		}

		protected void UpdateIcon()
		{
			this.successLv_icon = null;
			this.bonus_icon = null;
			if (base.maid != null && base.slot.textureBank != null)
			{
				switch (this.successLv)
				{
				case ScheduleData.WorkSuccessLv.Miss:
				case ScheduleData.WorkSuccessLv.Unexecuted:
					this.successLvName = "CM3D2_work_result_mark_sippai";
					this.bonus_icon = base.slot.textureBank.GetTexture("CM3D2_work_result_mark_sippai2");
					break;
				case ScheduleData.WorkSuccessLv.Success:
					this.successLvName = "CM3D2_work_result_mark_seikou";
					this.bonus_icon = base.slot.textureBank.GetTexture("CM3D2_work_result_mark_seikou2");
					break;
				case ScheduleData.WorkSuccessLv.Perfect:
					this.successLvName = "CM3D2_work_result_mark_daiseikou";
					this.bonus_icon = base.slot.textureBank.GetTexture("CM3D2_work_result_mark_daiseikou2");
					break;
				}
				if (this.communicationBonus)
				{
					this.bonus_icon = base.slot.textureBank.GetTexture("CM3D2_work_result_mark_commubonus");
				}
				this.successLv_icon = base.slot.textureBank.GetTexture(this.successLvName);
				this.commonSuccessLv = this.successLv;
			}
		}

		public Params uppedParamsWithoutCommunicationBonus;

		[Obsolete("Sry. This prm is obsolete. Plz use 'uppedParamsWithoutCommunicationBonus' and 'uppedParams' instead. frm F.", false)]
		public ScheduleAPI.TrainingResultSimulateParam simulateParams;

		public Texture2D bonus_icon;

		public bool maidLvCompletion;

		public bool maidLvMax;
	}
}
