private void CloseButton_Click(object sender, RoutedEventArgs e) { var button = e.OriginalSource as CardAcceptanceButton; CardAcceptanceDescription descr = button.CardAcceptanceDescription; StrategyDescription strategy = button.StrategyDescription; strategy.PurchaseOrderDescriptions.Remove(descr); }
public void PopulateFrom(Dominion.Strategy.Description.StrategyDescription descr) { this.Clear(); foreach (Dominion.Strategy.Description.CardAcceptanceDescription cardAcceptanceDescription in descr.purchaseOrderDescription.descriptions) { this.PurchaseOrderDescriptions.Add(CardAcceptanceDescription.PopulateFrom(cardAcceptanceDescription)); } foreach (Dominion.Strategy.Description.CardAcceptanceDescription cardAcceptanceDescription in descr.trashOrderDescription.descriptions) { this.TrashOrderDescriptions.Add(CardAcceptanceDescription.PopulateFrom(cardAcceptanceDescription)); } }
public static CardAcceptanceDescription PopulateFrom(Dominion.Strategy.Description.CardAcceptanceDescription descr) { var result = new CardAcceptanceDescription(); result.Card.Value = DominionCard.Create(descr.card); if (descr.matchDescriptions.Length != 1 && descr.matchDescriptions.Length != 2) { throw new Exception("Support only one match description in addition to count all owned"); } if (descr.matchDescriptions[0].countSource == Dominion.Strategy.Description.CountSource.Always) { result.Count.Value = CountAsManyAsPossible; } else if (descr.matchDescriptions[0].countSource == Dominion.Strategy.Description.CountSource.CountAllOwned && descr.matchDescriptions[0].cardType == descr.card && descr.matchDescriptions[0].comparison == Dominion.Strategy.Description.Comparison.LessThan) { result.Count.Value = descr.matchDescriptions[0].countThreshHold; } else { throw new Exception("First match description needs to describe how many of the card to own"); } if (descr.matchDescriptions.Length == 2) { result.TestCard.Value = descr.matchDescriptions[1].cardType != null?DominionCard.Create(descr.matchDescriptions[1].cardType) : null; result.Threshhold.Value = descr.matchDescriptions[1].countThreshHold; result.Comparison.Value = descr.matchDescriptions[1].comparison; result.CountSource.Value = descr.matchDescriptions[1].countSource; } else { result.CountSource.Value = Dominion.Strategy.Description.CountSource.Always; } return(result); }