void player_CleanedUp(object sender, CleanedUpEventArgs e) { if (_CardsDiscardingEventHandler != null) ((Player)sender).CardsDiscarding -= _CardsDiscardingEventHandler; if (_CleanedUpEventHandler != null) ((Player)sender).CleanedUp -= _CleanedUpEventHandler; _CardsToTopDeck.Clear(); _CardsDiscardingEventHandler = null; _CleanedUpEventHandler = null; }
internal void player_Action(Player player, ref CleaningUpEventArgs e) { if (_CleaningUpEventHandlers.Count > 0) { player.CleaningUp -= _CleaningUpEventHandlers[0]; _CleaningUpEventHandlers.RemoveAt(0); } CardCollection allInPlayCards = this.GetSelectableCards(e); if (allInPlayCards.Count > 0) { int schemeChoices = (int)e.Actions[TypeClass.Scheme].Data; Choice choice = new Choice( String.Format("Select up to {0} Action {1} to place on top of your deck", schemeChoices, Utilities.StringUtility.Plural("card", schemeChoices, false)), this, allInPlayCards, player, false, true, 0, schemeChoices); ChoiceResult result = player.MakeChoice(choice); _CardsToTopDeck.Clear(); foreach (Card cardToMove in result.Cards) _CardsToTopDeck.Add(cardToMove); if (_CardsToTopDeck.Count > 0) { _CardsDiscardingEventHandler = new Player.CardsDiscardingEventHandler(player_CardsDiscarding); e.CurrentPlayer.CardsDiscarding += _CardsDiscardingEventHandler; _CleanedUpEventHandler = new Player.CleanedUpEventHandler(player_CleanedUp); e.CurrentPlayer.CleanedUp += _CleanedUpEventHandler; } } }