public void InvalidPlaceCardActionTest_GameAddition() { Random random = new Random(); int targetPile = random.Next(0, 4); 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 + PlaceCardAction.Action(targetPile)).Game; target = target.DrawCard(); target = (target + PlaceCardAction.Action(targetPile)).Game; target = target.DrawCard(); target = (target + PlaceCardAction.Action(targetPile)).Game; Assert.AreEqual<int>(3, target.Piles[targetPile].Count); target = target.DrawCard(); ActionResult result = target + PlaceCardAction.Action(targetPile); Assert.IsNotNull(result); Assert.IsNotNull(result.Data); Assert.IsNotNull(result.Game); Assert.AreSame(target, result.Game); Assert.IsFalse(result.Success); Assert.IsInstanceOfType(result.Data, typeof(Exception)); }
public void PlaceCardActionTest_GameAddition() { Random random = new Random(); int targetPile = random.Next(0, 4); 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(); ActionResult result = target + PlaceCardAction.Action(targetPile); Assert.IsNotNull(result); Assert.IsNotNull(result.Data); Assert.IsNotNull(result.Game); Assert.IsInstanceOfType(result.Data, typeof(CardCollection)); Assert.AreSame(result.Data, result.Game.Piles[targetPile]); Assert.IsTrue(result.Success); Assert.IsNotNull(target.VisibleCard); Assert.IsNull(result.Game.VisibleCard); Assert.AreNotEqual<int>(target.Piles[targetPile].Count, result.Game.Piles[targetPile].Count); Assert.AreNotEqual<int>(target.CurrentPlayerIndex, result.Game.CurrentPlayerIndex); }
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); }
public void PickupPileActionTest_GameAddition() { Random random = new Random(); int targetPile = random.Next(0, 4); 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 + PlaceCardAction.Action(targetPile)).Game; target = target.DrawCard(); target = (target + PlaceCardAction.Action(targetPile)).Game; target = target.DrawCard(); target = (target + PlaceCardAction.Action(targetPile)).Game; Assert.AreEqual<int>(3, target.PreviousActions.Count); Assert.AreEqual<Type>(typeof(PlaceCardAction), target.PreviousActions[0].Actions[0].GetType()); Assert.AreEqual<Type>(typeof(PlaceCardAction), target.PreviousActions[1].Actions[0].GetType()); Assert.AreEqual<Type>(typeof(PlaceCardAction), target.PreviousActions[2].Actions[0].GetType()); Assert.AreEqual<int>(3, target.Piles[targetPile].Count); ActionResult result = target + PickupPileAction.Action(targetPile); Assert.IsNotNull(result); Assert.IsNotNull(result.Data); Assert.IsNotNull(result.Game); Assert.AreSame(result.Data, result.Game.Hands[target.CurrentPlayerIndex]); Assert.IsInstanceOfType(result.Data, typeof(CardCollection)); Assert.IsTrue(result.Success); Assert.IsNull(result.Game.Piles[targetPile]); foreach (var card in target.Piles[targetPile]) { Assert.IsTrue(result.Game.Hands[target.CurrentPlayerIndex].Contains(card)); } }
public void Game_PreviousActionsTest() { 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 + PlaceCardAction.Action(0)).Game; target = target.DrawCard(); target = (target + PlaceCardAction.Action(1)).Game; target = target.DrawCard(); target = (target + PlaceCardAction.Action(2)).Game; Assert.AreEqual<int>(3, target.PreviousActions.Count); }
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"); }
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); } } }
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); }
protected override ActionResult Execute(ColorettoGame game) { ColorettoGame cloneGame = game.DrawCard(); ActionResult result = new ActionResult(this.Name, cloneGame, game.CurrentPlayer, cloneGame.VisibleCard, cloneGame.VisibleCard != null); return result; }