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


C# CardCollection.RemovedFrom方法代码示例

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


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

示例1: Trash

		internal void Trash(DeckLocation location, CardCollection cards)
		{
			if (cards.Count == 0)
				return;

			TrashEventArgs tea = null;

			if (Trashing != null)
			{
				do
				{
					tea = new TrashEventArgs(this, cards);
					Trashing(this, tea);

					Boolean isAnyRequired = false;
					List<String> options = new List<String>();
					IEnumerable<Type> cardTypes = tea.Actions.Keys;
					foreach (Type key in cardTypes)
					{
						options.Add(tea.Actions[key].Text);
						isAnyRequired |= tea.Actions[key].IsRequired;
					}

					if (options.Count > 0)
					{
						options.Sort();
						Choice choice = new Choice(String.Format("You are trashing {0} cards", cards.Count), null, cards, options, this, tea, false, isAnyRequired ? 1 : 0, 1);
						ChoiceResult result = this.MakeChoice(choice);

						if (result.Options.Count > 0)
							tea.Actions.First(kvp => kvp.Value.Text == result.Options[0]).Value.Method(this, ref tea);
					}
				} while (Trashing != null && tea.HandledBy.Count > 0);
			}

			this.MoveToTrashStart(location, cards);
			if (CurrentTurn != null)
				CurrentTurn.Trashed(cards);

			if (Trashed != null)
			{
				List<Object> handledBy = new List<Object>();
				Boolean actionPerformed = false;
				do
				{
					actionPerformed = false;

					tea = new TrashEventArgs(this, cards);
					tea.HandledBy.AddRange(handledBy);
					Trashed(this, tea);
					handledBy = tea.HandledBy;

					IEnumerator<Player> enumerator = this._Game.GetPlayersStartingWithEnumerator(this);
					while (enumerator.MoveNext())
					{
						Boolean isAnyRequired = false;
						List<String> options = new List<String>();
						IEnumerable<Type> cardTypes = tea.Actions.Keys;
						foreach (Type key in cardTypes)
						{
							if (enumerator.Current == tea.Actions[key].Player)
							{
								options.Add(tea.Actions[key].Text);
								isAnyRequired |= tea.Actions[key].IsRequired;
							}
						}
						if (options.Count > 0)
						{
							options.Sort();
							Choice choice = new Choice(String.Format("{0} trashed {1}", this == enumerator.Current ? "You" : this.ToString(), Utilities.StringUtility.Plural("card", cards.Count)), null, cards, options, this, tea, false, isAnyRequired ? 1 : 0, 1);
							ChoiceResult result = enumerator.Current.MakeChoice(choice);

							if (result.Options.Count > 0)
							{
								tea.Actions.First(kvp => kvp.Value.Text == result.Options[0]).Value.Method(enumerator.Current, ref tea);
								actionPerformed = true;
							}
						}
					}
				} while (Trashed != null && actionPerformed);
			}

			cards.TrashedBy(this);
			Lose(cards);

			if (TrashedFinished != null)
			{
				tea = new TrashEventArgs(this, cards);
				TrashedFinished(this, tea);
			}

			cards.RemovedFrom(location, this);
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:93,代码来源:Player.cs

示例2: DrawFrom

		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;
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:61,代码来源:Player.cs

示例3: RetrieveCardsFrom

		internal CardCollection RetrieveCardsFrom(DeckLocation location, DeckPosition position, Predicate<Card> match, int count)
		{
			CardCollection cards;
			switch (location)
			{
				case DeckLocation.Hand:
					cards = _Hand.Retrieve(this, position, match, count);
					break;

				case DeckLocation.Revealed:
					cards = _Revealed.Retrieve(this, position, match, count);
					break;

				case DeckLocation.Discard:
					cards = _DiscardPile.Retrieve(this, position, match, count);
					break;

				case DeckLocation.Deck:
					cards = _DrawPile.Retrieve(this, position, match, count);
					if (cards.Count < count && _DrawPile.Count == 0 && _DiscardPile.Count > 0)
						this.ShuffleForDrawing();
					cards.AddRange(_DrawPile.Retrieve(this, position, match, count < 0 ? count : count - cards.Count));
					break;

				case DeckLocation.InPlay:
					cards = _InPlay.Retrieve(this, position, match, count);
					break;

				case DeckLocation.SetAside:
					cards = _SetAside.Retrieve(this, position, match, count);
					break;

				case DeckLocation.Private:
					cards = _Private.Retrieve(this, position, match, count);
					break;

				case DeckLocation.InPlayAndSetAside:
					cards = _InPlay.Retrieve(this, position, match, count);
					cards.AddRange(_SetAside.Retrieve(this, position, match, count < 0 ? count : count - cards.Count));
					break;

				default:
					cards = new CardCollection();
					break;
			}
			cards.RemovedFrom(location, this);
			return cards;
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:48,代码来源:Player.cs


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