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; }
void ActivePlayer_CardPutIntoPlay(object sender, CardPutIntoPlayEventArgs e) { if (e.Card != this && (e.Card.Category & Cards.Category.Attack) == Cards.Category.Attack) { Choice choicePlayer = Choice.CreateYesNoChoice(String.Format("Do you want to trash {0}?", this.PhysicalCard), this, e.Player); ChoiceResult resultPlayer = e.Player.MakeChoice(choicePlayer); if (resultPlayer.Options[0] == "Yes") { if (e.Player.InPlay.Contains(this.PhysicalCard)) e.Player.Trash(e.Player.RetrieveCardFrom(DeckLocation.InPlay, this.PhysicalCard)); else if (e.Player.SetAside.Contains(this.PhysicalCard)) e.Player.Trash(e.Player.RetrieveCardFrom(DeckLocation.SetAside, this.PhysicalCard)); else return; e.Player.Gain(e.Player._Game.Table.SpecialPiles[TypeClass.Mercenary]); } } }
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; }
void player_CardPuttingIntoPlay(object sender, CardPutIntoPlayEventArgs e) { if (e.Card != this) return; if (this.ClonedCard == null) { Choice choice = new Choice("Name a card to clone this card as", this, new SupplyCollection(e.Player._Game.Table.Supplies.Where(kvp => (kvp.Value.Category & Cards.Category.Action) == Cards.Category.Action && kvp.Value.Count > 0 && kvp.Value.CurrentCost < e.Player._Game.ComputeCost(this))), e.Player, false); ChoiceResult result = e.Player.MakeChoice(choice); if (result.Supply != null) { e.Player._Game.SendMessage(e.Player, this, result.Supply.TopCard); this.ClonedCard = Card.CreateInstance(result.Supply.TopCard.CardType); this.ClonedCard.PhysicalCard = this; // This is needed in order to set up player mats & any other acutrements this.ClonedCard.ReceivedBy(e.Player); } else e.Player._Game.SendMessage(e.Player, this, (ICard)null); } }