static void Main(string[] args)
        {
            // There is no limit on the amount of weapons supported by RPSGame. Matchups are calculated depending on the order.
            var rps = new RPSGame("scissors", "paper", "rock", "lizard", "spock");

            int wins = 0, losses = 0, draws = 0;

            while (true)
            {
                rps.NextAI();
                byte[] secretkey = new Byte[64];

                RandomNumberGenerator rng = RandomNumberGenerator.Create();

                rng.GetBytes(secretkey);
                String Key = String.Concat(Array.ConvertAll(secretkey, x => x.ToString("x2")));;
                Console.WriteLine(rps.GenerateNewHMAC(Key, rps.LastAIWeapon));

                Console.WriteLine("Make your move: " + string.Join(", ", rps.Weapons) + ", quit");

                string weapon = Console.ReadLine().Trim().ToLower();

                if (weapon == "quit")
                {
                    break;
                }

                if (!rps.Weapons.Contains(weapon))
                {
                    Console.WriteLine("Invalid weapon!");
                    continue;
                }

                int result = rps.Next(weapon);

                Console.WriteLine("You chose {0} and your opponent chose {1}!", weapon, rps.LastAIWeapon);

                switch (result)
                {
                case 1:
                    Console.WriteLine("{0} pwns {1}. You're a winner!", weapon, rps.LastAIWeapon);
                    wins++;
                    break;

                case 0:
                    Console.WriteLine("Draw!");
                    draws++;
                    break;

                case -1:
                    Console.WriteLine("{0} pwns {1}. You're a loser!", rps.LastAIWeapon, weapon);
                    losses++;
                    break;
                }

                Console.WriteLine("key:{0}", Key);//.GetHashCode());
            }
            Console.WriteLine("\nPlayer Statistics\nWins: {0}\nLosses: {1}\nDraws: {2}", wins, losses, draws);
        }
Ejemplo n.º 2
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Post["/game"] = _ => {
         string  user1choice = Request.Form["user1choice"];
         string  user2choice = Request.Form["user2choice"];
         RPSGame newRPSGame  = new RPSGame(user1choice, user2choice);
         return(View["result.cshtml", newRPSGame]);
     };
 }
Ejemplo n.º 3
0
        static void Main2(string[] args)
        {
            // There is no limit on the amount of weapons supported by RPSGame. Matchups are calculated depending on the order.
            var rps = new RPSGame("scissors", "paper", "rock" /*, "lizard", "spock"*/);

            int wins = 0, losses = 0, draws = 0;

            while (true)
            {
                Console.WriteLine("Make your move: " + string.Join(", ", rps.Weapons) + ", quit");

                string weapon = Console.ReadLine().Trim().ToLower();

                if (weapon == "quit")
                {
                    break;
                }

                if (!rps.Weapons.Contains(weapon))
                {
                    Console.WriteLine("Invalid weapon!");
                    continue;
                }

                int result = rps.Next(weapon);

                Console.WriteLine("You chose {0} and your opponent chose {1}!", weapon, rps.LastAIWeapon);

                switch (result)
                {
                case 1:
                    Console.WriteLine("{0} beats {1}. You're a winner!", weapon, rps.LastAIWeapon);
                    wins++;
                    break;

                case 0:
                    Console.WriteLine("Draw!");
                    draws++;
                    break;

                case -1:
                    Console.WriteLine("{0} beats {1}. You're a loser!", rps.LastAIWeapon, weapon);
                    losses++;
                    break;
                }

                Console.WriteLine();
            }

            Console.WriteLine("\nPlayer Statistics\nWins: {0}\nLosses: {1}\nDraws: {2}", wins, losses, draws);
        }
        static void Main(string[] args)
        {
            // There is no limit on the amount of weapons supported by RPSGame. Matchups are calculated depending on the order.
            var rps = new RPSGame("scissors", "paper", "rock", "lizard", "spock");

            int wins = 0, losses = 0, draws = 0;

            while (true)
            {
                Console.WriteLine("Make your move: " + string.Join(", ", rps.Weapons) + ", quit");

                string weapon = Console.ReadLine().Trim().ToLower();

                if (weapon == "quit")
                    break;

                if (!rps.Weapons.Contains(weapon))
                {
                    Console.WriteLine("Invalid weapon!");
                    continue;
                }

                int result = rps.Next(weapon);

                Console.WriteLine("You chose {0} and your opponent chose {1}!", weapon, rps.LastAIWeapon);

                switch (result)
                {
                    case 1: Console.WriteLine("{0} pwns {1}. You're a winner!", weapon, rps.LastAIWeapon);
                        wins++;
                        break;
                    case 0: Console.WriteLine("Draw!");
                        draws++;
                        break;
                    case -1: Console.WriteLine("{0} pwns {1}. You're a loser!", rps.LastAIWeapon, weapon);
                        losses++;
                        break;
                }

                Console.WriteLine();
            }

            Console.WriteLine("\nPlayer Statistics\nWins: {0}\nLosses: {1}\nDraws: {2}", wins, losses, draws);
        }
 static void Main(string[] args)
 {
     RPSGame rpsGame = new RPSGame();
     RPSMove rpsMove = new RPSMove();
 }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            var rps = new RPSGame("scissors", "paper", "rock", "lizard", "spock");

            int wins = 0, losses = 0, draws = 0;
            int round = 1;


            while (true)
            {
                if (wins == 3 || losses == 3)
                {
                    break;
                }

                Console.WriteLine("--------------------");
                Console.WriteLine("LETS PLAY!");
                Console.WriteLine("\nRound: {0}", round);
                Console.WriteLine("--------------------");
                Console.WriteLine("First to win 3 rounds is the Game winner!");
                Console.WriteLine("Make your move!: " + string.Join(", ", rps.Choices) + ", or press 'q' to quit the game");
                Console.WriteLine("");
                string choice = Console.ReadLine().Trim().ToLower();

                if (choice == "q")
                {
                    break;
                }

                if (!rps.Choices.Contains(choice))

                {
                    Console.WriteLine("Invalid choice!");
                    continue;
                }

                int result = rps.Next(choice);

                Console.WriteLine("");
                Console.WriteLine("You chose {0} and your opponent chose {1}!", choice, rps.LastCPUChoice);

                switch (result)

                {
                case 1:
                    Console.WriteLine("");
                    Console.WriteLine("{0} beats {1} - You WON this round.", choice, rps.LastCPUChoice);
                    wins++;
                    round++;
                    break;

                case 0:

                    Console.WriteLine("");
                    Console.WriteLine("This round is a DRAW!");
                    draws++;
                    round++;
                    break;

                case -1:
                    Console.WriteLine("");
                    Console.WriteLine("{0} beats {1} - You LOST this round", rps.LastCPUChoice, choice);
                    losses++;
                    round++;
                    break;
                }

                Console.WriteLine("");
                Console.WriteLine("Do you want to play again? Press 'y' for Yes or 'n' for No");
                if (!Console.ReadLine().StartsWith("y", StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }
            }
            Console.WriteLine("-------------------------------------------------");
            Console.WriteLine("MATCH RESULT - Win 3 to win the game.");
            Console.WriteLine("-------------------------------------------------");
            round--;
            Console.WriteLine("The game was completed in {0} moves/rounds", round);
            Console.WriteLine("\nWins: {0}\nLosses: {1}\nDraws: {2}", wins, losses, draws);


            Console.WriteLine("-------------------------------------------------");
            if (losses == 3 && wins < 3)
            {
                Console.WriteLine("You Lost the Match!");
            }

            else if (wins == 3 && losses < 3)
            {
                Console.WriteLine("You Won the Match!");
            }

            else
            {
                Console.WriteLine("Game Ended with no overall winner - 3 wins required");
            }
        }
Ejemplo n.º 7
0
 static void Main(string[] args)
 {
     RPSGame rPSGame = new RPSGame();
 }