using System.Collections.Generic;
using System.Linq;

namespace Wizard.DeckSelect.FirstDisplayPageIndexGetter;

public abstract class FirstDisplayPageIndexGetterBase : IFirstDisplayPageIndexGetter
{
	public int Get(List<DeckSelectUI.PageData> pageList, Format viewFormat, DeckData primaryDisplayDeck, bool canUseNonPossessionCard)
	{
		if (primaryDisplayDeck != null)
		{
			int num = pageList.FindIndex((DeckSelectUI.PageData page) => page.DeckViewList.FirstOrDefault((DeckUI.DeckViewData deck) => deck.Deck == primaryDisplayDeck) != null);
			if (num >= 0)
			{
				return num;
			}
		}
		return DerivedGet(pageList, viewFormat, canUseNonPossessionCard);
	}

	protected abstract int DerivedGet(List<DeckSelectUI.PageData> pageList, Format viewFormat, bool canUseNonPossessionCard);
}
