Пример #1
0
        public override void Setup(Game game, Supply supply)
        {
            base.Setup(game, supply);

            IList <Card> availableCards = null;

            try
            {
                if (game.Settings.Preset != null)
                {
                    availableCards = game.Settings.Preset.CardCards[game.Settings.Preset.Cards.First(c => c.CardType == typeof(BlackMarket))];
                    // Shuffle the preset cards -- these should definitely not be set up in a known order
                    Utilities.Shuffler.Shuffle(availableCards);
                }
                else
                {
                    int cardsToUse = 25;
                    //Boolean errorOnNotEnoughCards = true;
                    Boolean shouldUseGameConstraints   = true;
                    ConstraintCollection bmConstraints = new ConstraintCollection();
                    if (game.Settings.CardSettings.ContainsKey("Black Market"))
                    {
                        CardsSettings bmSettings = game.Settings.CardSettings["Black Market"];
                        cardsToUse = (int)bmSettings.CardSettingCollection[typeof(BlackMarket.BlackMarket_NumberOfCards)].Value;
                        //errorOnNotEnoughCards = (Boolean)bmSettings.CardSettingCollection[typeof(BlackMarket.BlackMarket_ErrorOnNotEnoughCards)].Value;
                        shouldUseGameConstraints = (Boolean)bmSettings.CardSettingCollection[typeof(BlackMarket.BlackMarket_UseGameConstraints)].Value;
                        bmConstraints            = (ConstraintCollection)bmSettings.CardSettingCollection[typeof(BlackMarket.BlackMarket_Constraints)].Value;
                    }

                    // need to set up a supply pile for Black Market; randomly pick an unused supply card and add it to the pile until we have the requisite number of cards
                    availableCards = game.CardsAvailable;
                    if (shouldUseGameConstraints)
                    {
                        // Skip all "Must Use" constraints
                        ConstraintCollection constraints = new ConstraintCollection(game.Settings.Constraints.Where(c => c.ConstraintType != ConstraintType.CardMustUse));
                        availableCards = constraints.SelectCards(availableCards, cardsToUse);
                    }
                    else
                    {
                        availableCards = bmConstraints.SelectCards(availableCards, cardsToUse);
                    }
                }
            }
            catch (DominionBase.Cards.ConstraintException ce)
            {
                throw new BlackMarketConstraintException(String.Format("Problem setting up Black Market constraints: {0}", ce.Message));
            }

            foreach (Card cardToUse in availableCards)
            {
                game.CardsAvailable.Remove(cardToUse);
                supply.AddTo(cardToUse);
            }
        }
Пример #2
0
        public override void Setup(Game game, Supply supply)
        {
            base.Setup(game, supply);

            Card baneCard = null;

            try
            {
                if (game.Settings.Preset != null)
                {
                    baneCard = game.Settings.Preset.CardCards[game.Settings.Preset.Cards.First(c => c.CardType == this.CardType)].ElementAt(0);
                }
                else
                {
                    IList <Card>         availableBaneCards       = null;
                    Boolean              shouldUseGameConstraints = true;
                    ConstraintCollection ywConstraints            = new ConstraintCollection();
                    if (game.Settings.CardSettings.ContainsKey(this.Name))
                    {
                        CardsSettings ywSettings = game.Settings.CardSettings[this.Name];
                        shouldUseGameConstraints = (Boolean)ywSettings.CardSettingCollection[typeof(YoungWitch_UseGameConstraints)].Value;
                        ywConstraints            = (ConstraintCollection)ywSettings.CardSettingCollection[typeof(YoungWitch_Constraints)].Value;
                    }

                    // need to setup a bane supply pile here; randomly pick an unused supply card type of cost $2 or $3 from
                    // the Kingdom cards, create a new supply pile of it, and mark it with a Bane token
                    availableBaneCards = game.CardsAvailable.Where(c => c.BaseCost == new Cost(2) || c.BaseCost == new Cost(3)).ToList();
                    if (shouldUseGameConstraints)
                    {
                        // Skip all "Must Use" constraints
                        ConstraintCollection constraints = new ConstraintCollection(game.Settings.Constraints.Where(c => c.ConstraintType != ConstraintType.CardMustUse));
                        availableBaneCards = constraints.SelectCards(availableBaneCards, 1);
                    }
                    else
                    {
                        availableBaneCards = ywConstraints.SelectCards(availableBaneCards, 1);
                    }
                    baneCard = availableBaneCards[0];
                }
            }
            catch (DominionBase.Cards.ConstraintException ce)
            {
                throw new YoungWitchConstraintException(String.Format("Problem setting up Young Witch constraints: {0}", ce.Message));
            }

            game.CardsAvailable.Remove(baneCard);
            game.Table.AddKingdomSupply(game.Players, baneCard.CardType);
            game.Table.Supplies[baneCard].Setup();
            game.Table.Supplies[baneCard].SnapshotSetup();
            game.Table.Supplies[baneCard].AddToken(new BaneToken());
        }
Пример #3
0
		public override void Setup(Game game, Supply supply)
		{
			base.Setup(game, supply);

			IList<Card> availableCards = null; 
			try
			{
				if (game.Settings.Preset != null)
				{
					availableCards = game.Settings.Preset.CardCards[game.Settings.Preset.Cards.First(c => c.CardType == typeof(BlackMarket))];
					// Shuffle the preset cards -- these should definitely not be set up in a known order
					Utilities.Shuffler.Shuffle(availableCards);
				}
				else
				{
					int cardsToUse = 25;
					//Boolean errorOnNotEnoughCards = true;
					Boolean shouldUseGameConstraints = true;
					ConstraintCollection bmConstraints = new ConstraintCollection();
					if (game.Settings.CardSettings.ContainsKey("Black Market"))
					{
						CardsSettings bmSettings = game.Settings.CardSettings["Black Market"];
						cardsToUse = (int)bmSettings.CardSettingCollection[typeof(BlackMarket.BlackMarket_NumberOfCards)].Value;
						//errorOnNotEnoughCards = (Boolean)bmSettings.CardSettingCollection[typeof(BlackMarket.BlackMarket_ErrorOnNotEnoughCards)].Value;
						shouldUseGameConstraints = (Boolean)bmSettings.CardSettingCollection[typeof(BlackMarket.BlackMarket_UseGameConstraints)].Value;
						bmConstraints = (ConstraintCollection)bmSettings.CardSettingCollection[typeof(BlackMarket.BlackMarket_Constraints)].Value;
					}

					// need to set up a supply pile for Black Market; randomly pick an unused supply card and add it to the pile until we have the requisite number of cards
					availableCards = game.CardsAvailable;
					if (shouldUseGameConstraints)
					{
						// Skip all "Must Use" constraints
						ConstraintCollection constraints = new ConstraintCollection(game.Settings.Constraints.Where(c => c.ConstraintType != ConstraintType.CardMustUse));
						availableCards = constraints.SelectCards(availableCards, cardsToUse);
					}
					else
						availableCards = bmConstraints.SelectCards(availableCards, cardsToUse);
				}
			}
			catch (DominionBase.Cards.ConstraintException ce)
			{
				throw new BlackMarketConstraintException(String.Format("Problem setting up Black Market constraints: {0}", ce.Message));
			}

			foreach (Card cardToUse in availableCards)
			{
				game.CardsAvailable.Remove(cardToUse);
				supply.AddTo(cardToUse);
			}
		}
Пример #4
0
		public override void Setup(Game game, Supply supply)
		{
			base.Setup(game, supply);

			Card baneCard = null;
			try
			{
				if (game.Settings.Preset != null)
				{
					baneCard = game.Settings.Preset.CardCards[game.Settings.Preset.Cards.First(c => c.CardType == this.CardType)].ElementAt(0);
				}
				else
				{
					IList<Card> availableBaneCards = null;
					Boolean shouldUseGameConstraints = true;
					ConstraintCollection ywConstraints = new ConstraintCollection();
					if (game.Settings.CardSettings.ContainsKey(this.Name))
					{
						CardsSettings ywSettings = game.Settings.CardSettings[this.Name];
						shouldUseGameConstraints = (Boolean)ywSettings.CardSettingCollection[typeof(YoungWitch_UseGameConstraints)].Value;
						ywConstraints = (ConstraintCollection)ywSettings.CardSettingCollection[typeof(YoungWitch_Constraints)].Value;
					}

					// need to setup a bane supply pile here; randomly pick an unused supply card type of cost $2 or $3 from
					// the Kingdom cards, create a new supply pile of it, and mark it with a Bane token
					availableBaneCards = game.CardsAvailable.Where(c => c.BaseCost == new Cost(2) || c.BaseCost == new Cost(3)).ToList();
					if (shouldUseGameConstraints)
					{
						// Skip all "Must Use" constraints
						ConstraintCollection constraints = new ConstraintCollection(game.Settings.Constraints.Where(c => c.ConstraintType != ConstraintType.CardMustUse));
						availableBaneCards = constraints.SelectCards(availableBaneCards, 1);
					}
					else
						availableBaneCards = ywConstraints.SelectCards(availableBaneCards, 1);
					baneCard = availableBaneCards[0];
				}
			}
			catch (DominionBase.Cards.ConstraintException ce)
			{
				throw new YoungWitchConstraintException(String.Format("Problem setting up Young Witch constraints: {0}", ce.Message));
			}

			game.CardsAvailable.Remove(baneCard);
			game.Table.AddKingdomSupply(game.Players, baneCard.CardType);
			game.Table.Supplies[baneCard].Setup();
			game.Table.Supplies[baneCard].SnapshotSetup();
			game.Table.Supplies[baneCard].AddToken(new BaneToken());
		}