using DominionBase.Enums; using DominionBase.Piles; using DominionBase.Players; using DominionBase.Properties; using System; using System.Diagnostics.Contracts; using System.Linq; namespace DominionBase.Cards.Cornucopia2ndEdition { public static class TypeClass { public static readonly Type BagOfGold = typeof(BagOfGold); public static readonly Type Fairgrounds = typeof(Fairgrounds); public static readonly Type FarmingVillage = typeof(FarmingVillage); public static readonly Type Followers = typeof(Followers); public static readonly Type FortuneTeller = typeof(FortuneTeller); public static readonly Type Hamlet = typeof(Hamlet); public static readonly Type HornOfPlenty = typeof(HornOfPlenty); public static readonly Type HorseTraders = typeof(HorseTraders); public static readonly Type HuntingParty = typeof(HuntingParty); public static readonly Type Jester = typeof(Jester); public static readonly Type Menagerie = typeof(Menagerie); public static readonly Type PrizeSupply = typeof(PrizeSupply); public static readonly Type Remake = typeof(Remake); public static readonly Type Tournament = typeof(Tournament); public static readonly Type TrustySteed = typeof(TrustySteed); public static readonly Type YoungWitch = typeof(YoungWitch); } public class BagOfGold : Cornucopia.BagOfGold { public BagOfGold() : base(Edition.Second) { } } public class Fairgrounds : Cornucopia.Fairgrounds { public Fairgrounds() : base(Edition.Second) { } } public class FarmingVillage : Cornucopia.FarmingVillage { public FarmingVillage() : base(Edition.Second) { } } public class Followers : Cornucopia.Followers { public Followers() : base(Edition.Second) { } } public class FortuneTeller : Cornucopia.FortuneTeller { public FortuneTeller() : base(Edition.Second) { } } public class Hamlet : Cornucopia.Hamlet { public Hamlet() : base(Edition.Second) { } } public class HornOfPlenty : Cornucopia.HornOfPlenty { public HornOfPlenty() : base(Edition.Second) { } } public class HorseTraders : Cornucopia.HorseTraders { public HorseTraders() : base(Edition.Second) { } } public class HuntingParty : Cornucopia.HuntingParty { public HuntingParty() : base(Edition.Second) { } } public class Jester : Cornucopia.Jester { public Jester() : base(Edition.Second) { } } public class Menagerie : Cornucopia.Menagerie { public Menagerie() : base(Edition.Second) { } } public class PrizeSupply : Card { public PrizeSupply() : base(Categories.Prize, Source.Cornucopia, Location.Invisible, edition: Edition.Second) { } public static void SetupSupply(IGame game) { Contract.Requires(game != null, "game cannot be null"); if (!game.Table.SpecialPiles.ContainsKey(TypeClass.PrizeSupply)) { var supply = new Supply(game, game.Players, TypeClass.PrizeSupply); supply.FullSetup(); game.Table.SpecialPiles.Add(TypeClass.PrizeSupply, supply); } } public override void SetupSupply(IGame game, ISupply supply) { Contract.Requires(supply != null, "supply cannot be null"); base.SetupSupply(game, supply); supply.AddTo(new BagOfGold()); supply.AddTo(new Cornucopia.Diadem()); supply.AddTo(new Followers()); supply.AddTo(new Cornucopia.Princess()); supply.AddTo(new TrustySteed()); } } public class Remake : Cornucopia.Remake { public Remake() : base(Edition.Second) { } } public class Tournament : Card { public Tournament() : base(Categories.Action, Source.Cornucopia, Location.Kingdom, Traits.IncludesExtraPiles | Traits.PlusCard | Traits.PlusAction | Traits.PlusCoin | Traits.Gainer | Traits.Discard | Traits.ConditionalBenefit, edition: Edition.Second) { BaseCost = new Cost(4); Benefit.Actions = 1; } public override void SetupSupply(IGame game, ISupply supply) { Contract.Requires(game != null, "game cannot be null"); base.SetupSupply(game, supply); PrizeSupply.SetupSupply(game); } public override void FollowInstructions(IPlayer player) { Contract.Requires(player != null, "player cannot be null"); base.FollowInstructions(player); var playerRevealedProvince = false; var anyoneElseRevealedProvince = false; // Perform on every player (including you) var enumerator = player._Game.GetPlayersStartingWithEnumerator(player); while (enumerator.MoveNext()) { var actor = enumerator.Current; if (actor.Hand[Universal.TypeClass.Province].Count == 0) continue; var showChoice = Choice.CreateYesNoChoice("Do you want to reveal a Province from your hand?", this, actor); var showResult = actor.MakeChoice(showChoice); if (showResult.Options[0] == Resource.Yes) { var shownProvince = actor.RetrieveCardFrom(DeckLocation.Hand, Universal.TypeClass.Province); actor.AddCardInto(DeckLocation.Revealed, shownProvince); if (actor == player) { playerRevealedProvince = true; } else { actor.AddCardInto(DeckLocation.Hand, actor.RetrieveCardFrom(DeckLocation.Revealed, shownProvince)); anyoneElseRevealedProvince = true; } } } if (playerRevealedProvince) { player.Discard(DeckLocation.Revealed); var prizes = (ISupply)player._Game.Table.SpecialPiles[TypeClass.PrizeSupply]; var isOptional = !((ISupply)player._Game.Table[Universal.TypeClass.Duchy]).Any() || !prizes.Any(); var cards = new CardCollection(prizes) { new Universal.Duchy() }; var prizeChoice = new Choice("Select a Prize or a Duchy", this, cards, ChoiceOutcome.Gain, player, minimum: isOptional ? 0 : 1); var prizeResult = player.MakeChoice(prizeChoice); if (prizeResult.Cards.Any()) { if (prizeResult.Cards[0] is Universal.Duchy) player.Gain(player._Game.Table.Duchy, this, DeckLocation.Deck, DeckPosition.Top); else player.Gain(prizes, prizeResult.Cards[0].Type, this, DeckLocation.Deck, DeckPosition.Top); } } if (!anyoneElseRevealedProvince) { var benefit = new CardBenefit { Cards = 1, Currency = new Currency(1) }; player.ReceiveBenefit(this, benefit); } } } public class TrustySteed : Cornucopia.TrustySteed { public TrustySteed() : base(Edition.Second) { } } public class YoungWitch : Cornucopia.YoungWitch { public YoungWitch() : base(Edition.Second) { } } }