예제 #1
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<Card> GetByIdAsync(this ICards operations, System.Guid id, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetByIdWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false))
     {
         return _result.Body;
     }
 }
예제 #2
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='code'>
 /// </param>
 /// <param name='number'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<Card> GetByCodeByNumberAsync(this ICards operations, string code, int number, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetByCodeByNumberWithHttpMessagesAsync(code, number, null, cancellationToken).ConfigureAwait(false))
     {
         return _result.Body;
     }
 }
예제 #3
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Card> GetRandomAsync(this ICards operations, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetRandomWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
예제 #4
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='page'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<CardList> GetAllAsync(this ICards operations, int? page = default(int?), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetAllWithHttpMessagesAsync(page, null, cancellationToken).ConfigureAwait(false))
     {
         return _result.Body;
     }
 }
예제 #5
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='exact'>
 /// </param>
 /// <param name='fuzzy'>
 /// </param>
 /// <param name='set'>
 /// </param>
 /// <param name='format'>
 /// </param>
 /// <param name='face'>
 /// </param>
 /// <param name='version'>
 /// </param>
 /// <param name='pretty'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<Card> GetNamedAsync(this ICards operations, string exact = default(string), string fuzzy = default(string), string set = default(string), string format = default(string), string face = default(string), string version = default(string), bool? pretty = default(bool?), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetNamedWithHttpMessagesAsync(exact, fuzzy, set, format, face, version, pretty, null, cancellationToken).ConfigureAwait(false))
     {
         return _result.Body;
     }
 }
예제 #6
0
        /// <summary>
        /// Copies the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        public static void Copy(ICards source, ICards target, CopyToProgress progressDelegate)
        {
            source.Parent.GetParentDictionary().Chapters.CopyTo(target.Parent.GetParentDictionary().Chapters, progressDelegate);

            CopyBase.Copy(source, target, typeof(ICards), progressDelegate);
            int counter = 0;
            int count   = source.Cards.Count - (CardIdsNotToCopy != null ? CardIdsNotToCopy.Count : 0);
            Dictionary <int, int> chapterMappings = target.Parent.GetParentDictionary().Parent.Properties[ParentProperty.ChapterMappings] as Dictionary <int, int>;

            foreach (ICard card in source.Cards)
            {
                if (CardIdsNotToCopy != null && CardIdsNotToCopy.Contains(card.Id))
                {
                    continue;
                }

                ++counter;
                if (progressDelegate != null && counter % 5 == 0)
                {
                    progressDelegate.Invoke(String.Format(Properties.Resources.CARDS_COPYTO_STATUS, counter, count), counter * 1.0 / count * 100);
                }

                ICard newCard = target.AddNew();
                card.CopyTo(newCard, progressDelegate);
                newCard.Chapter = chapterMappings[card.Chapter];
            }
        }
예제 #7
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='q'>
 /// </param>
 /// <param name='unique'>
 /// Possible values include: 'cards', 'art', 'prints'
 /// </param>
 /// <param name='order'>
 /// Possible values include: 'name', 'set', 'released', 'rarity', 'color',
 /// 'usd', 'tix', 'eur', 'cmc', 'power', 'toughness', 'edhrec', 'artist'
 /// </param>
 /// <param name='dir'>
 /// Possible values include: 'auto', 'asc', 'desc'
 /// </param>
 /// <param name='includeExtras'>
 /// </param>
 /// <param name='page'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<CardList> SearchAsync(this ICards operations, string q, UniqueStrategy? unique = default(UniqueStrategy?), SortOrder? order = default(SortOrder?), SortDirection? dir = default(SortDirection?), bool? includeExtras = default(bool?), int? page = default(int?), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.SearchWithHttpMessagesAsync(q, unique, order, dir, includeExtras, page, null, cancellationToken).ConfigureAwait(false))
     {
         return _result.Body;
     }
 }
예제 #8
0
파일: CardsTest.cs 프로젝트: pkb94/Cards
        public void TestCardExists()
        {
            mockICards.Setup(m => m.CheckCardExists(It.IsAny <int>(), It.IsAny <CardType>())).Returns(true);
            ICards crds = mockICards.Object;

            Assert.IsTrue(crds.CheckCardExists(3, CardType.Diamond));
        }
예제 #9
0
파일: CardsTest.cs 프로젝트: pkb94/Cards
        public void TestGetCards()
        {
            var crdsLst = new List <Card>()
            {
                new Card()
                {
                    cardType = CardType.Spade, id = "2Spade", num = 2
                },
                new Card()
                {
                    cardType = CardType.Heart, id = "7Heart", num = 7
                },
                new Card()
                {
                    cardType = CardType.Club, id = "8Club", num = 8
                },
                new Card()
                {
                    cardType = CardType.Diamond, id = "5Diamond", num = 5
                }
            };


            mockICards.Setup(m => m.GetCards(It.IsAny <int>())).Returns(crdsLst);
            ICards crds     = mockICards.Object;
            var    lstCards = crds.GetCards(4);

            Assert.IsNotNull(lstCards);
            Assert.AreEqual(lstCards.Count, 4);
        }
예제 #10
0
파일: CardsTest.cs 프로젝트: pkb94/Cards
        public void TestCardsShuffleFailure()
        {
            mockICards.Setup(m => m.ShuffleCards()).Returns(false);
            ICards crds = mockICards.Object;

            Assert.IsFalse(crds.ShuffleCards());
        }
예제 #11
0
파일: CardsTest.cs 프로젝트: pkb94/Cards
        public void TestCardsShuffleSuccess()
        {
            mockICards.Setup(m => m.ShuffleCards()).Returns(true);
            ICards crds = mockICards.Object;

            Assert.IsTrue(crds.ShuffleCards());
        }
예제 #12
0
파일: CardsTest.cs 프로젝트: pkb94/Cards
        public void TestCardNotExists()
        {
            mockICards.Setup(m => m.CheckCardExists(It.IsAny <int>(), It.IsAny <CardType>())).Returns(false);
            ICards crds = mockICards.Object;

            Assert.IsFalse(crds.CheckCardExists(4, CardType.Club));
        }
예제 #13
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='q'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<Catalog> AutocompleteAsync(this ICards operations, string q, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.AutocompleteWithHttpMessagesAsync(q, null, cancellationToken).ConfigureAwait(false))
     {
         return _result.Body;
     }
 }
예제 #14
0
파일: CardsTest.cs 프로젝트: pkb94/Cards
        public void TestInitialTopCardIndex()
        {
            mockICards.Setup(m => m.TopCard).Returns(0);
            ICards crds = mockICards.Object;

            Assert.AreEqual(crds.TopCard, 0);
        }
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PreviewDictionary"/> class.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <remarks>Documented by Dev03, 2009-03-23</remarks>
 public PreviewDictionary(IUser user)
 {
     parent = new ParentClass(user, this);
     cards = new PreviewCards(parent.GetChildParentClass(this));
     userSettings = new PreviewSettings(parent.GetChildParentClass(this));
     allowedSettings = new PreviewSettings(parent.GetChildParentClass(this));
     defaultSettings = new PreviewSettings(parent.GetChildParentClass(this));
     statistics = new PreviewStatistics();
 }
예제 #16
0
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='q'>
            /// </param>
            /// <param name='unique'>
            /// Possible values include: 'cards', 'art', 'prints'
            /// </param>
            /// <param name='order'>
            /// Possible values include: 'name', 'set', 'released', 'rarity', 'color',
            /// 'usd', 'tix', 'eur', 'cmc', 'power', 'toughness', 'edhrec', 'artist'
            /// </param>
            /// <param name='dir'>
            /// Possible values include: 'auto', 'asc', 'desc'
            /// </param>
            /// <param name='includeExtras'>
            /// </param>
            /// <param name='page'>
            /// </param>
            public static CardList Search(this ICards operations, string q, UniqueStrategy? unique = default(UniqueStrategy?), SortOrder? order = default(SortOrder?), SortDirection? dir = default(SortDirection?), bool? includeExtras = default(bool?), int? page = default(int?))
            {
				try {
				return operations.SearchAsync(q, unique, order, dir, includeExtras, page).GetAwaiter().GetResult();
				} catch {

				}
				return new CardList();
            }
예제 #17
0
파일: CardsTest.cs 프로젝트: pkb94/Cards
        public void TestGetTopCard()
        {
            var crd = new Card()
            {
                cardType = CardType.Spade, id = "2Spade", num = 2
            };

            mockICards.Setup(m => m.GetTopCard()).Returns(crd);
            ICards crds = mockICards.Object;

            Assert.AreEqual(crd, crds.GetTopCard());
        }
예제 #18
0
        private static void ReplaceCardsPositions <TCard>(this ICards <TCard> board, int card1Index, int card2Index)
            where TCard : class, ICard
        {
            //Card1
            int row1    = board.GetRow(card1Index);
            int column1 = board.GetColumn(card1Index);

            //card2
            int row2    = board.GetRow(card2Index);
            int column2 = board.GetColumn(card2Index);

            board.Replace(new Point(row1, column1), new Point(row2, column2));
        }
예제 #19
0
        internal static void MixCards <TCard>(this ICards <TCard> board, int times)
            where TCard : class, ICard
        {
            Random rand = new Random();

            do
            {
                int card1Index = rand.Next(0, board.NumOfCards);
                int card2Index = rand.Next(0, board.NumOfCards);

                board.ReplaceCardsPositions(card1Index, card2Index);
            } while (times-- > 0);
        }
예제 #20
0
        internal static void FillBoardAndMix <TCard>(this ICards <TCard> board, ICardBuilder <TCard> cardBuilder)
            where TCard : class, ICard
        {
            for (int cardNum = 0; cardNum < board.NumOfCards; cardNum++)
            {
                TCard[] cards = cardBuilder.GeneratePairCard();
                board.InsertCard(cards[0], board.GetRow(cardNum), board.GetColumn(cardNum));

                cardNum++;
                board.InsertCard(cards[1], board.GetRow(cardNum), board.GetColumn(cardNum));
            }

            board.MixCards(board.RemainCards);
        }
예제 #21
0
 public PlayStationController(ICards Cards) => this._Cards = Cards;
예제 #22
0
        /// <summary>
        /// Copies the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        public static void Copy(ICards source, ICards target, CopyToProgress progressDelegate)
        {
            source.Parent.GetParentDictionary().Chapters.CopyTo(target.Parent.GetParentDictionary().Chapters, progressDelegate);

            CopyBase.Copy(source, target, typeof(ICards), progressDelegate);
            int counter = 0;
            int count = source.Cards.Count - (CardIdsNotToCopy != null ? CardIdsNotToCopy.Count : 0);
            Dictionary<int, int> chapterMappings = target.Parent.GetParentDictionary().Parent.Properties[ParentProperty.ChapterMappings] as Dictionary<int, int>;
            foreach (ICard card in source.Cards)
            {
                if (CardIdsNotToCopy != null && CardIdsNotToCopy.Contains(card.Id))
                    continue;

                ++counter;
                if (progressDelegate != null && counter % 5 == 0)
                    progressDelegate.Invoke(String.Format(Properties.Resources.CARDS_COPYTO_STATUS, counter, count), counter * 1.0 / count * 100);

                ICard newCard = target.AddNew();
                card.CopyTo(newCard, progressDelegate);
                newCard.Chapter = chapterMappings[card.Chapter];
            }
        }
예제 #23
0
파일: CardDictionary.cs 프로젝트: hmehr/OSS
 /// <summary>
 /// Initializes a new instance of the <see cref="CardDictionary"/> class.
 /// </summary>
 /// <param name="cards">The cards.</param>
 /// <remarks>Documented by Dev05, 2007-09-03</remarks>
 public CardDictionary(Dictionary dict, ICards Cards)
 {
     dictionary = dict;
     this.cards = Cards;
 }
예제 #24
0
 public static bool IsNotEmptyOrVisible <TCard>(this ICards <TCard> board, int row, int column)
     where TCard : class, ICard
 {
     return(!(board[row, column] is null) && !board[row, column].IsValueVisible);
 }
예제 #25
0
 public static bool IsNotEmptyOrVisible <TCard>(this ICards <TCard> board, Point position)
     where TCard : class, ICard
 {
     return(board.IsNotEmptyOrVisible(position.X, position.Y));
 }
예제 #26
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// </param>
 public static Card GetById(this ICards operations, System.Guid id)
 {
     return operations.GetByIdAsync(id).GetAwaiter().GetResult();
 }
예제 #27
0
 public static int GetColumn <TCard>(this ICards <TCard> board, int cardNumber)
     where TCard : class, ICard
 {
     return(cardNumber % board.Columns);
 }
예제 #28
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='code'>
 /// </param>
 /// <param name='number'>
 /// </param>
 public static Card GetByCodeByNumber(this ICards operations, string code, int number)
 {
     return operations.GetByCodeByNumberAsync(code, number).GetAwaiter().GetResult();
 }
예제 #29
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// </param>
 public static Card GetByArenaId(this ICards operations, int id)
 {
     return operations.GetByArenaIdAsync(id).GetAwaiter().GetResult();
 }
예제 #30
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='page'>
 /// </param>
 public static CardList GetAll(this ICards operations, int? page = default(int?))
 {
     return operations.GetAllAsync(page).GetAwaiter().GetResult();
 }
예제 #31
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 public static Card GetRandom(this ICards operations)
 {
     return operations.GetRandomAsync().GetAwaiter().GetResult();
 }
예제 #32
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='q'>
 /// </param>
 public static Catalog Autocomplete(this ICards operations, string q)
 {
     return operations.AutocompleteAsync(q).GetAwaiter().GetResult();
 }
예제 #33
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='exact'>
 /// </param>
 /// <param name='fuzzy'>
 /// </param>
 /// <param name='set'>
 /// </param>
 /// <param name='format'>
 /// </param>
 /// <param name='face'>
 /// </param>
 /// <param name='version'>
 /// </param>
 /// <param name='pretty'>
 /// </param>
 public static Card GetNamed(this ICards operations, string exact = default(string), string fuzzy = default(string), string set = default(string), string format = default(string), string face = default(string), string version = default(string), bool? pretty = default(bool?))
 {
     return operations.GetNamedAsync(exact, fuzzy, set, format, face, version, pretty).GetAwaiter().GetResult();
 }