Пример #1
0
 public HomeModule()
 {
     Get["/"] = _ =>
     {
         return(View["/index.cshtml"]);
     };
     Get["/two_player"] = _ =>
     {
         return(View["two_player.cshtml"]);
     };
     Post["/human_hangman"] = _ =>
     {
         string  word       = Request.Form["new-word"];
         Hangman newHangman = new Hangman(word.ToUpper());
         return(View["hangman.cshtml", newHangman]);
     };
     Get["/computer_hangman"] = _ =>
     {
         List <string> computerWords = new List <string> {
             "PROGRAMMING", "RABBIT", "HOUSE", "BARNYARD", "ELEPHANT", "LUMBERJACK"
         };
         Random  picker      = new Random();
         int     pickerIndex = picker.Next(0, computerWords.Count - 1);
         Hangman newHangman  = new Hangman(computerWords[pickerIndex]);
         return(View["hangman.cshtml", newHangman]);
     };
     Get["/hangman/{id}/{letter}"] = parameters =>
     {
         Hangman currentHangman = Hangman.FindGame(int.Parse(parameters.id));
         currentHangman.GuessLetter(parameters.letter);
         return(View["hangman.cshtml", currentHangman]);
     };
 }
Пример #2
0
        public HomeModule()
        {
            Get["/new_game"] = _ => {
            Hangman glyph = new Hangman("glyph");
            return View["hangman.cshtml", glyph];
              };

              Get["/"] = _ => {
            return View["home.cshtml"];
              };
              Post["/guess_letter"] = _ =>{
            Hangman newHangman = Hangman.GetHangman();
            newHangman.HandleGuess(Request.Form["letter-input"]);
            return View["hangman.cshtml", newHangman];
              };
        }
Пример #3
0
        public HomeModule()
        {
            Get["/new_game"] = _ => {
                Hangman glyph = new Hangman("glyph");
                return(View["hangman.cshtml", glyph]);
            };

            Get["/"] = _ => {
                return(View["home.cshtml"]);
            };
            Post["/guess_letter"] = _ => {
                Hangman newHangman = Hangman.GetHangman();
                newHangman.HandleGuess(Request.Form["letter-input"]);
                return(View["hangman.cshtml", newHangman]);
            };
        }
Пример #4
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Hangman!!!!!!!!!!");
pAgain:
            Hangman game = new Hangman();

            game.SetupGame("", Enums.Difficulty.Medium);
            // TODO game.Loop();
            game.PlayGame();
            Console.WriteLine("The End!!!!!!!!!!");
            Console.WriteLine("------------------------------------");
            Console.WriteLine("do you want to play again? (y/n)");
            string y = Console.ReadLine();

            if (y == "y")
            {
                goto pAgain;
            }
        }