public void TestAlternatingColors( )
		{
			CardCollection coll = new CardCollection( );

			// An empty one is also alternating:
			Assert.AreEqual( coll.IsAlternatingColors( ), true );
			coll.Add( new Card( Suit.Clubs, 10, true, null ) );

			// So is a collection of only one element:
			Assert.AreEqual( coll.IsAlternatingColors( ), true );

			// Then, add a few cards of alternating colors:
			coll.Add( new Card( Suit.Diamonds, 11, true, null ) );
			coll.Add( new Card( Suit.Clubs, 7, true, null ) );
			coll.Add( new Card( Suit.Diamonds, 11, true, null ) );
			coll.Add( new Card( Suit.Spades, 7, true, null ) );
			coll.Add( new Card( Suit.Hearts, 11, true, null ) );
			coll.Add( new Card( Suit.Clubs, 7, true, null ) );

			// This should hold:
			Assert.AreEqual( coll.IsAlternatingColors( ), true );

			// Finally, remove a card in the middle:

			coll.RemoveAt( 2 );

			// ... which should make it no longer alternating:
			Assert.AreEqual( coll.IsAlternatingColors( ), false );
		}
        public ICollection<Card> GetOpponentCards(ICollection<Card> myCards, ICollection<Card> playedCards, Card activeTrumpCard, CardSuit suit)
        {
            var playerCards = new CardCollection
                                  {
                                      new Card(suit, CardType.Nine),
                                      new Card(suit, CardType.Jack),
                                      new Card(suit, CardType.Queen),
                                      new Card(suit, CardType.King),
                                      new Card(suit, CardType.Ten),
                                      new Card(suit, CardType.Ace),
                                  };

            foreach (var card in myCards.Where(x => x.Suit == suit))
            {
                playerCards.Remove(card);
            }

            foreach (var card in playedCards.Where(x => x.Suit == suit))
            {
                playerCards.Remove(card);
            }

            if (activeTrumpCard != null)
            {
                playerCards.Remove(activeTrumpCard);
            }

            return playerCards;
        }
        public void Test_DetermineWinners_FullHouse_TwoWinners()
        {
            Player winner1 = new Player("Winner1", 1000);
            winner1.Cards.Add(new Card(Rank.Two, Suit.Spades));
            winner1.Cards.Add(new Card(Rank.Two, Suit.Hearts));

            Player winner2 = new Player("Winner2", 1000);
            winner2.Cards.Add(new Card(Rank.Two, Suit.Diamonds));
            winner2.Cards.Add(new Card(Rank.Two, Suit.Clubs));

            CardCollection communityCards = new CardCollection();
            communityCards.Add(new Card(Rank.Three, Suit.Hearts));
            communityCards.Add(new Card(Rank.Six, Suit.Clubs));
            communityCards.Add(new Card(Rank.King, Suit.Hearts));
            communityCards.Add(new Card(Rank.King, Suit.Spades));
            communityCards.Add(new Card(Rank.King, Suit.Diamonds));

            HandEvaluator eval = new HandEvaluator();

            Hand hand1 = eval.GetBestHand(winner1.Cards + communityCards);

            Hand hand2 = eval.GetBestHand(winner2.Cards + communityCards);

            Assert.AreEqual(0, HandEvaluator.Compare(hand1, hand2));
        }
Beispiel #4
0
 internal static CardBehaviour CheckCardExistence(CardCollection cardType, GameObject player, GameObject systemObject)
 {
     if (player != null)
     {
         if(systemObject != null)
         {
             var cardBehaviour = CardObjectList.Find(x => x.CardType == cardType && x.Player == player && x.System == systemObject);
             return cardBehaviour;
         }
         else
         {
             var cardBehaviour = CardObjectList.Find(x => x.CardType == cardType && x.Player == player);
             return cardBehaviour;
         }
     }
     else
     {
         if (systemObject != null)
         {
             var cardBehaviour = CardObjectList.Find(x => x.CardType == cardType && x.System == systemObject);
             return cardBehaviour;
         }
         else
         {
             var cardBehaviour = CardObjectList.Find(x => x.CardType == cardType);
             return cardBehaviour;
         }
     }
 }
        public void CardCollection_AdditionTest()
        {
            CardCollection left = new CardCollection();

            ColorettoCard card1 = new ColorettoCard(ColorettoCardColors.Blue);
            ColorettoCard card2 = new ColorettoCard(ColorettoCardColors.Brown);
            ColorettoCard card3 = new ColorettoCard(ColorettoCardColors.Gray);

            left = left.Add(card1);
            left = left.Add(card2);
            left = left.Add(card3);

            CardCollection right = new CardCollection();

            card1 = new ColorettoCard(ColorettoCardColors.Blue);
            card2 = new ColorettoCard(ColorettoCardColors.Brown);
            card3 = new ColorettoCard(ColorettoCardColors.Gray);

            right = right.Add(card1);
            right = right.Add(card2);
            right = right.Add(card3);

            CardCollection added = left + right;
            Assert.AreEqual<int>(6, added.Count);
            Assert.AreEqual<int>(9, added.Score);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpResponse<string> response = Unirest.get("https://omgvamp-hearthstone-v1.p.mashape.com/cards?collectible=1")
        .header("X-Mashape-Key", "Y6G2Ve8iAOmshQFq4sGVgvBtI1HVp1CVLrWjsnPikTu4oqy2EK")
        .asJson<string>();

        CardCollection collection = new CardCollection();
        collection = JsonConvert.DeserializeObject<CardCollection>(response.Body);

        List<Card> cards = new List<Card>();
        cards.AddRange(collection.basic);
        cards.AddRange(collection.classic);
        cards.AddRange(collection.naxxramas);
        cards.AddRange(collection.gvg);
        cards.AddRange(collection.blackrock);
        cards.AddRange(collection.grandTournament);
        cards.AddRange(collection.leagueOfExplorers);

        DataAccessLayer layer1 = new DataAccessLayer();

        try
        {
            layer1.InsertCardsToDb(cards);
        }
        catch (Exception)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('Kortit jo kannassa');", true);
        }

        //Grid.DataSource = cards as IEnumerable<Card>;
        Grid.DataSource = cards as IEnumerable<Card>;
        Grid.DataBind();
    }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="pt"></param>
		/// <returns></returns>
		public override CardCollection GetCardsToDrag( Point pt )
		{
			// Loop backwards through all cards in this collection
			// and when we find a card that fits the bill, we return
			// that card and all cards on top of that card.
			// Also note that we don't allow dragging cards which are
			// face down.

			int i = base.Count - 1; 

			for ( ; i >= 0; i-- )
			{
				Card c = base.m_cards[ i ];
				if ( c.Contains( pt ) && c.FaceUp )
				{
					break;
				}
			}

			if ( i != -1 )
			{
				CardCollection cards = new CardCollection( );
				cards.AddRange( base.m_cards.GetRange( i, base.Count - i ) );
				return cards;
			}
			return null;
		}
Beispiel #8
0
 public Player(string name, double chips, PlayerState state, string gatewayServerId)
 {
     Name = name;
     Chips = chips;
     State = state;
     GatewayServerId = gatewayServerId;
     Cards = new CardCollection();
 }
Beispiel #9
0
 public CardCollection getAllCards()
 {
     CardCollection allCards = new CardCollection ();
     allCards.addList (hand.getCards());
     allCards.addList (deck.getCards ());
     allCards.addList (discardPile.getCards ());
     return allCards;
 }
        public void AddTest()
        {
            var cc = new CardCollection();

            cc.Add(new Card("TEST1", "Test1"));
            cc.Add("TEST2", new Card("TEST2", "Test2"));

            // Test add with existing keyword
        }
Beispiel #11
0
 public Hand(CardCollection cards, Combination HandType)
     : base(cards)
 {
     if (cards == null || cards.Count <= 0)
         throw new InvalidOperationException("You cannot add an empty collection of cards to a hand.");
     m_cmbBestCombination = HandType;
     base.Sort();
     m_cdHighCard = base[base.Count - 1];
 }
 public void CopyToShouldWorkProperly()
 {
     var card1 = new Card(CardSuit.Club, CardType.Ace); // 1
     var card2 = new Card(CardSuit.Spade, CardType.King); // 52
     var collection = new CardCollection { card1, card2 };
     var array = new Card[2];
     collection.CopyTo(array, 0);
     Assert.IsTrue(array.Contains(card1));
     Assert.IsTrue(array.Contains(card2));
 }
Beispiel #13
0
 public static CardCollection CreateEnemyCollection()
 {
     // Create enemy deck collection and return
     CardCollection enemyDeck = new CardCollection();
     foreach (string c in EnemyDeck1)
     {
         enemyDeck.Add(CardData.CreateCardFromName(c));
     }
     return enemyDeck;
 }
Beispiel #14
0
		/// <summary>
		/// SuitPile overrides the default behaviour of AddCards, since there are 
		/// restrictions to what kind of cards can be added where. 
		/// </summary>
		/// <param name="cards"></param>
		/// <returns></returns>
		public override bool AddCards( CardCollection cards )
		{
			if ( cards.Count > 0
				&& CanAddCard( cards[ 0 ] )
				&& cards.IsAscendingRank( ) )
			{
				return base.AddCards( cards );
			}

			return false;
		}
Beispiel #15
0
        public static CardCollection operator +(Card c1, Card c2)
        {
            CardCollection summCollection = new CardCollection();

            if (c1 != null)
                summCollection.Add(c1);

            if (c2 != null)
                summCollection.Add(c2);

            return summCollection;
        }
Beispiel #16
0
		private void OnDoubleClick( object sender, MouseEventArgs e )
		{
			if ( m_controller != null )
			{
				// Point pt = new Point( e.X, e.Y );
				m_controller.DoubleClick( e.Location );

				// Ensure that the MouseUp event won't interfere with this one:
				m_draggedCards = null;

				this.Invalidate( );
			}
		}
Beispiel #17
0
    /* Builds a deck given the types and their respective quantities in the array arguments.
     * NOTE: types and weights MUST be of the same length!
     * Also, there should be no null values in types and weights should contain no nonpositive values either! */
    public DeckManager(CardScript.CardType[] types, int[] weights)
    {
        deck = new CardCollection ();
        // Adds a number of each card type equal to their respective weights
        for (int idx = 0; idx < types.Length; ++idx) {
            for (int qty = 0; qty < weights[idx]; ++qty) {
                deck.add(new CardScript(types[idx]));
            }
        }

        hand = new CardCollection();
        discardPile = new CardCollection();
    }
Beispiel #18
0
		private Choice(String text, Card cardSource, CardCollection cardTriggers, ChoiceType choiceType, Player playerSource, EventArgs eventArgs, Boolean isOrdered, Boolean isSpecific, int minimum, int maximum)
		{
			_Text = text;
			_CardSource = cardSource;
			_CardTriggers = cardTriggers;
			_ChoiceType = choiceType;
			_PlayerSource = playerSource;
			_EventArgs = eventArgs;
			_IsOrdered = isOrdered;
			_IsSpecific = isSpecific;
			_Minimum = minimum < 0 ? 0 : minimum;
			_Maximum = maximum < _Minimum ? _Minimum : maximum;
		}
Beispiel #19
0
		public override bool AddCards( CardCollection cards )
		{
			foreach ( Card c in cards )
			{
				base.m_cards.Add( c );

				// First card should be placed exactly where the pile is located,
				// but next cards should be lowered accordingly
				c.Location = TranslatePoint( this.Location );
			}

			return true;
		}
 public void ClearShouldReturn0Cards()
 {
     var collection = new CardCollection
                          {
                              new Card(CardSuit.Club, CardType.Ace),
                              new Card(CardSuit.Diamond, CardType.Ten),
                              new Card(CardSuit.Heart, CardType.Jack),
                              new Card(CardSuit.Spade, CardType.Nine)
                          };
     collection.Clear();
     Assert.AreEqual(0, collection.Count);
     Assert.AreEqual(0, collection.ToList().Count);
 }
        internal static CardCollection BitsToCardCollection(int source)
        {
            var result = new CardCollection();

            for (int i = 0; i < 32; i++)
            {
                int card = (1 << i);
                if ((source & card) != 0)
                    result.Add(BitsToCard(card));
            }

            return result;
        }
		public void TestUpdateLocation( )
		{
			CardCollection coll = new CardCollection( );

			coll.Add( new Card( Suit.Clubs, 10, true, null ) );
			coll.Add( new Card( Suit.Diamonds, 11, true, null ) );
			coll.Add( new Card( Suit.Diamonds, 7, true, null ) );

			coll.UpdateLocation( 10, 7 );

			// This test does in fact rely on the fact that a card
			// will by default initialize its location to 0,0. 
			Assert.AreEqual( coll[ 0 ].Location.X, 10 );
		}
        public bool IsStraight(Hand hand)
        {
            CardCollection cards = new CardCollection(hand.OrderBy(c => c.Rank.Value));

            for (int i = 0; i < cards.Count; ++i)
            {
                if (cards.Count > i)
                {
                    if ((cards[i].Rank.Value + 1) != cards[i + 1].Rank.Value)
                        return false;
                }
            }

            return true;
        }
        public void CardCollection_AddTest()
        {
            CardCollection target = new CardCollection();

            ColorettoCard card1 = new ColorettoCard(ColorettoCardColors.Blue);
            ColorettoCard card2 = new ColorettoCard(ColorettoCardColors.Brown);
            ColorettoCard card3 = new ColorettoCard(ColorettoCardColors.Gray);

            target = target.Add(card1);
            target = target.Add(card2);
            target = target.Add(card3);

            Assert.AreEqual<ColorettoCard>(card1, target[0]);
            Assert.AreEqual<ColorettoCard>(card2, target[1]);
            Assert.AreEqual<ColorettoCard>(card3, target[2]);
        }
 public void CloneShouldReturnExactSameCollectionOfCards()
 {
     var collection = new CardCollection
                          {
                              new Card(CardSuit.Club, CardType.Ace), // 1
                              new Card(CardSuit.Spade, CardType.King), // 52
                              new Card(CardSuit.Heart, CardType.Ten),
                              new Card(CardSuit.Diamond, CardType.Queen),
                              new Card(CardSuit.Club, CardType.Jack),
                              new Card(CardSuit.Heart, CardType.Nine),
                          };
     var clonedCollection = collection.DeepClone();
     Assert.IsNotNull(clonedCollection);
     Assert.AreEqual(collection.Count, clonedCollection.Count);
     foreach (var card in clonedCollection)
     {
         Assert.IsTrue(collection.Contains(card));
     }
 }
        public void ContainsShouldReturnTrueForAllCardsAfterAddingThem()
        {
            var collection = new CardCollection();
            foreach (CardSuit cardSuitValue in Enum.GetValues(typeof(CardSuit)))
            {
                foreach (CardType cardTypeValue in Enum.GetValues(typeof(CardType)))
                {
                    var card = new Card(cardSuitValue, cardTypeValue);
                    collection.Add(card);
                }
            }

            foreach (CardSuit cardSuitValue in Enum.GetValues(typeof(CardSuit)))
            {
                foreach (CardType cardTypeValue in Enum.GetValues(typeof(CardType)))
                {
                    var card = new Card(cardSuitValue, cardTypeValue);
                    Assert.IsTrue(collection.Contains(card));
                }
            }
        }
Beispiel #27
0
		/// <summary>
		/// Override this to ensure we don't add cards to the pile 
		/// which are not allowed there.
		/// </summary>
		/// <param name="cards"></param>
		/// <returns></returns>
		public override bool AddCards( CardCollection cards )
		{
			if ( cards.Count > 0 )
			{
				if ( base.Count == 0 )
				{
					// If there are currently no cards in this pile,
					// we only allow adding a collection of cards
					// that starts with a king:
					if ( cards[ 0 ].Rank != 13 )
					{
						return false;
					}
				}
				else
				{
					// Otherwise, if there are cards on this pile,
					// only allow a collection of cards to be added
					// if the first card there has rank one lower
					// than our topmost card (6 can go on 7 etc.)
					if ( base.TopCard.Rank != cards[0].Rank + 1 )
					{
						return false;
					}

					// Also, the cards must not both be red/black:
					if ( !base.TopCard.IsOppositeColor( cards[ 0 ] ) )
					{
						return false;
					}
				}

				// And now to the final condition:
				if ( cards.IsAlternatingColors( ) )
				{
					return base.AddCards( cards );
				}
			}
			return false;
		}
 protected void Page_Load(object sender, EventArgs e)
 {
     CardCollection cardColl = new CardCollection();
     cardColl = cardBUS.RandomCardList(cardBUS.GetCardList(-1), 12);
     int piccount = cardColl.Count;
     if (piccount >= 1) LoadImage(CardImage0, cardColl.Index(0));
     if (piccount >= 2) LoadImage(CardImage1, cardColl.Index(1));
     if (piccount >= 3) LoadImage(CardImage2, cardColl.Index(2));
     if (piccount >= 4) LoadImage(CardImage3, cardColl.Index(3));
     if (piccount >= 5) LoadImage(CardImage4, cardColl.Index(4));
     if (piccount >= 6) LoadImage(CardImage5, cardColl.Index(5));
     if (!IsPostBack)
     {
         LoadGiftCard();           
     }
     //reload CartGridView
     //get Cart(MerchantIDList) from Session
     List<string> cart = new List<string>();
     cart = (List<string>)Session["Cart"];
     LoadShoppingCart(cart);
     CartLink.Text = "Shopping Cart (" + (((List<string>)(Session["Cart"])).Count - 1).ToString() + ")";
 }
Beispiel #29
0
        public CardCollection Retrieve(Player player, Type cardMatType, Predicate <Card> match, int count)
        {
            CardMat c = null;

            if (this.ContainsKey(cardMatType))
            {
                c = this[cardMatType];
            }
            else
            {
                c = CardMat.CreateInstance(cardMatType);
            }

            CardCollection cc = c.Retrieve(player, DeckPosition.Automatic, match, count);

            if (CardMatsChanged != null)
            {
                CardMatsChangedEventArgs pcea = new CardMatsChangedEventArgs(this[cardMatType], player, CardMatsChangedEventArgs.Operation.Removed, cc);
                CardMatsChanged(this, pcea);
            }

            return(cc);
        }
        // POST api/values
        public IHttpActionResult PostCardCollection([FromBody] CardCollection cardCollection)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var board = _context.Boards.Find(cardCollection.BoardId);

            if (board == null)
            {
                return(NotFound());
            }
            if (!AuthorizationHandler.PasswordMatched(board.Password, Request))
            {
                return(Unauthorized());
            }

            _context.CardCollections.Add(cardCollection);
            _context.SaveChanges();

            return(Ok(cardCollection));
        }
Beispiel #31
0
        public void InternalEnumeratorResetMethodShouldAllowNewEnumerating()
        {
            var collection = new CardCollection
            {
                new Card(CardSuit.Club, CardType.Ace),                      // 1
                new Card(CardSuit.Spade, CardType.King)                     // 52
            };
            var enumerator = collection.GetEnumerator();

            while (enumerator.MoveNext())
            {
            }

            enumerator.Reset();
            var count = 0;

            while (enumerator.MoveNext())
            {
                count++;
            }

            Assert.AreEqual(collection.Count, count);
        }
Beispiel #32
0
        public void DefenderCards_Can_Beat_AttackerCards_With_Trump()
        {
            var attackerCards = new CardCollection <BuraCard>();
            var defenderCards = new CardCollection <BuraCard>();

            attackerCards.Add(new BuraCard(CardSuit.Clubs, CardName.Seven));
            attackerCards.Add(new BuraCard(CardSuit.Clubs, CardName.Queen));
            attackerCards.Add(new BuraCard(CardSuit.Clubs, CardName.Eight));

            defenderCards.Add(new BuraCard(CardSuit.Hearts, CardName.Six));
            defenderCards[0].Trump = true;
            defenderCards.Add(new BuraCard(CardSuit.Clubs, CardName.Ten));
            defenderCards.Add(new BuraCard(CardSuit.Clubs, CardName.Nine));

            var strategy = new BuraDefenseStrategy();

            var tricks = strategy.Execute(attackerCards, defenderCards);

            foreach (var trick in tricks)
            {
                Assert.True(trick.Completed);
            }
        }
        /// <summary>
        /// 初始化卡号(新增)
        /// </summary>
        private void InitializeDropIncomeCardNumber()
        {
            CardCollection      cardcoll = new CardCollection();
            List <QueryElement> list     = new List <QueryElement>();

            cardcoll = CardMethods.GetCard(list);
            List <DropItem> card = new List <DropItem>();

            card.Add(new DropItem {
                ValueField = "", DisplayField = " "
            });

            for (int i = 0; i < cardcoll.Count; i++)
            {
                CardInfo cardInfo = cardcoll[i];
                string   bank     = StaticRescourse.DisplayBank(cardInfo.BankId);
                card.Add(new DropItem {
                    ValueField = cardInfo.Id.ToString(), DisplayField = cardInfo.CardNumber + " " + bank
                });                                                                                                        // +" "+bank
            }
            this.dropIncomeAddCardNumber.DataSource = card;
            Helper.SetDropDownList(this.dropIncomeAddCardNumber);
            this.dropIncomeAddCardNumber.SelectedValue = string.Empty;
        }
Beispiel #34
0
 public IFFFile()
 {
     FileName            = "data/pangya_gb.iff";
     Part                = new PartCollection();
     Card                = new CardCollection();
     Caddie              = new CaddieCollection();
     Item                = new ItemCollection();
     LevelUpPrizeItem    = new LevelUpPrizeItemCollection();
     Character           = new CharacterCollection();
     Ball                = new BallCollection();
     Ability             = new AbilityCollection();
     Skin                = new SkinCollection();
     CaddieItem          = new CaddieItemCollection();
     Club                = new ClubCollection();
     ClubSet             = new ClubSetCollection();
     Course              = new CourseCollection();
     CutinInformation    = new CutinInformationCollection();
     Desc                = new DescCollection();
     Furniture           = new FurnitureCollection();
     FurnitureAbility    = new FurnitureAbilityCollection();
     Mascot              = new MascotCollection();
     TikiSpecialTable    = new TikiSpecialTableCollection();
     TikiRecipe          = new TikiRecipeCollection();
     TikiPointTable      = new TikiPointTableCollection();
     CadieMagicBox       = new CadieMagicBoxCollection();
     CadieMagicBoxRandom = new CadieMagicBoxRandomCollection();
     HairStyle           = new HairStyleCollection();
     Match               = new MatchCollection();
     SetItem             = new SetItemCollection();
     Enchant             = new EnchantCollection();
     Achievement         = new AchievementCollection();
     QuestStuff          = new QuestStuffCollection();
     QuestItem           = new QuestItemCollection();
     SetEffectTable      = new SetEffectTableCollection();
     AuxPart             = new AuxPartCollection();
 }
        public ActionResult AddCardToDeck(int idcard)
        {
            CardCollections cc = new CardCollections();

            cc = (CardCollections)TempData["CardCollection"];

            int index = cc.coll.FindIndex(i => i.IdCard == idcard);

            CardCollection card = cc.coll[index];

            if (cc.coll[index].Number > 0)
            {
                cc.coll[index].Number -= 1;
                cc.deck.Add(card);
            }
            else
            {
                TempData["notEnoughCards"] = $"You do not have a '{cc.coll[index].Cardname}' card anymore";
            }

            ViewBag.Deckcount          = cc.deck.Count();
            TempData["CardCollection"] = cc;
            return(View("Deckbuilder", cc));
        }
Beispiel #36
0
        public static Settings Load()
        {
            CardCollection allCards = CardCollection.GetAllCards(c => true);

            Settings settings = null;

            try
            {
                XmlSerializer mySerializer = new XmlSerializer(typeof(Settings), GetAllSerializingTypes(allCards).ToArray());
                // This should only need to be here temporarily -- probably 3-5 releases -- until all the other versions get transitioned to the new saving area
                String filename = Settings.Filename;
                if (!System.IO.File.Exists(Settings.Filename))
                {
                    filename = Settings.OldFilename;
                }
                using (FileStream myFileStream = new FileStream(filename, FileMode.Open))
                {
                    settings = (Settings)mySerializer.Deserialize(myFileStream);
                }
            }
            catch
            {
                settings = new Settings();
            }

            while (settings.PlayerSettings.Count < 6)
            {
                settings.PlayerSettings.Add(new PlayerSettings()
                {
                    Name        = String.Format("Player {0}", settings.PlayerSettings.Count + 1),
                    AIClassType = typeof(DominionBase.Players.AI.Standard),
                    UIColor     = HLSColor.HlsToRgb(24 * (settings.PlayerSettings.Count * 2), 0.85, 1, 1)
                });
            }


            // Go through each card to make sure that the card's default settings are defined
            foreach (Card card in allCards)
            {
                CardSettingCollection csc = card.GenerateSettings();
                if (csc.Count == 0)                 // This card has no custom settings, so we can skip it
                {
                    continue;
                }

                if (!settings.CardSettings.ContainsKey(card.Name))
                {
                    settings.CardSettings[card.Name] = new CardsSettings(card.Name);
                }

                CardsSettings cardSettings = settings.CardSettings[card.Name];

                // Go through each setting defined for the card & make sure it exists
                foreach (CardSetting cSetting in csc)
                {
                    if (!cardSettings.CardSettingCollection.ContainsKey(cSetting.GetType()))
                    {
                        cardSettings.CardSettingCollection[cSetting.GetType()] = cSetting;
                    }
                }

                card.FinalizeSettings(cardSettings.CardSettingCollection);
            }

            return(settings);
        }
 private void Awake()
 {
     _collection     = GetComponent <CardCollection>();
     _handAnimations = GetComponent <HandAnimations>();
     _cardObjects    = GetComponentsInChildren <CardObject>();
 }
Beispiel #38
0
 public CardEnumerator(CardCollection cards)
 {
     _cards  = cards;
     curIdx  = -1;
     curCard = default(Hanafuda);
 }
Beispiel #39
0
    public UnitData GetCardById(int id, bool isWarrior = false)
    {
        CardCollection collection = isWarrior ? m_Warriors : m_Spirits;

        return(collection.m_CardList[id]);
    }
Beispiel #40
0
        private void ProcessRecognition()
        {
            for (int i = 0; i <= 2; i++)
            {
                if (counter3 == 0)
                {
                    this.image = im1;
                }
                else if (counter3 == 1)
                {
                    this.image = im2;
                }
                else
                {
                    this.image = im3;
                }

                CardCollection cards = recognizer.Recognize(this.image);
                //cardImagePanel.DrawImages(cards.ToImageList());
                String r, b;
                //txtCards.Clear();

                //foreach (Card card in cards)
                //{

                //txtCards.AppendText(card.ToString() + Environment.NewLine);

                getScore();

                //getWinner();

                //}
                // */
                //Draw Rectangle around cards and write card strings on card
                using (Graphics graph = Graphics.FromImage(image))
                {
                    foreach (Card card in cards)
                    {
                        graph.DrawPolygon(pen, card.Corners);                          //Draw a polygon around card
                        PointF point = CardRecognizer.GetStringPoint(card.Corners);    //Find Top left corner
                        point.Y += 10;
                        graph.DrawString(card.ToString(), font, Brushes.White, point); //Write string on card
                    }
                }

                /*
                 * r = recognizer.rank1.ToString();
                 * b = recognizer.numBlack.ToString();
                 * txtRed.Text = r;
                 * txtBlack.Text = b;
                 */
                /*
                 * recognizer.numRed = 0;
                 * recognizer.numBlack = 0;
                 */
                if (counter3 == 0)
                {
                    pb1.Image = ResizeBitmap(this.image);
                }
                else if (counter3 == 1)
                {
                    pb2.Image = ResizeBitmap(this.image);
                }
                else
                {
                    pb3.Image = ResizeBitmap(this.image);
                }


                //this.pb_loaded.Image = ResizeBitmap(this.image);
                counter3++;
            }
            getWinner();
        }
Beispiel #41
0
		public ChoiceResult MakeChoice(Choice choice)
		{
			PlayerMode previous = this.PlayerMode;
			PlayerMode = Players.PlayerMode.Choosing;

			CardCollection cards = null;
			ChoiceResult result = null;
			switch (choice.ChoiceType)
			{
				case ChoiceType.Options:
					if (!choice.IsOrdered && choice.Minimum >= choice.Options.Count)
						result = new ChoiceResult(choice.Options);
					break;

				case ChoiceType.Cards:
					//if (choice.IsSpecific && choice.Minimum == 1 && choice.Cards.Count() == 1)
					//    result = new ChoiceResult(new CardCollection(choice.Cards));
					//else 
					IEnumerable<Card> nonDummyCards = choice.Cards.Where(c => c.CardType != Cards.Universal.TypeClass.Dummy);
					if (nonDummyCards.Count() == 0)
						cards = new CardCollection();
					else if (!choice.IsOrdered && choice.Minimum >= nonDummyCards.Count())
						result = new ChoiceResult(new CardCollection(nonDummyCards));
					else if (choice.Maximum == 0)
						cards = new CardCollection();
					else if (choice.Maximum == choice.Minimum &&
							(!choice.IsOrdered || nonDummyCards.Count(card => card.CardType == nonDummyCards.ElementAt(0).CardType) == nonDummyCards.Count()))
						cards = new CardCollection(nonDummyCards);
					break;

				case ChoiceType.Supplies:
					if (choice.Supplies.Count == 1 && choice.Minimum > 0)
						result = new ChoiceResult(choice.Supplies.Values.First());
					else if (choice.Supplies.Count == 0)
						result = new ChoiceResult();
					break;

				case ChoiceType.SuppliesAndCards:
					if (choice.Supplies.Count == 1 && choice.Cards.Count() == 0)
						result = new ChoiceResult(choice.Supplies.Values.First());
					else if (choice.Supplies.Count == 0 && choice.Cards.Count() == 1)
						result = new ChoiceResult(new CardCollection { choice.Cards.First() });
					else if (choice.Supplies.Count == 0)
						result = new ChoiceResult();
					break;

				default:
					throw new Exception("Unable to do anything with this Choice Type!");
			}
			if (result == null && cards != null)
			{
				if (cards.All(delegate(Card c) { return c.CardType == cards[0].CardType; }))
					result = new ChoiceResult(new CardCollection(cards.Take(choice.Minimum)));
			}
			if (result == null)
			{
				Thread choiceThread = new Thread(delegate()
				{
					Choose.Invoke(this, choice);
				});
				choiceThread.Start();
				WaitEvent.WaitOne();
				choiceThread = null;

				if (_MessageRequestQueue.Count > 0)
				{
					lock (_MessageRequestQueue)
					{
						PlayerMessage message = _MessageRequestQueue.Dequeue();
						//System.Diagnostics.Trace.WriteLine(String.Format("Message: {0}", message.Message));
						PlayerMessage response = new PlayerResponseMessage();
						response.Message = "ACK";

						if (message is PlayerChoiceMessage)
							result = ((PlayerChoiceMessage)message).ChoiceResult;

						lock (_MessageResponseQueue)
						{
							_MessageResponseQueue.Enqueue(response);
						}
						if (message.ReturnEvent != null)
							message.ReturnEvent.Set();
					}
				}
			}

			this.PlayerMode = previous;
			return result;
		}
Beispiel #42
0
        static void Main(string[] args)
        {
            //GameDriver controller = new GameDriver();
            //controller.InitializeGame();

            ////foreach(Card card in controller.Deck.CardsInCollection)
            ////{
            ////    Console.WriteLine(card.GetDisplayName());
            ////}
            ////controller.Deck.Shuffle();
            ////Console.WriteLine();
            ////foreach (Card card in controller.Deck.CardsInCollection)
            ////{
            ////    Console.WriteLine(card.GetDisplayName());
            ////}
            ////Console.ReadKey();

            //Console.WriteLine("Player's hand: ");

            //foreach(Card card in controller.GameState.HumanPlayer.CardsInHand.CardsInCollection)
            //{
            //    Console.WriteLine(card.GetDisplayName());
            //}

            //Console.WriteLine();
            //Console.WriteLine("Opponent's hand: ");

            //foreach (Card card in controller.GameState.AIPlayer.CardsInHand.CardsInCollection)
            //{
            //    Console.WriteLine(card.GetDisplayName());
            //}

            //Console.ReadLine();

            CardCollection deck = DeckGenerator.GenerateDeck();


            CardCollection testHand = new CardCollection();

            testHand.AddCardToCollection(deck.CardsInCollection.First(c => c.CardNameEnum == CardNames.Pnakotic_Manuscripts));
            testHand.AddCardToCollection(deck.CardsInCollection.First(c => c.CardNameEnum == CardNames.Cthulhu));
            testHand.AddCardToCollection(deck.CardsInCollection.First(c => c.CardNameEnum == CardNames.Deep_Ones));
            testHand.AddCardToCollection(deck.CardsInCollection.First(c => c.CardNameEnum == CardNames.Rlyeh));
            testHand.AddCardToCollection(deck.CardsInCollection.First(c => c.CardNameEnum == CardNames.Elder_Things));

            Card testCard = deck.CardsInCollection.First(c => c.CardNameEnum == CardNames.Miskatonic_University);

            CardCollection testHand2 = new CardCollection();

            testHand2.AddCardToCollection(deck.CardsInCollection.First(c => c.CardNameEnum == CardNames.Miskatonic_University));
            testHand2.AddCardToCollection(deck.CardsInCollection.First(c => c.CardNameEnum == CardNames.Nyarlathotep));
            testHand2.AddCardToCollection(deck.CardsInCollection.First(c => c.CardNameEnum == CardNames.Shub_Niggurath));
            testHand2.AddCardToCollection(deck.CardsInCollection.First(c => c.CardNameEnum == CardNames.Mountains_Of_Madness));
            testHand2.AddCardToCollection(deck.CardsInCollection.First(c => c.CardNameEnum == CardNames.Hastur));

            Player testPlayer = new Player("me");

            testPlayer.CardsInPlay = testHand;

            Player testPlayer2 = new Player("you");

            testPlayer2.CardsInPlay = testHand2;

            int myScore   = ScoreCalculator.CalculateScore(testPlayer, testPlayer2);
            int yourScore = ScoreCalculator.CalculateScore(testPlayer2, testPlayer);

            Console.WriteLine(myScore);
            Console.WriteLine(yourScore);

            Console.ReadKey();
        }
Beispiel #43
0
 public PileChangedEventArgs(Operation operation)
 {
     _OperationPerformed = operation;
     _AddedCards         = new CardCollection();
     _RemovedCards       = new CardCollection();
 }
Beispiel #44
0
 public Shop_Pack()
 {
     CommonCards = new CardCollection();
     RareCards   = new CardCollection();
 }
 private void OverwriteSelect(CardCollection collection)
 {
     m_CurrentSelectDeck.m_Warrior  = collection.m_Warrior;
     m_CurrentSelectDeck.m_CardList = collection.m_CardList;
 }
Beispiel #46
0
        private static void Main(string[] args)
        {
            //Parse Commandline options
            var options            = new Options();
            var commandLineResults = Parser.Default.ParseArguments(args, options);
            var encode             = new Encode
            {
                ShuffleFields     = options.ShuffleFields,
                IncludeFlavorText = options.FlavorText
            };

            //Only continue if commandline options fullfilled. CommandLine will handle helptext if something was off.
            if (commandLineResults)
            {
                string outPath;
                string inPath;

                var _ConsoleLog = ConsoleLog.Instance;
                _ConsoleLog.Verbose = options.Verbose;
                _ConsoleLog.Silent  = options.Silent;

                //Use Path to get proper filesystem path for input
                try
                {
                    inPath = Path.GetFullPath(options.InputFile);
                }
                catch (Exception)
                {
                    Console.WriteLine("Invalid Path to input file: {0}", options.InputFile);
                    return;
                }

                //Check if input file is real.
                if (!File.Exists(inPath))
                {
                    Console.WriteLine("File does not exist: {0}", options.InputFile);
                    return;
                }

                //Use Path to get proper filesystem path for output
                try
                {
                    outPath = Path.GetFullPath(options.OutputFile);
                }
                catch (Exception)
                {
                    Console.WriteLine("Invalid Path to output file: {0}", options.OutputFile);
                    return;
                }

                //Load card collection to encode
                CardCollection cardCollection;
                try
                {
                    cardCollection = CardCollection.Load(inPath);
                }
                catch (Exception)
                {
                    Console.WriteLine("Could not parse '{0}'.", inPath);
                    return;
                }

                //Shuffle the cards, if that option is set
                if (options.ShuffleCards)
                {
                    cardCollection.Cards.Shuffle();
                }

                //Actually encode.
                string output;
                output = encode.EncodeCardCollection(cardCollection, options.EncodingFormat);

                try
                {
                }
                catch (Exception)
                {
                    Console.WriteLine("Error while trying to encode {0} using {1}.", inPath, options.EncodingFormat);
                    return;
                }


                //Write out again
                try
                {
                    File.WriteAllText(outPath, output);
                }
                catch (Exception)
                {
                    Console.WriteLine("Could not write output to {0}", outPath);
                }
            }
        }
Beispiel #47
0
        /// <summary>
        /// A method that finds what the player bot should be doing and acts accordingly
        /// </summary>
        /// <param name="proposals">The dictionary of all cards in the bots hand, and their confidence in playing that card</param>
        /// <param name="server">The server to execute on</param>
        /// <param name="hand">The bot's hand</param>
        public void Propose(Dictionary <PlayingCard, float> proposals, GameServer server, CardCollection hand)
        {
            GameState state = server.GameState;

            // Get trump card suit
            CardSuit trumpSuit = state.GetValueCard(Names.TRUMP_CARD).Suit;

            // Determine the cards we are working with
            PlayingCard[] keys = proposals.Keys.ToArray();

            //Bot player is in attacking mode
            if (state.GetValueBool(Names.IS_ATTACKING))
            {
                foreach (PlayingCard key in keys)
                {
                    //Auto set all cards proposal to 1.0
                    proposals[key] += .50f;
                    if (key.Suit == trumpSuit)
                    {
                        proposals[key] -= .25f;
                    }
                    ////If its not the first round do logic to only use cards that can be played based on pervious cards
                    if (state.GetValueInt(Names.CURRENT_ROUND) != 0)
                    {
                        for (int i = 0; i >= state.GetValueInt(Names.CURRENT_ROUND); i++)
                        {
                            //If the card does not share the same rank as the attacking or defending card or does not share the same suit as the trump
                            if (state.GetValueCard(Names.ATTACKING_CARD, i).Rank != key.Rank || state.GetValueCard(Names.DEFENDING_CARD, i).Rank == key.Rank || key.Suit == trumpSuit)
                            {
                                proposals[key] = 0.0f;
                            }
                        }
                    }
                }
            }

            //Bot Player is defending
            else
            {
                PlayingCard attackingCard = state.GetValueCard(Names.ATTACKING_CARD, state.GetValueInt(Names.CURRENT_ROUND));

                foreach (PlayingCard key in keys)
                {
                    //Add weight to all cards of the attacking cards suit and trump cards suit
                    if (key.Suit == trumpSuit | key.Suit == attackingCard.Suit)
                    {
                        proposals[key] += .25f;
                        //Add a little more weight if the card is not a trump card. So the bot has less chance to waste its trumps
                        if (key.Suit != trumpSuit)
                        {
                            proposals[key] += .25f;
                        }
                        //Add weight if the rank is higher than the attacking cards rank
                        if (key.Rank > attackingCard.Rank)
                        {
                            proposals[key] += .25f - ((int)key.Rank / 100.0f);
                        }
                        //If the cards rank is less than the attacking card and the suits are the same remove weight (meaning trump cards with a lower rank will still have weight)
                        else if (key.Rank < attackingCard.Rank && key.Suit == attackingCard.Suit)
                        {
                            proposals[key] = 0.0f;
                        }
                    }
                }
            }
        }
Beispiel #48
0
 public Choice(String text, Card cardSource, CardCollection cardTriggers, List <String> options, Player playerSource, EventArgs eventArgs, Boolean isOrdered, int minimum, int maximum)
     : this(text, cardSource, cardTriggers, ChoiceType.Options, playerSource, eventArgs, isOrdered, false, minimum, maximum)
 {
     _Options = new OptionCollection(options);
 }
 public void ChangeDeck(CardCollection cc)
 {
     Display(cc);
 }
Beispiel #50
0
 public Choice(String text, Card cardSource, CardCollection cardTriggers, IEnumerable <Card> cards, Player playerSource, Boolean isOrdered, int minimum, int maximum)
     : this(text, cardSource, cardTriggers, ChoiceType.Cards, playerSource, null, isOrdered, false, minimum, maximum)
 {
     _Cards = cards;
 }
Beispiel #51
0
 private void RefreshCollection()
 {
     _collection = CollectionImporter.ImportCollection();
     GC.Collect();
     UpdateStatusLabel();
 }
        public List <Trick <BuraCard> > Execute(CardCollection <BuraCard> attackerCards, CardCollection <BuraCard> defenderCards)
        {
            attackerCards.Sort((a, b) => { return(a.CompareTo(b) * -1); });
            defenderCards.Sort();

            var visitedCards = new HashSet <BuraCard>();
            var tricks       = this.Defend(attackerCards, defenderCards, visitedCards);

            if (tricks.Count == defenderCards.Count)
            {
                return(tricks);
            }

            var attackersLeft = new List <BuraCard>();
            var defendersLeft = new List <BuraCard>();

            foreach (var card in attackerCards)
            {
                if (!visitedCards.Contains(card))
                {
                    attackersLeft.Add(card);
                }
            }

            foreach (var card in defenderCards)
            {
                if (!visitedCards.Contains(card))
                {
                    defendersLeft.Add(card);
                }
            }

            for (var i = 0; i < attackersLeft.Count; i++)
            {
                tricks.Add(new Trick <BuraCard>(attackersLeft[i], defendersLeft[i]));
            }

            return(tricks);
        }
Beispiel #53
0
 public Choice(String text, Card cardSource, CardCollection cardTriggers, List <String> options, Player playerSource)
     : this(text, cardSource, cardTriggers, options, playerSource, null, false, 1, 1)
 {
 }
Beispiel #54
0
 void Awake()
 {
     cardCollection = GameObject.FindObjectOfType <CardCollection>();
     ResetDeck();
 }
Beispiel #55
0
 public ChoiceResult(CardCollection cards)
     : this(ChoiceType.Cards)
 {
     _Cards = cards;
 }
        public ActionResult Deckbuilder(int ALDeckID)
        {
            CardCollections cardColl = new CardCollections();

            #region Get Cards from Collection cardColl.coll
            var dbUCardList = DeckManager.GetAllCollectionCards(UserManager.GetUserByUserEmail(User.Identity.Name).idperson);
            foreach (var c in dbUCardList)
            {
                //Wenn kein Index vorhanden ist -> index = -1
                int index = cardColl.coll.FindIndex(i => i.IdCard == c.idcard);

                if (index >= 0)
                {
                    cardColl.coll[index].Number += 1;
                }
                else
                {
                    CardCollection card = new CardCollection();
                    card.IdCard           = c.idcard;
                    card.IdUser           = c.fkperson;
                    card.IdCollectioncard = c.idcollectioncard;
                    card.IdOrder          = c.fkorder;
                    card.Number           = 1;
                    card.Cardname         = c.cardname;
                    card.Attack           = c.attack;
                    card.Mana             = c.mana;
                    card.Life             = c.life;
                    card.pic = c.pic;

                    cardColl.coll.Add(card);
                }
            }
            #endregion

            #region Get Cards from Deck cardColl.deck
            var dbDCardList = DeckManager.GetAllDeckCards(ALDeckID);

            foreach (var c in dbDCardList)
            {
                int index  = cardColl.deck.FindIndex(i => i.IdCard == c.fkcard);
                int indexC = cardColl.coll.FindIndex(i => i.IdCard == c.fkcard);

                CardCollection card = new CardCollection();
                card.IdCard           = c.fkcard;
                card.IdUser           = c.fkperson;
                card.IdCollectioncard = c.idcollectioncard;
                card.IdOrder          = c.fkorder;
                //card.Number = 1;
                card.Cardname = c.tblcard.cardname;
                card.Attack   = c.tblcard.attack;
                card.Mana     = c.tblcard.mana;
                card.Life     = c.tblcard.life;
                card.pic      = c.tblcard.pic;

                cardColl.deck.Add(card);

                cardColl.coll[indexC].Number -= 1;
            }
            #endregion


            ViewBag.Deckcount = cardColl.deck.Count();

            cardColl.DeckName = DeckManager.GetDecknameById(ALDeckID);
            cardColl.DeckID   = ALDeckID;

            TempData["SaveCollection"] = cardColl;
            TempData["CardCollection"] = cardColl;

            return(View(cardColl));
        }
Beispiel #57
0
 public static IEnumerable <BaseCard> LessonsOfType(this CardCollection collection, LessonTypes type)
 {
     return(collection.Lessons.Where(c => ((BaseLesson)c).LessonType == type));
 }
Beispiel #58
0
        /// <summary>
        /// Adds models to the game. Add camera to the game. We'll do more with this later.
        /// </summary>
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            //Load camera.
            if (_cameraType == CameraType.TargetCamera)
            {
                _camera = new TargetCamera(
                    (new Vector3(0, 500, 500)) * 3,
                    Vector3.Zero, GraphicsDevice);
            }

            if (_cameraType == CameraType.FreeCamera)
            {
                _camera = new FreeCamera(
                    (new Vector3(500, 600, 1300)) * 1,
                    MathHelper.ToRadians(153),
                    MathHelper.ToRadians(5),
                    GraphicsDevice);
            }

            // Load Card texture.
            _cardTexture = Content.Load <Texture2D>("Cards\\Images\\cardlayout-2");

            // Load some fonts.
            _basicFont           = Content.Load <SpriteFont>("Fonts\\SpriteFont1");
            _rulesTextFont       = Content.Load <SpriteFont>("Fonts\\RulesTextFont");
            _rulesTextItalicFont = Content.Load <SpriteFont>("Fonts\\RulesTextItalicFont");
            _titleFont           = Content.Load <SpriteFont>("Fonts\\TitleFont");
            _typeFont            = Content.Load <SpriteFont>("Fonts\\TypeFont");
            _statFont            = Content.Load <SpriteFont>("Fonts\\StatFont");

            // Load models.
            _models.Add(
                new BasicModel(
                    Content.Load <Model>("blueship"),
                    Vector3.Zero,
                    Quaternion.Identity,
                    new Vector3(.01f),
                    GraphicsDevice));
            _movementDataReporter.PlayerShipSelected.Add("blueship", false);

            //Load sky box.
            _skybox = new Skybox(Content, GraphicsDevice, Content.Load <TextureCube>("Textures\\bluestreak"));


            //Load stars.
            Random r = new Random();

            Vector3[] postions      = new Vector3[30000];
            float     dispersalRate = 700000;
            float     height        = -400000;

            for (int i = 0; i < postions.Length; i++)
            {
                postions[i] = new Vector3((float)r.NextDouble() * dispersalRate - dispersalRate / 2, (float)r.NextDouble() * (height) - height / 2, (float)r.NextDouble() * dispersalRate - dispersalRate / 2);
                //postions[i] = new Vector3(10000, 400, 10000);
            }

            _stars = new BillboardSystem(GraphicsDevice, Content, Content.Load <Texture2D>("BillboardTextures\\flare-blue-purple1"), new Vector2(800), postions);


            // TEST DESERIALIZATION
            //_cards = CardCollection.Deserialize(File.ReadAllText("Content/Cards/Cards.json"));
            _cards = CardCollection.Deserialize(File.ReadAllText("Content/Cards/Cards.json"));

            FleetHackers.FleetHackersServer.FleetHackersServiceClient fhClient = new FleetHackers.FleetHackersServer.FleetHackersServiceClient();
            string result = fhClient.GetData(1223);             //this test works.

            //Appears we're experiencing some schema issues here. Will track down what the issue is.
            //cards = fhClient.GetCardData(new List<Card>());

            //cards = fhClient.GetCardData(cards); // This stuff needs fixing. JSON is disabled in the meantime.

            fhClient.Close();

            foreach (Card c in _cards)
            {
                Debug.WriteLine(c.Title);
                Debug.WriteLine(c.RulesText);
            }

            //initialize debug stuff
            DebugDraw._camera     = _camera;
            DebugDraw._lineDrawer = _lineDrawer;
        }
Beispiel #59
0
		public CardCollection DrawFrom(DeckPosition deckPosition, int number, Object destination)
		{
			CardCollection cards = new CardCollection();
			if (number <= 0)
				return cards;

			CardCollection cardsFirst = _DrawPile.Retrieve(this, deckPosition, c => true, number);
			cards.AddRange(cardsFirst);
			cards.RemovedFrom(DeckLocation.Deck, this);

			if (_AsynchronousDrawing)
			{
				if (_AsynchronousCardsDrawnEventArgs == null)
					_AsynchronousCardsDrawnEventArgs = new CardsDrawnEventArgs(cardsFirst, deckPosition, number);
				else
					_AsynchronousCardsDrawnEventArgs.Cards.AddRange(cardsFirst);
			}
			else if (CardsDrawn != null)
			{
				CardsDrawnEventArgs cdea = new CardsDrawnEventArgs(cardsFirst, deckPosition, number);
				CardsDrawn(this, cdea);
			}

			if (destination is Type)
				this.AddCardsInto((Type)destination, cardsFirst);
			else if (destination is DeckLocation)
				this.AddCardsInto((DeckLocation)destination, cardsFirst);
			else
				throw new Exception(String.Format("Destination of {0} ({1}) is not supported", destination, destination.GetType()));
			
			if (cardsFirst.Count < number && _DrawPile.Count == 0 && _DiscardPile.Count > 0)
			{
				this.ShuffleForDrawing();

				CardCollection cardsSecond = _DrawPile.Retrieve(this, deckPosition, c => true, number < 0 ? number : number - cards.Count);
				cards.AddRange(cardsSecond);
				cardsSecond.RemovedFrom(DeckLocation.Deck, this);

				if (_AsynchronousDrawing)
				{
					if (_AsynchronousCardsDrawnEventArgs == null)
						_AsynchronousCardsDrawnEventArgs = new CardsDrawnEventArgs(cardsSecond, deckPosition, number);
					else
						_AsynchronousCardsDrawnEventArgs.Cards.AddRange(cardsSecond);
				}
				else if (CardsDrawn != null)
				{
					CardsDrawnEventArgs cdea = new CardsDrawnEventArgs(cardsSecond, deckPosition, number);
					CardsDrawn(this, cdea);
				}

				if (destination is Type)
					this.AddCardsInto((Type)destination, cardsSecond);
				else if (destination is DeckLocation)
					this.AddCardsInto((DeckLocation)destination, cardsSecond);
				else
					throw new Exception(String.Format("Destination of {0} ({1}) is not supported", destination, destination.GetType()));
			}

			return cards;
		}
Beispiel #60
0
 public void Clear()
 {
     this.trumpCard    = null;
     this.UnknownCards = new CardCollection(CardCollection.AllSantaseCardsBitMask);
     this.PlayedCards  = new CardCollection();
 }