Example #1
0
		public void PlayCard(Card card, PlayerMode previousPlayerModeToRestore)
		{
			this.CurrentTurn.Played(card);
			card.Play(this);
			card.PlayFinished(this);

			this.InPlay.Refresh(this);

			if (CardPlayed != null)
			{
				CardPlayedEventArgs cpdea = new CardPlayedEventArgs(this, card);
				CardPlayed(this, cpdea);
			}
			this.PlayerMode = previousPlayerModeToRestore;
		}
Example #2
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);
			}
		}
Example #3
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;
		}
Example #4
0
		void ActivePlayer_CardPlayed(object sender, CardPlayedEventArgs e)
		{
			CardBenefit benefit = new CardBenefit();
			foreach (Card card in e.Cards)
			{
				if (card.CardType == Universal.TypeClass.Copper)
					benefit.Currency += new Coin(1);
			}
			e.Player.ReceiveBenefit(this, benefit);
		}