예제 #1
0
        public Result playRound(Player player1, Player player2)
        {
            MatchResult result = new MatchResult();

            result.Player1_Choice = player1.GetChoice();
            result.Player2_Choice = player2.GetChoice();

            if (result.Player1_Choice == result.Player2_Choice)
            {
                result.Match_Result = Result.Tie;
                return Result.Tie;
            }
            else if ((result.Player1_Choice == Choice.Rock && result.Player2_Choice == Choice.Sissors) ||
                (result.Player1_Choice == Choice.Paper && result.Player2_Choice == Choice.Rock) ||
                (result.Player1_Choice == Choice.Sissors && result.Player2_Choice == Choice.Paper))
            {
                result.Match_Result = Result.Win;
                return Result.Win;
            }
            else
            {
                result.Match_Result = Result.Loss;
                return Result.Loss;
            }
        }
예제 #2
0
        public void playRound()
        {
            Player p1 = new Human("Player 1");
            //Player p2 = new ComputerPlayer("Player 2");
            ComputerPlayerWeighted p2 = new ComputerPlayerWeighted("Player 2");

            MatchResult result = new MatchResult();
            result.Player1_Choice = p1.GetChoice();
            result.Player2_Choice = p2.GetChoiceWeighted();

            if (result.Player1_Choice == result.Player2_Choice)
            {
                result.Match_Result = Result.Tie;
            }
            else if((result.Player1_Choice == Choice.Rock && result.Player2_Choice == Choice.Sissors) ||
                (result.Player1_Choice == Choice.Paper && result.Player2_Choice == Choice.Rock) ||
                (result.Player1_Choice == Choice.Sissors && result.Player2_Choice == Choice.Paper))
            {
                result.Match_Result = Result.Win;
            }
            else
            {
                result.Match_Result = Result.Loss;
            }
            ProcessResult(p1,p2,result);

            Console.WriteLine("\n\tComputer Rock Count : {0} ", ComputerPlayerWeighted.CountR);
            Console.WriteLine("\tComputer Scissors Count : {0}", ComputerPlayerWeighted.CountS);
            Console.WriteLine("\tComputer Paper Count : {0} ", ComputerPlayerWeighted.CountP);
            //Console.WriteLine(Enum.GetName(typeof(Choice),p1.GetChoice()));
        }
예제 #3
0
        public int ProcessResult(Player player1, Player player2, MatchResult result)
        {
            Console.WriteLine("\n \t{0} picked  {1}. \n \t{2} picked {3}.", player1.Name,
                Enum.GetName(typeof(Choice),result.Player1_Choice),
                player2.Name, Enum.GetName(typeof(Choice),result.Player2_Choice));

            switch (result.Match_Result)
            {
                case Enums.Result.Win:
                    Console.WriteLine("\n \t{0} Wins!", player1.Name);
                    return 1;
                case Enums.Result.Loss:
                    Console.WriteLine("\n \t{0} Wins!", player2.Name);
                    return 2;
                default:
                    Console.WriteLine("\n \tYou both tie!");
                    return 0;
            }
        }