Esempio n. 1
0
        private void CharacterBtnClick(object sender, RoutedEventArgs e)
        {
            int[] temp = HangmanGame.TakeCharacter((sender as Button).Content.ToString()[0]);

            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i] == 1)
                {
                    Labels[i].Content = HangmanGame.Word[i];
                }
            }

            StageImage.Source = HangmanGame.GetStageImage();

            if (Labels.Count(l => l.Content == null) == 0)
            {
                FinishGame("You Win!");
            }
            else if (HangmanGame.IsGameOver())
            {
                FinishGame("You Lose!");
            }
            else
            {
                (sender as Button).IsEnabled = false;
            }
        }
        static void Main(string[] args)
        {
            HangmanGame game = new HangmanGame();
            game.Play();

            Console.ReadLine();
        }
 public void Start(string clue)
 {
     Game = new HangmanGame(clue);
     IsStarted = true;
     
     OnStateChange(new SendArgs(GameState(), LastUserTweetId));
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            HangmanGame game = new HangmanGame();

            game.Play();
            Console.ReadLine();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            const string filePath = "./FilesManagment/text/countries_and_capitals.txt";

            HangmanGame game = new HangmanGame(filePath);

            Console.WriteLine("\n\tWelcome to Hangman game! Would you like to proceed?\n\tEnter 1 to start the game, enter 2 to show highscores or 0 to exit application.");

            while (game.isRunning)
            {
                switch (game.EnterInput())
                {
                case "0":
                    game.endGame();
                    game.saveScoreToFile();
                    Console.WriteLine("\n\tThank you for playing!");
                    break;

                case "1":
                    game.startGame();
                    break;

                case "2":
                    game.showHighScore();
                    Console.WriteLine("\n\tEnter 1 to start the game, enter 2 to show highscores or 0 to exit application.");
                    break;

                default:
                    Console.WriteLine("\tYour input seem to be invalid. Try again.");
                    break;
                }
            }
        }
        public HangmanGame Guess(char guess, HangmanGame game)
        {
            if (game.Word.Contains(guess))
            {
            }

            var newMask = "";

            for (var i = 0; i < game.Word.Length; i++)
            {
                if (game.Word[i] == guess)
                {
                    newMask += guess;
                }
                else
                {
                    newMask += game.Mask[i];
                }
            }

            return(new HangmanGame
            {
                Word = game.Word,
                Mask = newMask
            });
        }
Esempio n. 7
0
        public static void Main(string[] args)
        {
            Console.WriteLine ("Starting game...");
            HangmanGame game = new HangmanGame();

            game.Play();
            Console.ReadLine().ToUpper();
        }
 public void HangManGameEndsIfThereisOnlyOneCandidateLeft()
 {
     var mockDictionary = new HangDictionary(@"dictionary\testdictionary.txt");
     var game = new HangmanGame("------",mockDictionary);
     game.Clue("a-a---");
     
     Assert.Equal(1,game.Dictionary.Words.Count());
     Assert.True(game.IsOver);
     Assert.True(game.HangmanWon);
 }
Esempio n. 9
0
 /* Reset the game, pick a new word */
 //H=When the player presses the play button
 private void replayBtn_Click(object sender, EventArgs e)
 {
     //Initilizes the game
     HangmanGame.SetWord();
     //Sets up the UI
     guessLbl.Text = "";
     //disables the input for the game
     inputBtn.Enabled  = true;
     replayBtn.Enabled = false;
     hangmanPic.Image  = Hangman.Properties.Resources.hangman0;
     UpdateUI();
 }
Esempio n. 10
0
        static void Main(string[] args)
        {
            bool playAgain = true;

            do
            {
                Console.Clear();
                HangmanGame game = new HangmanGame();
                game.Greeting();
                game.Play();
                game.EndGame();
            } while (playAgain);
        }
Esempio n. 11
0
        /// <summary>
        /// Entry point of the game. 
        /// </summary>
        public static void Main()
        {
            var kernel = new StandardKernel();

            kernel.Bind<IPrinter>().To<ConsolePrinter>();
            kernel.Bind<IDataManager<Dictionary<string, int>>>().To<TextFileScoreboardDataManager<Dictionary<string, int>>>();
            kernel.Bind<IDataManager<SaveLoadManager>>().To<XmlGameStateManager<SaveLoadManager>>();
            kernel.Bind<ISorter>().To<SelectionSorter>();
            kernel.Bind<ICommandInvoker>().To<HangmanCommandInvoker>();

            var printer = kernel.Get<IPrinter>();
            var sorter = kernel.Get<ISorter>();
            var scoresDataManager = kernel.Get<IDataManager<Dictionary<string, int>>>();
            var gameStateManager = kernel.Get<IDataManager<SaveLoadManager>>();
            var commandFactory = new CommandFactory();
            var commandExecutioner = kernel.Get<ICommandInvoker>();
            var wordProvider = SimpleRandomWordProvider.Instance;

            var game = new HangmanGame(printer, sorter, scoresDataManager, gameStateManager, commandFactory, commandExecutioner, wordProvider);
            game.Run();
        }
Esempio n. 12
0
        /// <summary>
        /// Start new game if player still want to play or redirect to menu.
        /// </summary>
        /// <param name="game">Instance of <see cref="HangmanGame"/> class.</param>
        public override void Play(HangmanGame game)
        {
            game.UI.Print("Title", "Title");

            game.UI.Print(Messages.PlayAgainMessage, "Message");

            char playAgainYesNo = game.UI.ReadKey();

            if (playAgainYesNo == 'y')
            {
                game.State = new ChooseCategoryState();
                game.State.Play(game);
            }
            else if (playAgainYesNo == 'n')
            {
                HangmanStartPoint.Main();
            }
            else
            {
                game.UI.Print(Messages.WrongCommand, "Message");
                this.Play(game);
            }
        }
Esempio n. 13
0
 static void Main(string[] args)
 {
     HangmanGame game = new HangmanGame();
     game.Start();
 }
Esempio n. 14
0
        public static void Main()
        {
            var game = new HangmanGame();

            while (true)
            {
                DisplayIntroText();

                var opt = GetMenuSelection();

                switch (opt)
                {
                    case 'X':
                        return; // Quit game
                    case 'N':
                        game.Play();
                        break;
                    default:
                        AddWordToDictionary();
                        break;
                }
            }
        }
Esempio n. 15
0
 public void UpdateUI()
 {
     wordLbl.Text  = HangmanGame.GetWordOnScree();
     livesLbl.Text = HangmanGame.lives.ToString();
     inputTxt.Text = "";
 }
Esempio n. 16
0
 static void Main(string[] args)
 {
     HangmanGame game = new HangmanGame();
 }
Esempio n. 17
0
        private void inputBtn_Click(object sender, EventArgs e)
        {
            //Gets the text and sets it to lower case
            string input = inputTxt.Text.ToLower();

            //If the input is valid
            if (input.Length < 1)
            {
                return;
            }
            else if (input[0] == ' ')
            {
                return;
            }
            //Adds charicter to the list
            if (guessLbl.Text != "")
            {
                guessLbl.Text += ", ";
            }
            if (input.Length == 1)
            {
                guessLbl.Text += input[0];
            }
            //Checs if they got it correct
            bool right = HangmanGame.CheckInput(input);

            if (right)
            {
                //if they have cmpleted the word
                if (HangmanGame.WordIsComplete())
                {
                    //disables the input for the game
                    inputBtn.Enabled = false;
                    //Enables the replay button
                    replayBtn.Enabled = true;
                    inputTxt.Text     = "";
                    MessageBox.Show("Game over! You won!");
                }
            }
            else
            {
                HangmanGame.lives--;
                switch (HangmanGame.lives)
                {
                case 0:
                    hangmanPic.Image = Hangman.Properties.Resources.hangmanFinal;
                    break;

                case 1:
                    hangmanPic.Image = Hangman.Properties.Resources.hangman9;
                    break;

                case 2:
                    hangmanPic.Image = Hangman.Properties.Resources.hangman8;
                    break;

                case 3:
                    hangmanPic.Image = Hangman.Properties.Resources.hangman7;
                    break;

                case 4:
                    hangmanPic.Image = Hangman.Properties.Resources.hangman6;
                    break;

                case 5:
                    hangmanPic.Image = Hangman.Properties.Resources.hangman5;
                    break;

                case 6:
                    hangmanPic.Image = Hangman.Properties.Resources.hangman4;
                    break;

                case 7:
                    hangmanPic.Image = Hangman.Properties.Resources.hangman3;
                    break;

                case 8:
                    hangmanPic.Image = Hangman.Properties.Resources.hangman2;
                    break;

                case 9:
                    hangmanPic.Image = Hangman.Properties.Resources.hangman1;
                    break;

                default:
                    hangmanPic.Image = Hangman.Properties.Resources.hangman0;
                    break;
                }
                //If they are out of lives
                if (HangmanGame.lives <= 0)
                {
                    //disables the input for the game
                    inputBtn.Enabled = false;
                    //Enables the replay button
                    replayBtn.Enabled = true;
                    inputTxt.Text     = "";
                }
            }
            //Updates the UI
            UpdateUI();

            if (HangmanGame.lives <= 0)
            {
                MessageBox.Show("Game over! You lost!");
                replayBtn.Enabled = true;
            }
        }