Beispiel #1
0
        private void SetupGame()
        {
            string Choice;

            Console.Write("Enter L to load a game from a file, anything else to play a new game:> ");
            Choice = Console.ReadLine().ToUpper();
            if (Choice == "L")
            {
                if (!LoadGame("game1.txt"))
                {
                    GameOver = true;
                }
            }
            else
            {
                CreateStandardDeck();
                Deck.Shuffle();
                for (int Count = 1; Count <= 5; Count++)
                {
                    MoveCard(Deck, Hand, Deck.GetCardNumberAt(0));
                }
                AddDifficultyCardsToDeck();
                Deck.Shuffle();
                CurrentLock = GetRandomLock();
            }
        }
Beispiel #2
0
        public void PlayGame()
        {
            string MenuChoice;

            if (Locks.Count > 0)
            {
                GameOver    = false;
                CurrentLock = new Lock();
                SetupGame();
                while (!GameOver)
                {
                    LockSolved = false;
                    while (!LockSolved && !GameOver)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Current score: " + Score);
                        Console.WriteLine(CurrentLock.GetLockDetails());
                        Console.WriteLine(Sequence.GetCardDisplay());
                        Console.WriteLine(Hand.GetCardDisplay());
                        MenuChoice = GetChoice();
                        switch (MenuChoice)
                        {
                        case "D":
                        {
                            Console.WriteLine(Discard.GetCardDisplay());
                            break;
                        }

                        case "U":
                        {
                            int    CardChoice    = GetCardChoice();
                            string DiscardOrPlay = GetDiscardOrPlayChoice();
                            if (DiscardOrPlay == "D")
                            {
                                MoveCard(Hand, Discard, Hand.GetCardNumberAt(CardChoice - 1));
                                GetCardFromDeck(CardChoice);
                            }
                            else if (DiscardOrPlay == "P")
                            {
                                PlayCardToSequence(CardChoice);
                            }
                            break;
                        }
                        }
                        if (CurrentLock.GetLockSolved())
                        {
                            LockSolved = true;
                            ProcessLockSolved();
                        }
                    }
                    GameOver = CheckIfPlayerHasLost();
                }
            }
            else
            {
                Console.WriteLine("No locks in file.");
            }
        }
Beispiel #3
0
        public override void Process(CardCollection deck, CardCollection discard, CardCollection hand, CardCollection sequence, Lock currentLock, string choice, int cardChoice)
        {
            int ChoiceAsInteger;

            if (int.TryParse(choice, out ChoiceAsInteger))
            {
                if (ChoiceAsInteger >= 1 && ChoiceAsInteger <= 5)
                {
                    if (ChoiceAsInteger >= cardChoice)
                    {
                        ChoiceAsInteger -= 1;
                    }
                    if (ChoiceAsInteger > 0)
                    {
                        ChoiceAsInteger -= 1;
                    }
                    if (hand.GetCardDescriptionAt(ChoiceAsInteger)[0] == 'K')
                    {
                        Card CardToMove = hand.RemoveCard(hand.GetCardNumberAt(ChoiceAsInteger));
                        discard.AddCard(CardToMove);
                        return;
                    }
                }
            }
            int Count = 0;

            while (Count < 5 && deck.GetNumberOfCards() > 0)
            {
                Card CardToMove = deck.RemoveCard(deck.GetCardNumberAt(0));
                discard.AddCard(CardToMove);
                Count += 1;
            }
        }
Beispiel #4
0
 private void ProcessLockSolved()
 {
     Score += 10;
     Console.WriteLine("Lock has been solved.  Your score is now: " + Score);
     while (Discard.GetNumberOfCards() > 0)
     {
         MoveCard(Discard, Deck, Discard.GetCardNumberAt(0));
     }
     Deck.Shuffle();
     CurrentLock = GetRandomLock();
 }