AIsOfCatan.StarterAgent.DiscardCards C# (CSharp) Метод

DiscardCards() публичный Метод

public DiscardCards ( IGameState state, int toDiscard ) : Resource[]
state IGameState
toDiscard int
Результат Resource[]
        public Resource[] DiscardCards(IGameState state, int toDiscard)
        {
            if (!silent)
                Console.WriteLine(id + ": Choosing cards to discard");

            List<Resource> chosenDiscard = new List<Resource>(toDiscard);
            List<Resource> hand = state.GetOwnResources().ToList();

            while (chosenDiscard.Count < toDiscard)
            {
                // pick one of the type we have most of
                Resource pick = hand.OrderByDescending(r => hand.Count(c => c == r)).First();
                chosenDiscard.Add(pick);
                hand.Remove(pick);
            }

            return chosenDiscard.ToArray();
        }