Example #1
0
		internal void player_RevealMoat(Player player, ref AttackedEventArgs e)
		{
			player.AddCardInto(DeckLocation.Revealed, player.RetrieveCardFrom(DeckLocation.Hand, this.PhysicalCard));
			e.Cancelled = true;
			player.AddCardInto(DeckLocation.Hand, player.RetrieveCardFrom(DeckLocation.Revealed, this.PhysicalCard));
			e.HandledBy.Add(TypeClass.Moat);
		}
Example #2
0
		/// <summary>
		/// Fires off the Attack event, so any listeners can pick it up.
		/// </summary>
		/// <param name="player">The attacking player</param>
		/// <param name="attackingCard">The card that triggered the Attack event</param>
		/// <returns>"true" if the Attack can proceed (wasn't blocked).  "false" if the Attack was blocked.</returns>
		/// <summary>
		public Boolean AttackedBy(Player attacker, Card attackingCard)
		{
			if (Attacked != null)
			{
				AttackedEventArgs aea = null;
				Boolean cancelled = false;
				do
				{
					aea = new AttackedEventArgs(attacker, attackingCard);
					aea.Cancelled |= cancelled;
					Attacked(this, aea);

					CardCollection cards = new CardCollection(aea.Revealable.Values.Select(s => s.Card));
					if (cards.Count > 0)
					{
						cards.Sort();
						Choice choice = new Choice("Reveal a card?", null, attackingCard, cards, this, true, aea);
						ChoiceResult result = this.MakeChoice(choice);

						if (result.Cards.Count > 0)
							aea.Revealable[result.Cards[0].CardType].Method(this, ref aea);
						else
							break;
					}

					cancelled |= aea.Cancelled;

				} while (Attacked != null && aea.HandledBy.Count > 0);

				if (aea != null)
					cancelled |= aea.Cancelled;

				return !cancelled;
			}
			return true;
		}
Example #3
0
		internal void player_RevealBeggar(Player player, ref AttackedEventArgs e)
		{
			player.Discard(DeckLocation.Hand, this.PhysicalCard);
			player.Gain(player._Game.Table.Silver, DeckLocation.Deck, DeckPosition.Top);
			player.Gain(player._Game.Table.Silver);

			e.HandledBy.Add(TypeClass.Beggar);

			// Attack isn't cancelled... it's just mitigated
		}
Example #4
0
		internal override void player_Attacked(object sender, AttackedEventArgs e)
		{
			Player player = sender as Player;

			// Moat only protects against other attackers
			if (player == e.Attacker)
				return;

			// Already been cancelled -- don't need to process this one
			if (player.Hand.Contains(this.PhysicalCard) && !e.Cancelled && !e.Revealable.ContainsKey(TypeClass.Moat))
				e.Revealable[TypeClass.Moat] = new AttackReaction(this, String.Format("Reveal {0}", this.PhysicalCard), player_RevealMoat);
		}
Example #5
0
		internal override void player_Attacked(object sender, AttackedEventArgs e)
		{
			Player player = sender as Player;

			// Horse Traders only protects against other attackers
			if (player == e.Attacker)
				return;

			// Make sure it exists already
			if (player.Hand.Contains(this.PhysicalCard) && !e.Revealable.ContainsKey(TypeClass.Beggar))
				e.Revealable[TypeClass.Beggar] = new AttackReaction(this, String.Format("Discard {0}", this.PhysicalCard), player_RevealBeggar);
		}
		internal void player_RevealHorseTraders(Player player, ref AttackedEventArgs e)
		{
			player.AddCardInto(DeckLocation.Revealed, player.RetrieveCardFrom(DeckLocation.Hand, this.PhysicalCard));
			player.AddCardInto(DeckLocation.SetAside, player.RetrieveCardFrom(DeckLocation.Revealed, this.PhysicalCard));
			// Attack isn't cancelled... it's just mitigated
			e.HandledBy.Add(TypeClass.HorseTraders);
		}
Example #7
0
		internal void player_RevealSecretChamber(Player player, ref AttackedEventArgs e)
		{
			player.AddCardInto(DeckLocation.Revealed, player.RetrieveCardFrom(DeckLocation.Hand, this.PhysicalCard));
			player.AddCardToHand(player.RetrieveCardFrom(DeckLocation.Revealed, this.PhysicalCard));

			player.Draw(2, DeckLocation.Hand);

			Choice replaceChoice = new Choice("Choose order of cards to put back on your deck", this, new CardCollection() { e.AttackCard }, player.Hand, player, true, 2, 2);
			ChoiceResult replaceResult = player.MakeChoice(replaceChoice);
			player.RetrieveCardsFrom(DeckLocation.Hand, replaceResult.Cards);
			player.AddCardsToDeck(replaceResult.Cards, DeckPosition.Top);

			e.HandledBy.Add(TypeClass.SecretChamber);

			// Attack isn't cancelled... it's just mitigated
		}
Example #8
0
		internal override void player_Attacked(object sender, AttackedEventArgs e)
		{
			Player player = sender as Player;

			// Secret Chamber only protects against other attackers
			if (player == e.Attacker)
				return;

			// Only allow a single handling by a given card type
			if (player.Hand.Contains(this.PhysicalCard) && !e.HandledBy.Contains(TypeClass.SecretChamber) && !e.Revealable.ContainsKey(TypeClass.SecretChamber))
				e.Revealable[TypeClass.SecretChamber] = new AttackReaction(this, String.Format("Reveal {0}", this.PhysicalCard), player_RevealSecretChamber);
		}
Example #9
0
		private void player_Attacked_InPlay(object sender, AttackedEventArgs e)
		{
			// Already been cancelled -- don't need to process this one
			if (e.Cancelled)
				return;
			Player player = sender as Player;

			// Lighthouse only protects against other attackers
			if (player == e.Attacker)
				return;

			// Passively cancels any attack
			e.Cancelled = true;
			player._Game.SendMessage(player, this);
		}