using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MegaCrit.Sts2.Core.Entities.CardRewardAlternatives;
using MegaCrit.Sts2.Core.Entities.Cards;
using MegaCrit.Sts2.Core.Models;
using MegaCrit.Sts2.Core.TestSupport;
namespace StS2Sim;
///
/// Card-select prompts (Armaments "pick a card to upgrade", Havoc "pick a card to play",
/// etc.) need a selector or they NRE. The game's normal selector talks to a UI;
/// for headless sims we just auto-pick the first maxSelect options
/// (or skip if minSelect == 0).
///
/// This is a "good enough" heuristic — it doesn't try to make optimal choices.
/// For decks with select-heavy cards we could swap in a smarter strategy later.
///
internal sealed class AutoCardSelector : ICardSelector
{
public Task> GetSelectedCards(IEnumerable options, int minSelect, int maxSelect)
{
var list = options.ToList();
var picked = list.Take(System.Math.Max(minSelect, System.Math.Min(maxSelect, list.Count))).ToList();
// Record the first picked card as the subject of the current play event (e.g. Nightmare → selected card).
if (picked.Count > 0)
PlayCapture.RecordEffectSubject(picked[0]);
return Task.FromResult>(picked);
}
public CardModel? GetSelectedCardReward(IReadOnlyList options, IReadOnlyList alternatives)
=> options.FirstOrDefault()?.Card;
}