public static CardInstance FindIdenticalCardInSource(IList <CardInstance> source, CardInstance card, IList <CardInstance> exclusions = null, bool failureOkay = false) { if (exclusions == null) { exclusions = new List <CardInstance>(); } CardInstance res = null; var cs = card.ToString(); foreach (var c in source) { if (!exclusions.Contains(c) && c.ToString() == cs) { return(c); } } if (res == null) { if (failureOkay) { return(null); } throw new Exception("No card."); } return(res); }
/// <summary> /// When we generate an action, we check to see if it's already a duplicate (in randoms or choices). This is how we compare them. /// </summary> public bool IsEqual(FightAction other) { if (FightActionType != other.FightActionType) { return(false); } if (CardInstance?.ToString() != other.CardInstance?.ToString()) { return(false); } if (Potion?.Name != other.Potion?.Name) { return(false); } if (Target?.Name != other.Target?.Name) { return(false); } if (CardTargets != null && other.CardTargets == null) { return(false); } if (CardTargets == null && other.CardTargets != null) { return(false); } if (!Helpers.CompareHands(CardTargets, other.CardTargets, out var msg2)) { return(false); } //if (Key != other.Key) return false; //we do not compare key here because this is at the "choice" stage. if (Random != other.Random) { return(false); } return(true); }