コード例 #1
0
ファイル: PlayerTests.cs プロジェクト: jsgalla/YahtzeeNetwork
 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());
 }
コード例 #2
0
ファイル: PlayerTests.cs プロジェクト: jsgalla/YahtzeeNetwork
 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);
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: jsgalla/YahtzeeNetwork
        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();
        }
コード例 #4
0
        public void testMakeUnique()
        {
            List<Player> players = new List<Player>();
            Player p;
            p = new HumanPlayer("A");
            players.Add(p);
            p = new HumanPlayer("A");
            players.Add(p);
            p = new HumanPlayer("B");
            players.Add(p);
            p = new HumanPlayer("A");
            players.Add(p);
            PlayerList pl = new PlayerList();
            pl.Players = players;

            pl.makeNamesUnique();
            Assert.AreEqual("A", pl.Players[0].Name);
            Assert.AreEqual("A2", pl.Players[1].Name);
            Assert.AreEqual("B", pl.Players[2].Name);
            Assert.AreEqual("A3", pl.Players[3].Name);
        }
コード例 #5
0
        public void testRemovePlayer()
        {
            List<Player> players = new List<Player>();
            Player p;
            p = new HumanPlayer("A");
            players.Add(p);
            p = new HumanPlayer("B");
            players.Add(p);
            p = new HumanPlayer("C");
            players.Add(p);
            PlayerList pl = new PlayerList();
            pl.Players = players;

            Assert.AreEqual(3, pl.Players.Count);
            Assert.AreEqual("A", pl.Players[0].Name);
            Assert.AreEqual("B", pl.Players[1].Name);
            Assert.AreEqual("C", pl.Players[2].Name);

            pl.removePlayer("B");
            Assert.AreEqual(2, pl.Players.Count);
            Assert.AreEqual("A", pl.Players[0].Name);
            Assert.AreEqual("C", pl.Players[1].Name);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 public void testHumanTurn()
 {
     Player human = new HumanPlayer("Test Human", new CmdLinePlayerStrategy());
     human.TakeTurn();
 }
コード例 #8
0
 public void testHumanPlayerConstructor()
 {
     Player human = new HumanPlayer();
     Assert.IsInstanceOf(typeof(HumanPlayer), human);
 }
コード例 #9
0
 public void testHumanPlayer()
 {
     Player human = new HumanPlayer("Test Human", new CmdLinePlayerStrategy());
     Assert.AreEqual("Test Human", human.Name);
     Assert.AreEqual("Human", human.PlayerType);
 }