コード例 #1
0
ファイル: Player.cs プロジェクト: brocwoodworth/DMS
        public void ActionPhase(Kingdom myKingdom)
        {
            bool readyForBuyPhase = false;

            do
            {
                int index = 1;
                ClearIndex(myKingdom);
                foreach (Card card in inHand.Cards)
                {
                    if (card.types.Contains(Card.Type.Action))
                    {
                        card.index = index++;
                    }
                }

                inHand.PrintDeck();
                Console.WriteLine("\r\nSelect Actions to play from your hand. [#] = Play specific action. [D] = Done playing actions.");
                Console.WriteLine("Actions:" + Actions + ", Buys: " + Buys + ", Dollars: " + Dollars + ".");

                string playActionInput = Console.ReadLine().ToLower();

                if (playActionInput == "d")
                {
                    readyForBuyPhase = true;
                }
                else
                {
                    int intplayActionInput = -1;
                    if (Int32.TryParse(playActionInput, out intplayActionInput))
                    {
                        if (intplayActionInput > 0 && intplayActionInput < index)
                        {
                            for (int i = 0; i < inHand.Cards.Count; i++)
                            {
                                if (inHand.Cards[i].index == intplayActionInput)
                                {
                                    PlayAction(inHand.Cards[i], myKingdom);
                                    Actions--;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("Invalid Input.");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid Input.");
                    }
                }

                if (Actions <= 0 || !HasActions())
                {
                    readyForBuyPhase = true;
                }
            } while (!readyForBuyPhase);
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: brocwoodworth/DMS
 public void PlayAction(Card card, Kingdom myKingdom)
 {
     if (card.types.Contains(Card.Type.Action))
     {
         switch (card.expansion)
         {
         case Card.Expansion.BaseSet:
             inHand.Cards.Remove(card);
             inPlay.Cards.Add(card);
             PlayBaseSetAction(card, myKingdom);
             break;
         }
     }
 }
コード例 #3
0
ファイル: Player.cs プロジェクト: brocwoodworth/DMS
 public void GainCardByName(string cardName, bool optional, Kingdom myKingdom, Deck.State state = Deck.State.discardPile)
 {
     foreach (Deck deck in myKingdom.KingdomSupply)
     {
         if (deck.Cards.Count > 0)
         {
             if (deck.Cards[0].name == cardName)
             {
                 Card cardToGain = deck.Cards[deck.Cards.Count - 1];
                 GainCard(cardToGain, deck, state);
                 return;
             }
         }
     }
     Console.WriteLine("\r\nNo " + cardName + " available.\r\n");
 }
コード例 #4
0
ファイル: Player.cs プロジェクト: brocwoodworth/DMS
 public void Trash(Card card, Kingdom myKingdom)
 {
     if (inPlay.Cards.Contains(card))
     {
         inPlay.Cards.Remove(card);
     }
     if (inHand.Cards.Contains(card))
     {
         inHand.Cards.Remove(card);
     }
     if (discardPile.Cards.Contains(card))
     {
         discardPile.Cards.Remove(card);
     }
     if (drawPile.Cards.Contains(card))
     {
         drawPile.Cards.Remove(card);
     }
     myKingdom.Trash.Cards.Add(card);
 }
コード例 #5
0
ファイル: Player.cs プロジェクト: brocwoodworth/DMS
        public void ClearIndex(Kingdom myKingdom)
        {
            foreach (Card card in discardPile.Cards)
            {
                card.index = -1;
            }

            foreach (Card card in drawPile.Cards)
            {
                card.index = -1;
            }

            foreach (Deck deck in myKingdom.KingdomSupply)
            {
                if (deck.Cards.Count > 0)
                {
                    deck.Cards[0].index = -1;
                }
            }
        }
コード例 #6
0
ファイル: Player.cs プロジェクト: brocwoodworth/DMS
        //Discard all cards in hand and all cards in play. Draw 5 new cards (and shuffle if necessary)
        //Set number of buys and actions to 1, and dollars to 0
        //Reset index on all cards
        public void Cleanup(Kingdom myKingdom)
        {
            for (int i = inHand.Cards.Count - 1; i >= 0; i--)
            {
                Discard(inHand.Cards[i]);
            }
            for (int i = inPlay.Cards.Count - 1; i >= 0; i--)
            {
                ClearFromPlay(inPlay.Cards[i]);
            }

            ClearIndex(myKingdom);

            Turns++;

            DrawCard(5);
            Buys    = 1;
            Actions = 1;
            Dollars = 0;
        }
コード例 #7
0
        static void Main(string[] args)
        {
            bool gameOver = false;

            Player Broc = new Player("Broc");

            Kingdom.SetName chosenSet = Kingdom.SetName.Random;
            Console.Write("\r\nWelcome to Dominion Mimicing Software!\r\n\r\n Please choose a recommended Set of 10 from the list below, or anything else for Random.\r\n\r\n");
            Console.Write("[1]: First Game\r\n[2]: Size Distortion\r\n[3]: Deck Top\r\n[4]: Sleight of Hand\r\n[5]: Improvements\r\n[6]: Silver & Gold\r\n\r\n");
            string chosenSetInput = Console.ReadLine().ToLower();
            int    intChosenSet   = -1;

            if (Int32.TryParse(chosenSetInput, out intChosenSet))
            {
                if (intChosenSet >= 0 && intChosenSet <= 6)
                {
                    chosenSet = (Kingdom.SetName)intChosenSet;
                }
            }
            Kingdom myKingdom = new Kingdom((Kingdom.SetName)intChosenSet, 1, false);

            do
            {
                Broc.StartTurn();
                do
                {
                    myKingdom.PrintKingdom();
                    if (Broc.HasActions())
                    {
                        Broc.PrintHand();
                        Console.Write("\r\nA to play an action. B to go to buy phase. T to print Trash. H for help. Q to quit.\r\n");
                        Console.Write("Actions: " + Broc.Actions + ", Buys: " + Broc.Buys + ", Dollars: " + Broc.Dollars + ".\r\n");
                        switch (Console.ReadLine().ToLower())
                        {
                        case "a":
                            Broc.ActionPhase(myKingdom);
                            break;

                        case "b":
                            Broc.BuyPhase(myKingdom);
                            break;

                        case "t":
                            myKingdom.PrintTrash();
                            break;

                        case "printplayer":
                            Broc.PrintPlayer();
                            break;

                        case "q":
                            gameOver = true;
                            break;
                        }
                    }
                    else
                    {
                        Broc.BuyPhase(myKingdom);
                    }
                } while (!Broc.TurnComplete && !gameOver);

                Broc.Cleanup(myKingdom);
            } while (!gameOver && !myKingdom.GameOver());

            Console.WriteLine("Game Over! " + Broc.PlayerName + " won with " + Broc.CalculatePoints() + " points, taking " + Broc.Turns + " turns.\r\nPress enter to continue...");
            Console.ReadLine();
        }
コード例 #8
0
ファイル: Player.cs プロジェクト: brocwoodworth/DMS
        public void GainCardByCost(int cost, bool exactCost, bool optional, Kingdom myKingdom, Deck.State state = Deck.State.discardPile, Card.Type type = 0)
        {
            ClearIndex(myKingdom);
            bool done  = false;
            int  index = 1;

            foreach (Deck deck in myKingdom.KingdomSupply)
            {
                if (deck.Cards.Count > 0)
                {
                    if ((deck.Cards[0].cost <= cost && !exactCost) || (deck.Cards[0].cost == cost && exactCost))
                    {
                        if (type == 0 || deck.Cards[0].types.Contains(type))
                        {
                            deck.Cards[0].index = index++;
                        }
                    }
                }
            }
            myKingdom.PrintKingdom();
            string optionalText = "";

            if (optional)
            {
                optionalText = " Or, press [n] to gain no card.";
            }
            if (exactCost)
            {
                Console.WriteLine("\r\nChoose a card from the kingdom to gain costing exactly " + cost + "." + optionalText);
            }
            else
            {
                Console.WriteLine("\r\nChoose a card from the kingdom to gain costing up to " + cost + "." + optionalText);
            }

            do
            {
                string buyInput    = Console.ReadLine().ToLower();
                int    intBuyInput = -1;
                if (Int32.TryParse(buyInput, out intBuyInput))
                {
                    if (intBuyInput > 0 && intBuyInput < index)
                    {
                        foreach (Deck deck in myKingdom.KingdomSupply)
                        {
                            if (deck.Cards[0].index == intBuyInput)
                            {
                                Card cardToGain = deck.Cards[deck.Cards.Count - 1];
                                GainCard(cardToGain, deck, state);
                                done = true;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid Input.");
                    }
                }
                else if (optional && buyInput == "n")
                {
                    done = true;
                }
                else
                {
                    Console.WriteLine("Invalid Input");
                }
            } while (!done);
        }
コード例 #9
0
ファイル: Player.cs プロジェクト: brocwoodworth/DMS
 public void PlayBaseSetAction(Card card, Kingdom myKingdom)
 {
     Sets.BaseSet baseSet = new Sets.BaseSet();
     baseSet.PlayAction(card, this, myKingdom);
 }
コード例 #10
0
ファイル: Player.cs プロジェクト: brocwoodworth/DMS
        public void BuyPhase(Kingdom myKingdom)
        {
            bool readyToBuy = false;
            int  index      = 1;

            ClearIndex(myKingdom);
            foreach (Card card in inHand.Cards)
            {
                if (card.types.Contains(Card.Type.Treasure))
                {
                    card.index = index++;
                }
            }

            do
            {
                inHand.PrintDeck();
                Console.WriteLine("\r\nSelect Treasures to play from your hand. [A] = All. [#] = Play specific treasure. [D] = Done playing treasures. [T] = Print trash.");
                Console.WriteLine("Buys: " + Buys + ", Dollars: " + Dollars + ".");

                string playTreasureInput = Console.ReadLine().ToLower();
                if (playTreasureInput == "a")
                {
                    for (int i = inHand.Cards.Count - 1; i >= 0; i--)
                    {
                        if (inHand.Cards[i].types.Contains(Card.Type.Treasure))
                        {
                            PlayTreasure(inHand.Cards[i]);
                        }
                    }
                    readyToBuy = true;
                }
                else if (playTreasureInput == "d")
                {
                    readyToBuy = true;
                }
                else if (playTreasureInput == "t")
                {
                    myKingdom.PrintTrash();
                }
                else
                {
                    int intPlayTreasureInput = -1;
                    if (Int32.TryParse(playTreasureInput, out intPlayTreasureInput))
                    {
                        if (intPlayTreasureInput > 0 && intPlayTreasureInput < index)
                        {
                            for (int i = 0; i < inHand.Cards.Count; i++)
                            {
                                if (inHand.Cards[i].index == intPlayTreasureInput)
                                {
                                    PlayTreasure(inHand.Cards[i]);
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("Invalid Input.");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid Input.");
                    }
                }
            } while (!readyToBuy);

            //Ready to buy, reset index
            index = 1;
            bool doneBuying = false;

            foreach (Deck deck in myKingdom.KingdomSupply)
            {
                if (deck.Cards.Count > 0)
                {
                    if (deck.Cards[0].cost <= Dollars)
                    {
                        deck.Cards[0].index = index++;
                    }
                }
            }
            myKingdom.PrintKingdom();
            while (!doneBuying)
            {
                Console.WriteLine("\r\nChoose a card from the kingdom to buy. [N] for none. Buys: " + Buys + ", Dollars: " + Dollars + ".");
                string buyInput    = Console.ReadLine().ToLower();
                int    intBuyInput = -1;
                if (Int32.TryParse(buyInput, out intBuyInput))
                {
                    if (intBuyInput > 0 && intBuyInput < index)
                    {
                        foreach (Deck deck in myKingdom.KingdomSupply)
                        {
                            if (deck.Cards[0].index == intBuyInput)
                            {
                                Card cardToGain = deck.Cards[deck.Cards.Count - 1];
                                GainCard(cardToGain, deck);
                                Dollars = Dollars - cardToGain.cost;
                                Buys    = Buys - 1;
                                if (Buys == 0)
                                {
                                    doneBuying = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid Input.");
                    }
                }
                else if (buyInput == "n")
                {
                    doneBuying = true;
                }
                else
                {
                    Console.WriteLine("Invalid Input.");
                }
            }
            TurnComplete = true;
        }