public List <CardRank> CheckFourCards() { var numCardsWithRank = new int[(int)CardRank.Ace + 1]; foreach (var card in cards) { numCardsWithRank[(int)card.rank] += 1; } var hasAllFourOfRank = new List <CardRank>(); for (var rank = CardRank.Two; rank <= CardRank.Ace; ++rank) { if (numCardsWithRank[(int)rank] == 4) { hasAllFourOfRank.Add(rank); } } negativePoints += hasAllFourOfRank.Count; cards.RemoveAll(x => hasAllFourOfRank.Contains(x.rank)); try { controller.HasFourOf(hasAllFourOfRank); } catch (Exception e) { throw new PlayerException( myId, e, "Player code cause exception" + e.GetType().ToString() + ": " + e.Message ); } return(hasAllFourOfRank); }