private void newGame() { g = new Game(); enter.Enabled = true; wordTextBox.Text = g.getDefaultUserGuessedWord(); guessedLetters.Text = ""; pictureBox1.Image = (Image)Hangman.Properties.Resources.ResourceManager.GetObject("_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); }
public void TheLetterAsSomeChar() { char letter = '%'; Game game = new Game(new InitialState()); game.Run(); GameEngine.GuessLetter(game, letter); }
public void WordIsLetterAsNonLetter() { char letter = '$'; Game game = new Game(new InitialState()); game.Run(); GameEngine.GuessLetter(game, letter); }
public void GameEngineContainsLetter() { char letter = 'd'; Game game = new Game(new InitialState()); game.Run(); GameEngine.GuessLetter(game, letter); }
public override void PerformAction(Game game) { Console.Write(WelcomeMessage); game.Word = new Word(); game.NumberOfMistakes = 0; CommandInterpreter.AssignGameDelegate(() => game); game.State = new PlayState(); }
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"); }
public void GameRunTest() { Game game = new Game(new InitialState()); game.Run(); }
static void Main(string[] args) { Game game = new Game(); game.run(); Console.ReadLine(); }
public void GameMistakeAsLessThanZero() { Game game = new Game(new InitialState()); game.NumberOfMistakes = -1; }
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); }
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(); } }
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(); } }
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++; } }
public void GameAddWordTest() { Game game = new Game(new InitialState()); game.Word = new Word(); Assert.IsNotNull(game.Word); }