/// <summary> /// Assigns random cards to the hands on the playing state that should be randomized. /// </summary> internal void Randomize() { for (int i = 0; i < mHandsToRandomize.Count; i++) { int handIndex = mHandsToRandomize[i]; HandState hand = mState.Hands[handIndex]; hand.Cards = 0; CardSet cardSet = mCardSets[i].Clone(); for (int j = 0; j < mCardCounts[i]; j++) { int card = cardSet.GetRandomCard(); // The following code handles a situation when there are two hands to distribute and the first hand // takes too many "shared" (available to both hands) cards so that the second hand might be left without // enough cards to select. I don't like the way it is currently handled but let it be for the time being. if ((mHandsToRandomize.Count == 2) && (i == 0) && (mCardSets[1].HasCard(card))) { if (mCardSets[1].Count == mCardCounts[1]) { // No more "shared" cards for the first hand. cardSet.RemoveCards(mCardSets[1].Cards); card = cardSet.GetRandomCard(); } else { mCardSets[1].RemoveCard(card); } } Debug.Assert(card != 0); cardSet.RemoveCard(card); hand.Cards |= card; } } // Make sure there are no intersections. Debug.Assert((mState.Hands[0].Cards & mState.Hands[1].Cards & mState.Hands[2].Cards) == 0); }
public override void RightClick() { _cardSet.RemoveCard(this); }