예제 #1
0
 public void TestDieSetRoll4Times()
 {
     DieSet dieSet = new DieSet();
     dieSet.Roll();
     dieSet.Roll();
     dieSet.Roll();
     dieSet.Roll();
 }
예제 #2
0
        public override void TakeTurn()
        {
            Turn turn = new Turn();

            DieSet dieSet = new DieSet();

            dieSet.Roll();
            Strategy.reroll(dieSet, 1, ScoreSheet);
            dieSet.Roll();
            Strategy.reroll(dieSet, 0, ScoreSheet);
            dieSet.Roll();
            string cat = Strategy.chooseCategory(dieSet, ScoreSheet);
            int points = ScoreSheet.Score(cat, dieSet);
            Console.WriteLine(Name + " scoring in " + cat + " for " + points + " points.");
        }
예제 #3
0
        public void TestRollAllDie()
        {
            DieSet dieSet = new DieSet();
            dieSet.Roll();

            foreach (Die die in dieSet.Dice)
            {
                Assert.IsTrue(die.Value > 0);
            }
        }
예제 #4
0
 public void TestDieSetReset()
 {
     DieSet dieSet = new DieSet();
     dieSet.Roll();
     foreach (Die die in dieSet.Dice)
     {
         die.Freeze();
     }
     Assert.AreEqual(1, dieSet.TimesRolled);
     dieSet.Reset();
     Assert.AreEqual(0, dieSet.TimesRolled);
     foreach (Die die in dieSet.Dice)
     {
         Assert.IsFalse(die.IsFrozen);
     }
 }
예제 #5
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);
            }
        }