Exemplo n.º 1
0
		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;
		}
Exemplo n.º 2
0
		public PlayerMode PutCardIntoPlay(Card card, String modifier)
		{
			PlayerMode currentPlayerMode = this.PlayerMode;
			this.PlayerMode = PlayerMode.Playing;

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

			// Retrieve the actual card instead of the one we're passed.  It might not exist
			// Also, we need to remove it from the Hand, Revealed, or Private (these are the 3 places cards can be played from)
			Card actualCard = null;
			if (this.Hand.Contains(card))
				actualCard = this.RetrieveCardFrom(DeckLocation.Hand, card);
			if (actualCard == null && this.Revealed.Contains(card))
				actualCard = this.RetrieveCardFrom(DeckLocation.Revealed, card);
			if (actualCard == null && this.Private.Contains(card))
				actualCard = this.RetrieveCardFrom(DeckLocation.Private, card);

			// Add it to In Play, add it to the Played list for the turn, and Play it
			if (actualCard == 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);
				}
			}

			return currentPlayerMode;
		}
Exemplo n.º 3
0
		public void PlayNothing(String modifier)
		{
			if (CardPlaying != null)
			{
				CardPlayingEventArgs cpgea = new CardPlayingEventArgs(this, (CardCollection)null, modifier);
				CardPlaying(this, cpgea);
			}
			if (CardPlayed != null)
			{
				CardPlayedEventArgs cpdea = new CardPlayedEventArgs(this, (CardCollection)null);
				CardPlayed(this, cpdea);
			}
		}