Exemple #1
0
        public Card Shuffle(string id)
        {
            Card card = null;

            if (id != null)
            {
                try
                {
                    card = CardRepository.GetCardAndUpdateLastUse(id);
                    if (card != null)
                    {
                        card.Shuffle();
                        CardRepository.SaveCardAndUpdateLastUse(id, card);
                    }
                }
                catch (Exception e)
                {
                    logger.Error("Error at Shuffling deck");
                    logger.Debug($"Error message {e.Message}");
                }
            }
            else
            {
                logger.Error("Invalid parameters.");
                logger.Debug($"Id: {id}");
            }
            return(card);
        }
Exemple #2
0
        public Card Cut(string id, int offset)
        {
            Card card = null;

            if (id != null && offset >= 0 && offset < Card.NumberOfCardsInDeck)
            {
                try
                {
                    card = CardRepository.GetCardAndUpdateLastUse(id);
                    if (card != null)
                    {
                        card.Cut(offset);
                        CardRepository.SaveCardAndUpdateLastUse(id, card);
                    }
                }
                catch (Exception e)
                {
                    logger.Error("Error at Cutting deck");
                    logger.Debug($"Error message {e.Message}");
                }
            }
            else
            {
                logger.Error("Invalid parameters.");
                logger.Debug($"Id: {id}, Offset: {offset}");
            }
            return(card);
        }
Exemple #3
0
        public Card Create()
        {
            Card card = null;

            try
            {
                card = CardRepository.GetCardAndUpdateLastUse();
            }
            catch (Exception e)
            {
                logger.Error("Error at Creating deck");
                logger.Debug($"Error message {e.Message}");
            }
            return(card);
        }