public override CardCost ModifyValue(CardCost currentValue, ITreasureCard card) { if (card is Copper) return currentValue + 1; return currentValue; }
public void Can_convert_integer_to_CardCost() { CardCost cost = 5; cost.Money.ShouldEqual(5); cost.Potions.ShouldEqual(0); }
public void Can_compare_CardCost_to_integer() { CardCost cost = 5; int otherCost = 5; Assert.That(cost == otherCost); }
public void CardCost_of_5_is_enough_for_CardCost_of_5() { CardCost cost1 = 5; CardCost cost2 = 5; Assert.That(cost1.IsEnoughFor(cost2)); }
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)); }
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); }
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)); }
public void ThenPlayerShouldHaveToSpend(string playerName, string spend) { Game.ActivePlayer.Name.ShouldEqual(playerName); CardCost actualSpend = CardCost.Parse(spend); Game.CurrentTurn.AvailableSpend.ShouldEqual(actualSpend); }
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); }
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); }
public void CardCost_of_5_is_enough_for_CardCost_of_3() { CardCost cost5 = 5; CardCost cost3 = 3; Assert.That(cost5.IsEnoughFor(cost3)); }
protected Card(CardCost cost) { Id = Guid.NewGuid(); Cost = cost; _currentZone = new NullZone(); _zoneChanger = zone => _currentZone = zone; }
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); }
public void Null_CardCosts_are_equal() { CardCost cost1 = null; CardCost cost2 = null; Assert.AreEqual(cost1, cost2); Assert.That(cost1 == cost2); }
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); }
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); }
public void Can_explicitly_convert_from_string_to_CardCost() { string stringCost = "3P"; CardCost cost = (CardCost)stringCost; cost.Money.ShouldEqual(3); cost.Potions.ShouldEqual(1); }
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); }
public static ISelectionSpecification SelectPileCostingUpToX(CardCost costUpTo) { return(new SelectionSpecification { MatchFunction = cards => cards.Count() == 1 && costUpTo.IsEnoughFor(cards.Single()), ActivityType = ActivityType.SelectPile, Cost = costUpTo }); }
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 }; }
public static ISelectionSpecification SelectPileCostingExactlyX(CardCost cost) { return(new SelectionSpecification { MatchFunction = cards => cards.Count() == 1 && cost == cards.Single().Cost, ActivityType = ActivityType.SelectPile, Cost = cost }); }
public static ISelectionSpecification SelectPileCostingUpToX(CardCost costUpTo) { return new SelectionSpecification { MatchFunction = cards => cards.Count() == 1 && costUpTo.IsEnoughFor(cards.Single()), ActivityType = ActivityType.SelectPile, Cost = costUpTo }; }
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)); }
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; }
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); } }
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); } }; }
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 }; }
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); }
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; }
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 }); }
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); }
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(); }
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 }); }
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(); } }
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(); }
public virtual CardCost ModifyValue(CardCost currentValue, ITreasureCard card) { return currentValue; }
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); }
public AvailableSpendViewModel(CardCost availableSpend) { Money = availableSpend.Money; Potions = availableSpend.Potions; DisplayValue = availableSpend.ToString(); }
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); }
public bool CanGainOfCost(CardCost cardCost) { return Game.Bank.Piles.Any(p => !p.IsEmpty && p.TopCard.Cost == cardCost); }
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 }; }
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); }
public static SelectPileActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost) { return GainACardCostingUpToX(log, player, cost, player.Discards); }
public TestCard(CardCost cost) : base(cost) { }
public TestCardPile(CardCost cost) { AddCard(new TestCard(cost)); }
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) { }
public static GainACardActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost, ICard source) { return GainACardCostingUpToX(log, player, cost, player.Discards, source); }