コード例 #1
0
ファイル: GameTest.cs プロジェクト: ischyrus/coloretto_old
        public void Game_AvaliableActions2()
        {
            Profile player1 = new Profile();
            Profile player2 = new Profile();
            Profile player3 = new Profile();
            Profile player4 = new Profile();
            ColorettoGame target = new ColorettoGame(player1, player2, player3, player4);
            target = target.DrawCard();
            target = target.PlaceCardOnPile(2);

            Assert.AreEqual<GameActions>(GameActions.DrawOrPickupPile, target.AvailableActions);
        }
コード例 #2
0
 protected override ActionResult Execute(ColorettoGame game)
 {
     try
     {
         ColorettoGame newGame = game.PlaceCardOnPile(_targetPile);
         ActionResult result = new ActionResult(this.Name, newGame, game.CurrentPlayer, newGame.Piles[_targetPile], true);
         return result;
     }
     catch (ArgumentException ex)
     {
         return new ActionResult(this.Name, game, game.CurrentPlayer, ex, false);
     }
     catch (InvalidOperationException ex)
     {
         return new ActionResult(this.Name, game, game.CurrentPlayer, ex, false);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #3
0
ファイル: GameTest.cs プロジェクト: ischyrus/coloretto_old
        public void Game_PlaceCardOnPileTest()
        {
            Profile player1 = new Profile();
            Profile player2 = new Profile();
            Profile player3 = new Profile();
            Profile player4 = new Profile();
            ColorettoGame target = new ColorettoGame(player1, player2, player3, player4);

            target = target.PlaceCardOnPile(0);
            target = target.PlaceCardOnPile(0);
            target = target.PlaceCardOnPile(0);
            target = target.PlaceCardOnPile(0);
        }
コード例 #4
0
ファイル: GameTest.cs プロジェクト: ischyrus/coloretto_old
        public void Game_PickupPileTest()
        {
            Profile player1 = new Profile();
            Profile player2 = new Profile();
            Profile player3 = new Profile();
            Profile player4 = new Profile();
            ColorettoGame target = new ColorettoGame(player1, player2, player3, player4);

            target = target.DrawCard();
            target = target.PlaceCardOnPile(0);
            target = target.DrawCard();
            target = target.PlaceCardOnPile(0);
            target = target.DrawCard();
            target = target.PlaceCardOnPile(0);

            int numberOfPlayersWithNonZeroScore = target.Hands.Where(cc => cc.Score > 0).Count();
            Assert.IsTrue(numberOfPlayersWithNonZeroScore == 0, "Somehow someone started with a non-zero score.");

            target = target.PickupPile(0);

            CardCollection nullPileBecauseItWasPickedUp = target.Piles.First();
            Assert.IsNull(nullPileBecauseItWasPickedUp);

            numberOfPlayersWithNonZeroScore = target.Hands.Where(cc => cc.Score > 0).Count();
            Assert.IsTrue(numberOfPlayersWithNonZeroScore > 0, "Someone picked up a pile but nobody has a non-zero score");
        }
コード例 #5
0
ファイル: GameTest.cs プロジェクト: ischyrus/coloretto_old
        public void Game_FullRound()
        {
            Profile player1 = new Profile();
            Profile player2 = new Profile();
            Profile player3 = new Profile();
            Profile player4 = new Profile();
            ColorettoGame target = new ColorettoGame(player1, player2, player3, player4);

            // Loop through 5 times.
            // There are 76 cards. The last cycle card should be the 61st.
            // Each cycle, which is in this for loop, uses 12 cards.
            // 12 * 5 = 60 cards. So, the next cycle will be in the 6th loop
            for (int i = 0; i < 6; i++)
            {
                if (i == 5)
                {
                    Assert.AreEqual<int>(1, target.Round);
                }

                target = target.DrawCard();
                target = target.PlaceCardOnPile(0);
                target = target.DrawCard();
                target = target.PlaceCardOnPile(0);

                if (i == 5)
                {
                    Assert.AreEqual<int>(1, target.Round);
                    Assert.IsTrue(target.IsLastCycleForRound);
                }

                target = target.DrawCard();
                target = target.PlaceCardOnPile(0);

                target = target.DrawCard();
                target = target.PlaceCardOnPile(1);
                target = target.DrawCard();
                target = target.PlaceCardOnPile(1);
                target = target.DrawCard();
                target = target.PlaceCardOnPile(1);

                target = target.DrawCard();
                target = target.PlaceCardOnPile(2);
                target = target.DrawCard();
                target = target.PlaceCardOnPile(2);
                target = target.DrawCard();
                target = target.PlaceCardOnPile(2);

                target = target.DrawCard();
                target = target.PlaceCardOnPile(3);
                target = target.DrawCard();
                target = target.PlaceCardOnPile(3);
                target = target.DrawCard();
                target = target.PlaceCardOnPile(3);

                target = target.PickupPile(0);
                target = target.PickupPile(1);
                target = target.PickupPile(2);
                target = target.PickupPile(3);

                if (i == 5)
                {
                    Assert.AreEqual<int>(2, target.Round);
                }
            }
        }
コード例 #6
0
ファイル: GameTest.cs プロジェクト: ischyrus/coloretto_old
        public void Game_FullCycle()
        {
            Profile player1 = new Profile();
            Profile player2 = new Profile();
            Profile player3 = new Profile();
            Profile player4 = new Profile();
            ColorettoGame target = new ColorettoGame(player1, player2, player3, player4);

            target = target.DrawCard();
            target = target.PlaceCardOnPile(0);
            target = target.DrawCard();
            target = target.PlaceCardOnPile(0);
            target = target.DrawCard();
            target = target.PlaceCardOnPile(0);

            target = target.DrawCard();
            target = target.PlaceCardOnPile(1);
            target = target.DrawCard();
            target = target.PlaceCardOnPile(1);
            target = target.DrawCard();
            target = target.PlaceCardOnPile(1);

            target = target.DrawCard();
            target = target.PlaceCardOnPile(2);
            target = target.DrawCard();
            target = target.PlaceCardOnPile(2);
            target = target.DrawCard();
            target = target.PlaceCardOnPile(2);

            target = target.DrawCard();
            target = target.PlaceCardOnPile(3);
            target = target.DrawCard();
            target = target.PlaceCardOnPile(3);
            target = target.DrawCard();
            target = target.PlaceCardOnPile(3);

            Assert.AreEqual<int>(1, target.Cycle);
            Assert.AreEqual<int>(13, target.Turn);
            Assert.AreEqual<GameActions>(GameActions.PickupPile, target.AvailableActions);

            target = target.PickupPile(0);
            target = target.PickupPile(1);
            target = target.PickupPile(2);
            target = target.PickupPile(3);

            // Make sure that a new cycle is created
            Assert.AreEqual<int>(2, target.Cycle);
            Assert.AreEqual<int>(17, target.Turn);
            Assert.AreEqual<GameActions>(GameActions.Draw, target.AvailableActions);
        }