Exemplo n.º 1
0
Arquivo: Form1.cs Projeto: jckccc/Fun
 private void newGame()
 {
     g = new Game();
     enter.Enabled = true;
     wordTextBox.Text = g.getDefaultUserGuessedWord();
     guessedLetters.Text = "";
     pictureBox1.Image = (Image)Hangman.Properties.Resources.ResourceManager.GetObject("_0");
 }
Exemplo n.º 2
0
		public void GameCreationTest()
		{
			Game game = new Game(new InitialState());

			Assert.IsNotNull(game);
			Assert.AreEqual(game.NumberOfMistakes, 0);
			Assert.IsNotNull(game.State);
			Assert.IsNull(game.Word);
		}
Exemplo n.º 3
0
        public void TheLetterAsSomeChar()
        {
            char letter = '%';

            Game game = new Game(new InitialState());

			game.Run();

            GameEngine.GuessLetter(game, letter);
        }
Exemplo n.º 4
0
        public void WordIsLetterAsNonLetter()
        {
            char letter = '$';

            Game game = new Game(new InitialState());

			game.Run();

            GameEngine.GuessLetter(game, letter);
        }
Exemplo n.º 5
0
        public void GameEngineContainsLetter()
        {
            char letter = 'd';

            Game game = new Game(new InitialState());

			game.Run();

            GameEngine.GuessLetter(game, letter);
        }
Exemplo n.º 6
0
        public override void PerformAction(Game game)
        {
			Console.Write(WelcomeMessage);

            game.Word = new Word();
            game.NumberOfMistakes = 0;

            CommandInterpreter.AssignGameDelegate(() => game);

            game.State = new PlayState();
        }        
Exemplo n.º 7
0
 void GoStartGame()
 {
     picked = false;
     while (!picked)
     {
         ogame = new Game(lang);
         if (!ogame.DecideNewGame())
         {
             picked = true;
         }
     }
 }
		public void CommandInterpreterDecodeHelpInput()
		{
			Game game = new Game(new InitialState());

			game.Word = new Word();

			CommandInterpreter.AssignGameDelegate(() => game);

			var decoder = new CommandInterpreter();

			decoder.Decode("help");
		}
Exemplo n.º 9
0
		public void GameRunTest()
		{
			Game game = new Game(new InitialState());

			game.Run();
        }
Exemplo n.º 10
0
 static void Main(string[] args)
 {
     Game game = new Game();
     game.run();
     Console.ReadLine();
 }
Exemplo n.º 11
0
		public void GameMistakeAsLessThanZero()
		{
			Game game = new Game(new InitialState());

			game.NumberOfMistakes = -1;
		}
Exemplo n.º 12
0
        private void InitializeGameField(string word)
        {
            HangmanGame = new Game(word, GameLanguage.En);

            Labels.Clear();
            Buttons.Clear();
            GameGrid.Children.Clear();

            CreateImage();
            StageImage.Source = HangmanGame.GetStageImage();

            CreateNewGameBtn();
            CreateCharacterBtns(HangmanGame.Alphabet);
            CreateCharacterLbl(HangmanGame.Lenght);
        }
        public void DecodeCommandTests()
        {
            Game game = new Game(new InitialState());

            game.Run();

            string testExampleWord = "computer";
            string testDecodeCommand = "help";

            CommandInterpreter.Decode(testDecodeCommand);

            // CommandInterpreter decodeCommandWord = new CommandInterpreter(testDecodeCommand);

            // var decodeCommand = CommandInterpreter.AssignGameDelegate(GetGameDelegate);
            // Assert.IsNotNull(decodeCommandWord);

            Assert.AreEqual(game.Word, testExampleWord);
        }
Exemplo n.º 14
-3
        static void Main(string[] args)
        {
            Game game = new Game(args[0] != null ? args[0] : "jogo.txt");
            char c;
            game.renderBoard();

            while( !game.End ){

                while (Console.KeyAvailable == false)
                    Thread.Sleep(250); // Loop until input is entered.

                var key = Console.ReadKey(true);
                if (key.Key == ConsoleKey.F2)
                {
                    game.showNewTip();
                }
                else if (char.IsLetter(key.KeyChar))
                {
                    c = key.KeyChar;

                    game.checkGuess(c);
                }

                game.renderBoard();
            }
        }
Exemplo n.º 15
-20
        public override void PerformAction(Game game)
        {
            if (game.Word.MaskedWord.Contains('_'))
            {
                Console.WriteLine("The secret word is " + game.Word.MaskedWord);

                Console.Write("Enter your guess: ");

                string command = Console.ReadLine();

                CommandInterpreter decoder = new CommandInterpreter();

                decoder.Decode(command);
            }
            else
            {
                GameEngine.EstimateScore(game.Word, game.NumberOfMistakes);
                game.NumberOfMistakes = 0;

                game.State = new InitialState();
            }
        } 
Exemplo n.º 16
-44
        public static void GuessLetter(Game currentGame, char letter)
        {
            if (currentGame.Word.ContainsLetter(letter))
            {
                currentGame.Word.RevealLetterPosition(letter);

                int numberOfOccurrences = currentGame.Word.NumberOfLetterOccurrences(letter);
                string comment = numberOfOccurrences == 1 ? " letter" : " letters";

                Console.WriteLine("Good job! You revealed " + numberOfOccurrences + comment);
            }
            else
            {
                Console.WriteLine("Sorry! There are no unrevealed letters \"{0}\"", char.ToLower(letter));
                currentGame.NumberOfMistakes++;
            }
        }
Exemplo n.º 17
-53
		public void GameAddWordTest()
		{
			Game game = new Game(new InitialState());

			game.Word = new Word();

			Assert.IsNotNull(game.Word);
		}