当前位置: 首页>>代码示例>>C#>>正文


C# CardCollection.Any方法代码示例

本文整理汇总了C#中CardCollection.Any方法的典型用法代码示例。如果您正苦于以下问题:C# CardCollection.Any方法的具体用法?C# CardCollection.Any怎么用?C# CardCollection.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CardCollection的用法示例。


在下文中一共展示了CardCollection.Any方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UndoPlayCards

		public void UndoPlayCards(CardCollection cards)
		{
			if (this.Actions == 0 && this.Phase != PhaseEnum.BuyTreasure && cards.Any(c => (c.Category & Category.Action) == Category.Action))
				throw new Exception("You cannot play any Action cards right now!");

			UndoPlayCardsInternal(cards, String.Empty);

			if (cards.Any(c => (c.Category & Category.Action) == Category.Action))
				this.Phase = PhaseEnum.Action;
			else
				this.Phase = PhaseEnum.BuyTreasure;
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:12,代码来源:Player.cs

示例2: PlayCards

		public void PlayCards(CardCollection cards)
		{
			if (this.Actions == 0 && cards.Any(c => (c.Category & Category.Action) == Category.Action))
				throw new Exception("You cannot play any Action cards right now!");

			PlayCardsInternal(cards);

			// Check Phase after playing -- we may need to switch phases
			if (this.Phase == PhaseEnum.Action && (this.Actions == 0 || this.Hand[Category.Action].Count == 0))
				this.Phase = PhaseEnum.BuyTreasure;
			else if (this.Phase == PhaseEnum.BuyTreasure && this.Hand[Category.Treasure].Count == 0 && !this.TokenPiles.IsAnyPlayable)
				this.Phase = PhaseEnum.Buy;
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:13,代码来源:Player.cs

示例3: PlayCardsInternal

		internal void PlayCardsInternal(CardCollection cards, String modifier)
		{
			// Don't even bother; just return straight away
			if (cards.Count == 0)
				return;

			// So the AI doesn't blow things up, just return immediately if the Phase is Endgame
			if (this.Phase == PhaseEnum.Endgame)
				return;

			foreach (Card card in cards)
			{
				if (Phase == PhaseEnum.Action && (card.Category & Category.Action) != Category.Action)
					this.Phase = PhaseEnum.BuyTreasure;
			}

			if (this.Phase != PhaseEnum.Action && this.Phase != PhaseEnum.Starting && this.PlayerMode != PlayerMode.Playing && cards.Any(c => (c.Category & Category.Action) == Category.Action))
				throw new Exception("You cannot play any Action cards right now!");
			if (this.Phase != PhaseEnum.ActionTreasure && this.Phase != PhaseEnum.BuyTreasure && this.PlayerMode != PlayerMode.Playing && 
				cards.Any(c => (c.Category & Category.Treasure) == Category.Treasure))
				throw new Exception("You cannot play any Treasure cards right now!");

			PlayerMode currentPlayerMode = this.PlayerMode;
			this.PlayerMode = PlayerMode.Playing;

			if (CardPlaying != null)
			{
				CardPlayingEventArgs cpgea = new CardPlayingEventArgs(this, cards, modifier);
				CardPlaying(this, cpgea);
			}

			// Retrieve the actual card instead of the one we're passed.  It might not exist
			// Also, we need to remove them from the Hand, Revealed, or Private (these are the 3 places cards can be played from)
			CardCollection actualCards = this.RetrieveCardsFrom(DeckLocation.Hand, cards);
			actualCards.AddRange(this.RetrieveCardsFrom(DeckLocation.Revealed, cards));
			actualCards.AddRange(this.RetrieveCardsFrom(DeckLocation.Private, cards));

			// Add them to In Play, add them to the Played list for the turn, and Play them (individually)
			foreach (Card card in cards)
			{
				if (actualCards.Contains(card))
				{
					if (CardPuttingIntoPlay != null)
					{
						CardPutIntoPlayEventArgs cpipea = new CardPutIntoPlayEventArgs(this, card);
						CardPuttingIntoPlay(this, cpipea);
					}

					this.AddCardInto(DeckLocation.InPlay, card);

					if (CardPutIntoPlay != null)
					{
						CardPutIntoPlayEventArgs cpipea = new CardPutIntoPlayEventArgs(this, card);
						CardPutIntoPlay(this, cpipea);
					}
				}

				this.CurrentTurn.Played(card);
				card.Play(this);
				card.PlayFinished(this);
			}

			this.InPlay.Refresh(this);

			if (CardPlayed != null)
			{
				CardPlayedEventArgs cpdea = new CardPlayedEventArgs(this, cards);
				CardPlayed(this, cpdea);
			}
			this.PlayerMode = currentPlayerMode;
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:71,代码来源:Player.cs

示例4: GetEnumeratorShouldShouldWorkProperlyInNestedLoops

 public void GetEnumeratorShouldShouldWorkProperlyInNestedLoops()
 {
     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),
                          };
     foreach (var firstCard in collection)
     {
         Assert.NotNull(firstCard);
         var found = collection.Any(x => x.Equals(new Card(CardSuit.Diamond, CardType.Queen)));
         Assert.IsTrue(found);
     }
 }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:18,代码来源:CardCollectionTests.cs


注:本文中的CardCollection.Any方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。