Пример #1
0
            public override CardCost ModifyValue(CardCost currentValue, ITreasureCard card)
            {
                if (card is Copper)
                    return currentValue + 1;

                return currentValue;
            }
Пример #2
0
        public void Can_convert_integer_to_CardCost()
        {
            CardCost cost = 5;

            cost.Money.ShouldEqual(5);
            cost.Potions.ShouldEqual(0);
        }
Пример #3
0
        public void Can_compare_CardCost_to_integer()
        {
            CardCost cost      = 5;
            int      otherCost = 5;

            Assert.That(cost == otherCost);
        }
Пример #4
0
        public void CardCost_of_5_is_enough_for_CardCost_of_5()
        {
            CardCost cost1 = 5;
            CardCost cost2 = 5;

            Assert.That(cost1.IsEnoughFor(cost2));
        }
Пример #5
0
        public void CardCost_of_2P_is_enough_for_CardCost_of_2P()
        {
            CardCost cost1 = CardCost.Parse("2P");
            CardCost cost2 = CardCost.Parse("2P");

            Assert.That(cost1.IsEnoughFor(cost2));
        }
Пример #6
0
 public void Can_create_CardCost_by_subtracting_from_existing_CardCost()
 {
     CardCost cost = new CardCost(5);
     var newCost = cost - 2;
     newCost.Money.ShouldEqual(3);
     newCost.Potions.ShouldEqual(0);
 }
Пример #7
0
        public void CardCost_of_3P_is_not_enough_for_CardCost_of_5()
        {
            CardCost cost5  = 5;
            CardCost cost3P = CardCost.Parse("3P");

            Assert.False(cost3P.IsEnoughFor(cost5));
        }
Пример #8
0
        public void ThenPlayerShouldHaveToSpend(string playerName, string spend)
        {
            Game.ActivePlayer.Name.ShouldEqual(playerName);
            CardCost actualSpend = CardCost.Parse(spend);

            Game.CurrentTurn.AvailableSpend.ShouldEqual(actualSpend);
        }
Пример #9
0
            public void AddGainActivity(IGameLog log, Player player, CardCost upToCost, ICard source)
            {
                var activity = Activities.GainACardCostingUpToX(log, player, upToCost, player.Hand, source);

                activity.Specification.CardTypeRestriction = typeof(ITreasureCard);
                _activities.Add(activity);
            }
Пример #10
0
 public void Can_create_CardCost_by_adding_to_existing_CardCost()
 {
     CardCost cost = new CardCost(5);
     cost += 2;
     cost.Money.ShouldEqual(7);
     cost.Potions.ShouldEqual(0);
 }
Пример #11
0
        public void CardCost_of_5_is_enough_for_CardCost_of_3()
        {
            CardCost cost5 = 5;
            CardCost cost3 = 3;

            Assert.That(cost5.IsEnoughFor(cost3));
        }
Пример #12
0
 protected Card(CardCost cost)
 {
     Id = Guid.NewGuid();
     Cost = cost;
     _currentZone = new NullZone();
     _zoneChanger = zone => _currentZone = zone;            
 }
Пример #13
0
        public void Can_create_CardCost_by_subtracting_from_existing_CardCost()
        {
            CardCost cost    = new CardCost(5);
            var      newCost = cost - 2;

            newCost.Money.ShouldEqual(3);
            newCost.Potions.ShouldEqual(0);
        }
Пример #14
0
        public void Can_create_CardCost_by_adding_to_existing_CardCost()
        {
            CardCost cost = new CardCost(5);

            cost += 2;
            cost.Money.ShouldEqual(7);
            cost.Potions.ShouldEqual(0);
        }
Пример #15
0
        public void Can_parse_string_with_potions_as_CardCost()
        {
            string   stringCost = "3PP";
            CardCost cost       = CardCost.Parse(stringCost);

            cost.Money.ShouldEqual(3);
            cost.Potions.ShouldEqual(2);
        }
Пример #16
0
        public void Null_CardCosts_are_equal()
        {
            CardCost cost1 = null;
            CardCost cost2 = null;

            Assert.AreEqual(cost1, cost2);
            Assert.That(cost1 == cost2);
        }
Пример #17
0
        public void CardCosts_with_same_values_are_equal()
        {
            CardCost cost1 = new CardCost(3, 1);
            CardCost cost2 = new CardCost(3, 1);

            Assert.AreEqual(cost1, cost2);
            Assert.That(cost1 == cost2);
        }
Пример #18
0
        public void ThenPlayerMustGainACardOfCostOrLess(string playerName, string cost)
        {
            var      player   = Game.Players.Single(p => p.Name == playerName);
            var      activity = (ISelectPileActivity)Game.GetPendingActivity(player);
            CardCost cardCost = CardCost.Parse(cost);

            activity.GetCostProperty().ShouldEqual(cardCost);
        }
Пример #19
0
        public void Can_explicitly_convert_from_string_to_CardCost()
        {
            string   stringCost = "3P";
            CardCost cost       = (CardCost)stringCost;

            cost.Money.ShouldEqual(3);
            cost.Potions.ShouldEqual(1);
        }
Пример #20
0
 public void CardCost_3P_minus_CardCost_2P_equals_1()
 {
     CardCost cost3P = new CardCost(3, 1);
     CardCost cost2P = new CardCost(2, 1);
     var newCost = cost3P - cost2P;
     newCost.Money.ShouldEqual(1);
     newCost.Potions.ShouldEqual(0);
 }
Пример #21
0
        public void CardCost_3P_minus_CardCost_2P_equals_1()
        {
            CardCost cost3P  = new CardCost(3, 1);
            CardCost cost2P  = new CardCost(2, 1);
            var      newCost = cost3P - cost2P;

            newCost.Money.ShouldEqual(1);
            newCost.Potions.ShouldEqual(0);
        }
Пример #22
0
 public static ISelectionSpecification SelectPileCostingUpToX(CardCost costUpTo)
 {
     return(new SelectionSpecification
     {
         MatchFunction = cards => cards.Count() == 1 && costUpTo.IsEnoughFor(cards.Single()),
         ActivityType = ActivityType.SelectPile,
         Cost = costUpTo
     });
 }
Пример #23
0
            public override CardCost ModifyValue(CardCost currentValue, ITreasureCard card)
            {
                if (card is Copper)
                {
                    return(currentValue + 1);
                }

                return(currentValue);
            }
 public static ISelectionSpecification SelectPileCostingExactlyX(CardCost cost)
 {
     return new SelectionSpecification
     {
         MatchFunction = cards => cards.Count() == 1 && cost == cards.Single().Cost,
         ActivityType = ActivityType.SelectPile,
         Cost = cost
     };
 }
Пример #25
0
 public static ISelectionSpecification SelectPileCostingExactlyX(CardCost cost)
 {
     return(new SelectionSpecification
     {
         MatchFunction = cards => cards.Count() == 1 && cost == cards.Single().Cost,
         ActivityType = ActivityType.SelectPile,
         Cost = cost
     });
 }
Пример #26
0
 public static ISelectionSpecification SelectPileCostingUpToX(CardCost costUpTo)
 {
     return new SelectionSpecification
     {
         MatchFunction = cards => cards.Count() == 1 && costUpTo.IsEnoughFor(cards.Single()),
         ActivityType = ActivityType.SelectPile,
         Cost = costUpTo
     };
 }
Пример #27
0
        public void ThenPlayer1MayGainAnActionCardOfCost5OrLess(string playerName, string cost)
        {
            var      player   = Game.Players.Single(p => p.Name == playerName);
            var      activity = (ISelectPileActivity)Game.GetPendingActivity(player);
            CardCost cardCost = CardCost.Parse(cost);

            activity.IsOptional.ShouldBeTrue();
            activity.GetCostProperty().ShouldEqual(cardCost);
            activity.GetTypeRestrictionProperty().ShouldEqual(typeof(IActionCard));
        }
Пример #28
0
    void Start()
    {
        // Change card variable to physical copy here

        this.name = CardName + " Card";
        transform.Find("CardName").GetComponent <Text>().text       = CardName;
        transform.Find("CardDecription").GetComponent <Text>().text = CardDescription;
        transform.Find("CardCost").GetComponent <Text>().text       = CardCost.ToString();

        GetComponentInParent <Draggable>().cardType = CardTypes.Utility;
    }
Пример #29
0
 private void AddGainActivityForCost(TurnContext context, ICard source, CardCost cost)
 {
     if (context.CanGainOfCost(cost))
     {
         var gainActivity = Activities.GainACardCostingExactlyX(context.Game.Log, context.ActivePlayer,
                                                                cost, context.ActivePlayer.Discards, source);
         _activities.Add(gainActivity);
     }
     else
     {
         context.Game.Log.LogMessage("{0} could gain no card of appropriate cost", context.ActivePlayer);
     }
 }
Пример #30
0
 public static SelectPileActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost, CardZone destination)
 {
     return new SelectPileActivity(log, player, string.Format("Select a card to gain of cost {0} or less", cost),
                                   SelectionSpecifications.SelectPileCostingUpToX(cost))
     {
         AfterPileSelected = pile =>
         {
             var card = pile.TopCard;
             card.MoveTo(destination);
             log.LogGain(player, card);
         }
     };
 }
Пример #31
0
 private void AddGainActivityForCost(TurnContext context, ICard source, CardCost cost)
 {
     if (context.CanGainOfCost(cost))
     {
         var gainActivity = Activities.GainACardCostingExactlyX(context.Game.Log, context.ActivePlayer,
                                                                cost, context.ActivePlayer.Discards, source);
         _activities.Add(gainActivity);
     }
     else
     {
         context.Game.Log.LogMessage("{0} could gain no card of appropriate cost", context.ActivePlayer);
     }
 }
Пример #32
0
 public static SelectPileActivity GainACardCostingExactlyX(IGameLog log, Player player, CardCost cost, CardZone destination, ICard source)
 {
     return new SelectPileActivity(log, player, string.Format("Select a card to gain with a cost of exactly {0}", cost),
                                   SelectionSpecifications.SelectPileCostingExactlyX(cost), source)
     {
         AfterPileSelected = pile =>
         {
             var card = pile.TopCard;
             card.MoveTo(destination);
             log.LogGain(player, card);
         },
         Hint = ActivityHint.GainCards
     };
 }
Пример #33
0
    public Card deepCopy()
    {
        Card c = new Card(getName(), deck);

        CardCost cos = cost.deepCopy();

        c.setCost(cos);

        foreach (Effect eff in effects)
        {
            Effect effCopy = eff.deepCopy();
            c.addEffect(effCopy);
        }
        return(c);
    }
Пример #34
0
        public static void handleCardCost(HtmlNode costRow, ref WixossCard wixossCard)
        {
            // Find all 'a' tags
            List <HtmlNode> imgNodes = costRow.Descendants().Where
                                           (x => (x.Name == "a")).ToList();

            List <CardCost> costForCard  = new List <CardCost>();
            List <long>     cardCostList = new List <long>();

            // Loop thru all card cost values
            // We first removeHTML then split it based on 'x'
            // i.e 1Gx1W becomes ['1G','1W']
            foreach (var item in removeHTML(costRow.InnerText).Split(new String[] { " x " }, StringSplitOptions.RemoveEmptyEntries))
            {
                // Make sure its not just whitespace
                if (item.Trim() != "")
                {
                    String cleanedItem = item;

                    // sometimes its an 'or' not just 'x'
                    if (item.Contains("or"))
                    {
                        cleanedItem = item.Split(' ')[0];
                    }

                    cardCostList.Add(Convert.ToInt16(cleanedItem.Trim()));
                }
            }

            // Loop thru all img nodes, because those contain what color to use
            for (int i = 0; i < imgNodes.Count; i++)
            {
                CardCost cost = new CardCost();

                if (i < cardCostList.Count)
                {
                    cost.NumberPerColor = (int)cardCostList[i];
                }
                else
                {
                    cost.NumberPerColor = 0;
                }

                cost.Color = colorFromName(imgNodes[i].Attributes["title"].Value);
                costForCard.Add(cost);
            }
            wixossCard.Cost = costForCard;
        }
Пример #35
0
        public async Task Update(CardCost cardCost)
        {
            var cardCostEntity = await _cardCostConfigurationRepository.GetByCountryAsync(cardCost.Country);

            if (cardCostEntity is null)
            {
                throw new CardCostNotConfiguredException($"Card cost with key {cardCost.Country} not configured.");
            }

            await _cardCostConfigurationRepository.UpdateAsync(
                new CardCostEntity
            {
                Cost    = cardCost.Cost,
                Country = cardCost.Country
            });
        }
Пример #36
0
    public CardCost deepCopy()
    {
        CardCost c = new CardCost();

        foreach (DictionaryOfStringAndString cos in cost)
        {
            DictionaryOfStringAndString newD = new DictionaryOfStringAndString();

            foreach (KeyValuePair <string, string> attach in cos)
            {
                newD.Add(attach.Key, attach.Value);
            }
            c.addCostDict(newD);
        }
        return(c);
    }
Пример #37
0
        public void ThenPlayerMustGainACardOfExactCost(string playerName, string costString)
        {
            var player   = Game.Players.Single(p => p.Name == playerName);
            var cost     = CardCost.Parse(costString);
            var activity = (ISelectPileActivity)Game.GetPendingActivity(player);

            activity.GetCostProperty().ShouldEqual(cost);

            var matchingPile = new TestCardPile(cost);

            activity.Specification.IsMatch(matchingPile).ShouldBeTrue();

            var lowMismatchPile = new TestCardPile(cost - 1);

            activity.Specification.IsMatch(lowMismatchPile).ShouldBeFalse();
        }
Пример #38
0
        public async Task Add(CardCost cardCost)
        {
            var cardCostEntity = await _cardCostConfigurationRepository.GetByCountryAsync(cardCost.Country);

            if (cardCostEntity != null)
            {
                throw new CardCostAlreadyExistsException(
                          $"Card cost with key {cardCost.Country} already configured.");
            }

            await _cardCostConfigurationRepository.AddAsync(
                new CardCostEntity
            {
                Cost    = cardCost.Cost,
                Country = cardCost.Country
            });
        }
Пример #39
0
        private bool HaveEnoughResources(CardCost cost)
        {
            switch (cost.ResourceType)
            {
            case ResourceType.Uranus:
                return(_playerData.Uranus >= cost.ResourceAmount);

            case ResourceType.Energy:
                return(_playerData.Energy >= cost.ResourceAmount);

            case ResourceType.Slaves:
                return(_playerData.Slaves >= cost.ResourceAmount);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #40
0
    public void setupCard(string name, Deck d)
    {
        setDeck(d);
        cardName = name;
        if (cost == null)
        {
            cost = new CardCost();
        }

        if (effects == null)
        {
            effects = new List <Effect>();
            Effect e = new Effect(this);
            effects.Add(e);
        }
        setupEffects();
        setupDesc();
    }
Пример #41
0
 public virtual CardCost ModifyValue(CardCost currentValue, ITreasureCard card)
 {
     return currentValue;
 }
Пример #42
0
 public void AddGainActivity(IGameLog log, Player player, CardCost upToCost)
 {
     var activity = Activities.GainACardCostingUpToX(log, player, upToCost, player.Hand);
     activity.Specification.CardTypeRestriction = typeof (ITreasureCard);
     _activities.Add(activity);
 }
Пример #43
0
 public AvailableSpendViewModel(CardCost availableSpend)
 {
     Money = availableSpend.Money;
     Potions = availableSpend.Potions;
     DisplayValue = availableSpend.ToString();
 }
Пример #44
0
 public static GainACardActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost, CardZone destination, ICard source)
 {
     return new GainACardActivity(log, player, string.Format("Select a card to gain of cost {0} or less.", cost),
                                  SelectionSpecifications.SelectPileCostingUpToX(cost), destination, source);
 }
Пример #45
0
 public bool CanGainOfCost(CardCost cardCost)
 {
     return Game.Bank.Piles.Any(p => !p.IsEmpty && p.TopCard.Cost == cardCost);
 }
Пример #46
0
 public static ISelectPileActivity SelectACardForOpponentToGain(TurnContext context, Player player, Player victim, CardCost cost, ICard source)
 {
     return new SelectPileActivity(context.Game.Log, player, string.Format("Select a card for {0} to gain of cost {1}.", victim.Name, cost),
                                   SelectionSpecifications.SelectPileCostingExactlyX(cost), source)
     {
         AfterPileSelected = pile =>
         {                    
             var card = pile.TopCard;
             card.MoveTo(victim.Discards);
             context.Game.Log.LogGain(victim, card);
         },
         Hint = ActivityHint.OpponentGainCards
     };
 }
Пример #47
0
 public static GainACardActivity GainACardCostingExactlyX(IGameLog log, Player player, CardCost cost, CardZone destination, ICard source)
 {
     return new GainACardActivity(log, player,
                                  string.Format("Select a card to gain with a cost of exactly {0}.", cost),
                                  SelectionSpecifications.SelectPileCostingExactlyX(cost), destination, source);
 }
Пример #48
0
 public static SelectPileActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost)
 {
     return GainACardCostingUpToX(log, player, cost, player.Discards);
 }
Пример #49
0
 public TestCard(CardCost cost)
     : base(cost)
 {
 }
Пример #50
0
        public void CardCosts_with_same_values_are_equal()
        {
            CardCost cost1 = new CardCost(3, 1);
            CardCost cost2 = new CardCost(3, 1);

            Assert.AreEqual(cost1, cost2);
            Assert.That(cost1 == cost2);
        }
Пример #51
0
 public TestCardPile(CardCost cost)
 {
     AddCard(new TestCard(cost));
 }
Пример #52
0
 public DoBuysActivity(Player activePlayer, int buys, CardCost buyValue)
     : base(null, activePlayer, string.Format("Select card(s) to buy. You have {0} buy(s) for a total of {1}.", buys, buyValue), ActivityType.DoBuys, null)
 {
 }
Пример #53
0
 public static GainACardActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost, ICard source)
 {
     return GainACardCostingUpToX(log, player, cost, player.Discards, source);
 }