示例#1
0
 public void testPlayerTurn()
 {
     Player player = new ComputerPlayer("test", new GreedyAIStrategy());
     player.TakeTurn();
     // the strategy should always return a nonzero score for the first turn (Chance category at the worst)
     Assert.IsTrue(player.CurrentScore > 0);
 }
示例#2
0
 public void testPlayerToString()
 {
     Player player = new ComputerPlayer("test computer", new GreedyAIStrategy());
     Assert.AreEqual("test computer - Computer - Greedy", player.ToString());
     player = new HumanPlayer("test human");
     Assert.AreEqual("test human - Human", player.ToString());
 }
示例#3
0
 public void testPlayerName()
 {
     Player player = new HumanPlayer("test name");
     Assert.AreEqual("test name", player.Name);
     player = new ComputerPlayer("test name 2", new GreedyAIStrategy());
     Assert.AreEqual("test name 2", player.Name);
 }
示例#4
0
        static void Main(string[] args)
        {
            Game game = new Game();

            Player player1 = new ComputerPlayer("GreedyAI", new GreedyAIStrategy());
            Player player2 = new HumanPlayer("Test Player", new CmdLinePlayerStrategy());

            game.AddPlayer(player1);
            game.AddPlayer(player2);

            game.PlayGame();

            Console.WriteLine("The Winner Is: " + game.GetWinnerName());
            Console.WriteLine("With a score of: " + game.GetWinningScore().ToString());
            Console.ReadKey();
        }
        public void CheckSerialization()
        {
            PlayerList playerList = new PlayerList();
            Turn turn = new Turn();
            DieSet dieSet = new DieSet();

            HumanPlayer hp = new HumanPlayer("Test Player Name");
            ComputerPlayer cp = new ComputerPlayer("Test Computer Player", new GreedyAIStrategy());

            playerList.Players.Add(hp);
            playerList.Players.Add(cp);

            dieSet.Roll();

            GameState gameState = new GameState();
            gameState.Players = playerList;
            gameState.Turn = turn;

            XmlSerializer serializer = new XmlSerializer(typeof(GameState));
            using (TextWriter writer = new StreamWriter(@"C:\GameStateTest.xml"))
            {
                serializer.Serialize(writer, gameState);
            }
        }
 public void testComputerPlayerConstructor()
 {
     Player comp = new ComputerPlayer();
     Assert.IsInstanceOf(typeof(ComputerPlayer), comp);
 }