void player_CardsDiscarding(object sender, CardsDiscardEventArgs e) { if (!e.Cards.Contains(this.PhysicalCard) || e.GetAction(TypeClass.Alchemist) != null || (e.FromLocation != DeckLocation.InPlay && e.FromLocation != DeckLocation.SetAside && e.FromLocation != DeckLocation.InPlayAndSetAside)) return; if (e.Cards.Any(c => c.CardType == TypeClass.Potion)) e.AddAction(TypeClass.Alchemist, new CardsDiscardAction(sender as Player, this, String.Format("Put {0} on your deck", this.PhysicalCard), player_Action, false)); }
public void Discard(DeckLocation fromLocation, Predicate<Card> match, int count, CardsDiscardAction discardAction) { CardCollection matchingCards = this.ResolveDeck(fromLocation)[match]; if (count >= 0 && count < matchingCards.Count) { matchingCards.RemoveRange(count, matchingCards.Count - count); if (matchingCards.Count != count) throw new Exception("Incorrect number of cards found!"); } if (matchingCards.Count == 0) return; if (CardsDiscarding != null) { CardsDiscardEventArgs cdea = null; List<Object> handledBy = new List<Object>(); Boolean actionPerformed = false; Boolean cancelled = false; do { actionPerformed = false; cdea = new CardsDiscardEventArgs(fromLocation, matchingCards); cdea.Cancelled = cancelled; cdea.HandledBy.AddRange(handledBy); CardsDiscarding(this, cdea); handledBy = cdea.HandledBy; matchingCards = cdea.Cards; cancelled |= cdea.Cancelled; OptionCollection options = new OptionCollection(); IEnumerable<Tuple<Type, Type>> cardTypes = cdea.Actions.Keys; foreach (Tuple<Type, Type> key in cardTypes) options.Add(new Option(cdea.Actions[key].Text, cdea.Actions[key].IsRequired)); if (options.Count > 0) { if (discardAction != null && !cdea.HandledBy.Contains(this)) { cdea.AddAction(this.GetType(), discardAction); options.Add(new Option(discardAction.Text, true)); } options.Sort(); Choice choice = new Choice(String.Format("You are discarding {0}", Utilities.StringUtility.Plural("card", matchingCards.Count)), options, this, cdea); ChoiceResult result = this.MakeChoice(choice); if (result.Options.Count > 0) { CardsDiscardAction action = cdea.Actions.First(kvp => kvp.Value.Text == result.Options[0]).Value; cdea.Data = action.Data; action.Method(this, ref cdea); actionPerformed = true; handledBy = cdea.HandledBy; matchingCards = cdea.Cards; cancelled |= cdea.Cancelled; } } } while (CardsDiscarding != null && actionPerformed); if (cancelled) return; } this.RetrieveCardsFrom(fromLocation, matchingCards); if (CardsDiscard != null) { CardsDiscardEventArgs cdea = null; List<Object> handledBy = new List<Object>(); cdea = new CardsDiscardEventArgs(fromLocation, matchingCards); cdea.HandledBy.AddRange(handledBy); CardsDiscard(this, cdea); handledBy = cdea.HandledBy; matchingCards = cdea.Cards; } this.AddCardsInto(DeckLocation.Discard, matchingCards); if (CardsDiscarded != null) { CardsDiscardEventArgs cdea = null; List<Object> handledBy = new List<Object>(); Boolean actionPerformed = false; do { actionPerformed = false; cdea = new CardsDiscardEventArgs(fromLocation, matchingCards); cdea.HandledBy.AddRange(handledBy); CardsDiscarded(this, cdea); handledBy = cdea.HandledBy; OptionCollection options = new OptionCollection(); IEnumerable<Tuple<Type, Type>> cardTypes = cdea.Actions.Keys; foreach (Tuple<Type, Type> key in cardTypes) options.Add(new Option(cdea.Actions[key].Text, false)); if (options.Count > 0) { options.Sort(); Choice choice = new Choice(String.Format("You discarded {0}", Utilities.StringUtility.Plural("card", matchingCards.Count)), options, this, cdea); ChoiceResult result = this.MakeChoice(choice); if (result.Options.Count > 0) { cdea.Actions.First(kvp => kvp.Value.Text == result.Options[0]).Value.Method(this, ref cdea); actionPerformed = true; } } } while (CardsDiscarded != null && actionPerformed); } }
void player_CardsDiscarding(object sender, CardsDiscardEventArgs e) { if (!e.Cards.Contains(this.PhysicalCard) || e.GetAction(TypeClass.Herbalist) != null || e.HandledBy.Contains(this) || (e.FromLocation != DeckLocation.InPlay && e.FromLocation != DeckLocation.SetAside && e.FromLocation != DeckLocation.InPlayAndSetAside)) return; if (e.Cards.Any(c => (c.Category & Cards.Category.Treasure) == Cards.Category.Treasure)) e.AddAction(TypeClass.Herbalist, new CardsDiscardAction(sender as Player, this, "Put a Treasure on your deck", player_Action, false)); }
void player_CardsDiscarding(object sender, CardsDiscardEventArgs e) { if (e.FromLocation != DeckLocation.InPlay && e.FromLocation != DeckLocation.SetAside && e.FromLocation != DeckLocation.InPlayAndSetAside) return; if (e.HandledBy.Contains(this)) return; if (e.Cards.Contains(this._SetAsideCardInPlay)) { e.AddAction(TypeClass.Prince, this._SetAsideCardInPlay.CardType, new CardsDiscardAction(sender as Player, this, String.Format("Set aside {0}", this._SetAsideCardInPlay), player_DiscardAction, true) { Data = this._SetAsideCardInPlay }); } else { } }
void player_CardsDiscarding(object sender, CardsDiscardEventArgs e) { Player player = (Player)sender; // Only allow this if no cards were bought this turn // We set this up right now because this action happens regardless of whether or not the card is "lost track of" if (e.Cards.Contains(this.PhysicalCard) && player.CurrentTurn.CardsBought.Count == 0 && (e.FromLocation == DeckLocation.InPlay || e.FromLocation == DeckLocation.SetAside || e.FromLocation == DeckLocation.InPlayAndSetAside)) _ShouldBeTrashed = true; if (e.GetAction(TypeClass.Hermit) != null || !_ShouldBeTrashed) return; e.AddAction(TypeClass.Hermit, new CardsDiscardAction(sender as Player, this, String.Format("Trash {0}", this.PhysicalCard), player_Action, true)); }
void player_CardsDiscarded(object sender, CardsDiscardEventArgs e) { Player player = sender as Player; // Already being processed or been handled -- don't need to process this one if (e.GetAction(TypeClass.Tunnel) != null || e.HandledBy.Contains(this)) return; if (e.Cards.Contains(this.PhysicalCard) && player.Phase != PhaseEnum.Cleanup) e.AddAction(TypeClass.Tunnel, new CardsDiscardAction(this.Owner, this, String.Format("Reveal {0}", this.PhysicalCard), player_DiscardTunnel, false)); }
void player_CardsDiscarding(object sender, CardsDiscardEventArgs e) { Player player = (Player)sender; foreach (Card card in _CardsToTopDeck) { if (e.GetAction(TypeClass.Scheme, card.CardType) != null || player.ResolveDeck(e.FromLocation)[c => c == card].Count == 0) continue; e.AddAction(TypeClass.Scheme, card.CardType, new CardsDiscardAction(player, this, String.Format("Put {0} on your deck", card), player_DiscardAction, true) { Data = card }); } }
void player_CardsDiscarding(object sender, CardsDiscardEventArgs e) { if (!e.Cards.Contains(this.PhysicalCard) || e.GetAction(TypeClass.Treasury) != null || e.HandledBy.Contains(this) || (e.FromLocation != DeckLocation.InPlay && e.FromLocation != DeckLocation.SetAside && e.FromLocation != DeckLocation.InPlayAndSetAside)) return; // Only allow this if no Victory cards were bought this turn if (!((sender as Player).CurrentTurn.CardsBought.Any(c => (c.Category & Cards.Category.Victory) == Cards.Category.Victory))) e.AddAction(TypeClass.Treasury, new CardsDiscardAction(sender as Player, this, String.Format("Put {0} on your deck", this.PhysicalCard), player_Action, false)); }