Esempio n. 1
0
        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);
        }
        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;
        }