public override CardSource AskIfCardSourceIsReplaced(CardSource cardSource, GameAction gameAction = null, ITrigger trigger = null) { if (cardSource == null || !cardSource.AllowReplacements || this._copiedCard == null || !this._copiedCard.Equals(cardSource.Card) || cardSource.AssociatedCardSources.All(acs => acs.Card != this.Card) || !ShouldSwapCardSources(cardSource, trigger)) { return(null); } CardSource newCardSource = (from cs in cardSource.AssociatedCardSources where cs.CardController == this select cs).LastOrDefault <CardSource>(); if (newCardSource == null) { return(null); } if (newCardSource.AssociatedCardSources.All(cs => cs.CardController != cardSource.CardController)) { newCardSource.AddAssociatedCardSource(cardSource); } cardSource.RemoveAssociatedCardSourcesWhere(cs => cs.CardController == this); return(newCardSource); }
protected virtual IEnumerator TrackOriginalTargetsAndRunResponse(DealDamageAction dd, CardSource cardSource, params object[] otherItems) { if (!cardSource.AssociatedCardSources.Contains(baseCardSource)) { // Indicate this is a related card for that damage instance only! if (this.IsRealAction()) { cardSource.AddAssociatedCardSource(baseCardSource); } // Best way to 'track' to make sure only base instances of damage trigger the effect. IEnumerator coroutine = RunResponse(dd, cardSource, otherItems); if (this.UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } if (this.IsRealAction()) { cardSource.RemoveAssociatedCardSourcesWhere((CardSource cs) => cs == baseCardSource); } } }