예제 #1
0
 private static string DetailedMessage(string message, byte card, CardLocations location)
 {
     return(message + "\nCard ID: " + card.ToString() + "\nLocation: " + location.ToString());
 }
예제 #2
0
            /// <summary>
            /// Handy little method that matches ambiguous cards with their full local representation, as well as determines if
            /// such an association exists. If encountering a problem, will throw errors, expect to handle them by providing location.
            /// </summary>
            private static List <byte> GetCorrespondingCards(List <byte> expectedCards, List <byte> evaluatingDeck, CardLocations location = CardLocations.UNKNOWN)
            {
                //TODO: check for duplicates - so that, for example "44" doesn't result in an error for a deck with only 4h and 4s
                List <byte> modifiableDeck = new List <byte>(evaluatingDeck); //temp deck
                List <byte> updatedCards   = new List <byte>();               //includes filled out suits

                foreach (byte card in expectedCards)
                {
                    try {
                        byte modifiedCard = 0;
                        if (!CardHasASuit(card))
                        {
                            modifiedCard = GetCardByValue(card, modifiableDeck);
                            updatedCards.Add(modifiedCard); //solves ambiguity
                        }
                        else
                        {
                            if (modifiableDeck.Contains(card))
                            {
                                modifiedCard = card;
                                updatedCards.Add(card);
                            }
                            else
                            {
                                throw new CardNotPresentException();
                            }
                        }
                        modifiableDeck.Remove(modifiedCard);
                    } catch (CardNotPresentException cnp) {
                        throw new CardNotPresentException("Card is not present in " + location.ToString(), cnp, card, location);
                    } catch (AmbiguousCardException ac) {
                        throw new AmbiguousCardException("Card is ambiguous and can refer to several cards in " + location.ToString(), ac, card, location);
                    } catch {
                        throw;
                    }
                }
                return(updatedCards);
            }