Exemple #1
0
        /// <summary>
        /// Start a new round
        /// </summary>
        public void ContinueGame()
        {
            CurrentPlayer = players.IndexOf(GetCroupier()) + 1;
            foreach (Player player in Players)
            {
                if (player.IsCroupier)
                {
                    continue;
                }
                foreach (Card card in player.Hand)
                {
                    Discarded.Push(card);
                    card.Deck = Discarded;
                }
                player.Clear();
                GiveCard(Players.IndexOf(player), 2);
            }
            Player croupier = GetCroupier();

            foreach (Card card in croupier.Hand)
            {
                Discarded.Push(card);
                card.Deck = Discarded;
            }
            croupier.Clear();
            GiveCard(players.IndexOf(GetCroupier()));
        }
Exemple #2
0
        /// <summary>
        /// This code removes any exact duplicates from the medication list.
        /// These are unlikely to exist.
        /// </summary>
        private void RemoveExactDuplicates()
        {
            var newMedList = _medicationRule1Entries.Distinct().ToList();

            Discarded.AddRange(_medicationRule1Entries.Where(x => !newMedList.Contains(x)).Select(x => x.Element));

            _medicationRule1Entries = newMedList;
        }
Exemple #3
0
        /// <summary>
        /// In CCD 3 there is one section that has a mismatch on the name and original text.  The name is
        /// nexium and the original text is some sort of hormone replacment drug.
        /// </summary>
        private void RemoveInvalidEntries()
        {
            var newMedList = _medicationRule1Entries.Where(x => x.Name == x.OriginalText).ToList();

            Discarded.AddRange(_medicationRule1Entries.Where(x => !newMedList.Contains(x)).Select(x => x.Element));

            _medicationRule1Entries = newMedList;
        }
        /// <summary></summary>
        public override int GetHashCode()
        {
            var code = 13;

            // Calculate hash on each properties one by one
            code = (code * 7) + Id.GetHashCode();
            if (CreationTime != null)
            {
                code = (code * 7) + CreationTime.GetHashCode();
            }
            if (this.ActionTypeUrl != null)
            {
                code = (code * 7) + ActionTypeUrl.GetHashCode();
            }
            if (this.ActionType != null)
            {
                code = (code * 7) + ActionType.GetHashCode();
            }
            code = (code * 7) + Discarded.GetHashCode();
            if (this.StatusUrl != null)
            {
                code = (code * 7) + StatusUrl.GetHashCode();
            }
            if (this.Status != null)
            {
                code = (code * 7) + Status.GetHashCode();
            }
            if (this.ErrorString != null)
            {
                code = (code * 7) + ErrorString.GetHashCode();
            }
            if (this.User != null)
            {
                code = (code * 7) + User.GetHashCode();
            }
            if (this.ObjectUrl != null)
            {
                code = (code * 7) + ObjectUrl.GetHashCode();
            }
            if (this.AnnotationsUrl != null)
            {
                code = (code * 7) + AnnotationsUrl.GetHashCode();
            }
            if (this.Self != null)
            {
                code = (code * 7) + Self.GetHashCode();
            }
            return(code);
        }
Exemple #5
0
        /// <summary>
        /// This code uses the RXNORM code plus the provider to remove duplication
        /// </summary>
        private void RemoveDuplicatesByCodeAndProvider()
        {
            for (int i = _medicationRule1Entries.Count - 1; i > -1; i--)
            {
                if (_medicationRule1Entries.Count(x => x.Code == _medicationRule1Entries[i].Code &&
                                                  x.CodeSystem == _medicationRule1Entries[i].CodeSystem &&
                                                  x.Provider == _medicationRule1Entries[i].Provider) == 1 || _medicationRule1Entries[i].Code == "")
                {
                    continue;
                }

                var xcount = _medicationRule1Entries.Count(x => x.Code == _medicationRule1Entries[i].Code &&
                                                           x.CodeSystem == _medicationRule1Entries[i].CodeSystem &&
                                                           x.Provider == _medicationRule1Entries[i].Provider);

                Discarded.Add(_medicationRule1Entries[i].Element);
                _medicationRule1Entries.RemoveAt(i);
                medicationDedupCount++;// counting overall number of deduplation
            }
        }
Exemple #6
0
        /// <summary>
        /// Give a number of cards to a player
        /// </summary>
        /// <param name="playerId">Player that receives cards</param>
        /// <param name="count">Number of cards the player receives</param>
        private void GiveCard(int playerId, int count = 1)
        {
            if (MyDeck.Count < count)
            {
                throw new NotEnoughCardsException();
            }
            Player player = Players[playerId];

            for (int i = 0; i < count; i++)
            {
                if (player.Hand.Any(card => card.ToStringShort == MyDeck.Peek().ToStringShort) == false)
                {
                    Card card = myDeck.Pop();
                    player.AddCard(card);
                }
                else
                {
                    Card card = myDeck.Pop();
                    Discarded.Push(card);
                    card.Deck = Discarded;
                    GiveCard(playerId);
                }
            }
        }
Exemple #7
0
 public void Discard(Card card)
 {
     Hand.Remove(card);
     Discarded.Add(card);
 }