using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Wizard.Battle.View.Vfx;

namespace Wizard.Battle.Recovery;

public abstract class RecoveryNetworkManagerBase : IRecoveryManager
{
	protected readonly RecoveryOperationInfo _operationInfo;

	protected bool _needUpdate;

	private readonly Queue<string> _skillTargetNameQueue;

	protected Action StartRecoveryEvent;

	protected Action EndDataRecoveryEvent;

	protected Action EndRecoveryEvent;

	public DataMgr.BattleType BattleType => _operationInfo.BattleType;

	public bool? DidPlayerGoFirst => Data.BattleRecoveryInfo.first_turn == PlayerStaticData.UserViewerID;

	public int RandomSeed => Data.BattleRecoveryInfo.seed;

	public bool HasMulliganInfo => false;

	public int BackGroundId => Data.BattleRecoveryInfo.field_id;

	public string BgmId => "NONE";

	public long RecordTime => long.Parse(DateTime.Now.ToLongTimeString());

	public int IdxChangeSeed => Data.BattleRecoveryInfo.IdxChangeSeed;

	public static bool failedRecoveryFlag { get; private set; }

	public event Action OnStartRecovery
	{
		add
		{
			StartRecoveryEvent = (Action)Delegate.Combine(StartRecoveryEvent, value);
		}
		remove
		{
			StartRecoveryEvent = (Action)Delegate.Remove(StartRecoveryEvent, value);
		}
	}

	public event Action OnEndDataRecovery
	{
		add
		{
			EndDataRecoveryEvent = (Action)Delegate.Combine(EndDataRecoveryEvent, value);
		}
		remove
		{
			EndDataRecoveryEvent = (Action)Delegate.Remove(EndDataRecoveryEvent, value);
		}
	}

	public event Action OnEndRecovery
	{
		add
		{
			EndRecoveryEvent = (Action)Delegate.Combine(EndRecoveryEvent, value);
		}
		remove
		{
			EndRecoveryEvent = (Action)Delegate.Remove(EndRecoveryEvent, value);
		}
	}

	public RecoveryNetworkManagerBase()
	{
	}

	public void Setup()
	{
		DataMgr dataMgr = GameMgr.GetIns().GetDataMgr();
		dataMgr.SetPlayerCharaId(Data.BattleRecoveryInfo.chara_id);
		dataMgr.SetEnemyCharaId(Data.BattleRecoveryInfo.opponent_chara_id);
	}

	public abstract VfxBase Recovery(BattlePlayer battlePlayer, BattleEnemy battleEnemy, Func<IEnumerator, Coroutine> startCoroutine);

	public abstract VfxBase UpdateRecovery();

	public virtual void RecoveryBeforeMulligan()
	{
	}

	public virtual VfxBase RecoveryMulligan(BattlePlayer battlePlayer, BattleEnemy battleEnemy)
	{
		return NullVfx.GetInstance();
	}

	public virtual string RecoveryPopSkillTargetCardName()
	{
		return "";
	}
}
