Пример #1
0
 private bool CheckForTroel()
 {
     Troel troel = new Troel();
     if (troel.AfterDealCheck(players))
     {
         GameCase = Case.TROEL;
         return true;
     }
     else
         return false;
 }
Пример #2
0
 public void Test_TROEL_When_3_Aces()
 {
     createPlayers();//de attributen van de init en cleanup methodes werken blijkbaar niet...
     IList<Card> aces = new List<Card>() { new Card(1, 14), new Card(2, 14), new Card(3, 14), new Card(4, 14) };
     players[0].hand.AddCard(aces[0]);
     players[0].hand.AddCard(aces[1]);
     players[0].hand.AddCard(aces[2]);
     for (int i = 2; i < 12; i++)
     {
         players[0].hand.AddCard(new Card(1, i));
     }
     for(int i = 12; i < 14; i++)
     {
         players[1].hand.AddCard(new Card(1, i));
     }
     for (int i = 2; i < 13; i++)
     {
         players[1].hand.AddCard(new Card(2, i));
     }
     players[2].hand.AddCard(aces[3]);
     players[2].hand.AddCard(new Card(2, 13));
     for(int i = 2; i < 13; i++)
     {
         players[2].hand.AddCard(new Card(3, i));
     }
     players[3].hand.AddCard(new Card(3, 13));
     for(int i=2; i<14; i++)
     {
         players[3].hand.AddCard(new Card(4, i));
     }
     foreach(Player player in players)
     {
         Console.Write("Player " + player.name + " cards: ");
         foreach (Card card in player.hand.Cards)
         {
             Console.Write(card.ToString() + ", ");
         }
         Console.WriteLine();
     }
     SpecialGameCase troel = new Troel();
     Team[] teams = troel.Teams(players.ToArray());
     Assert.IsTrue(troel.AfterDealCheck(players.ToArray()));//troel
     Assert.AreEqual(players[0], teams[0].Players[0]);//troelplayers, player with 3 aces
     Assert.AreEqual(players[2], teams[0].Players[1]);//troelplayers, player with 4th ace
     Assert.AreEqual(players[1], teams[1].Players[0]);//otherplayers
     Assert.AreEqual(players[3], teams[1].Players[1]);//otherplayers
 }
Пример #3
0
 public void Test_No_TROEL_When_Nobody_With_3_Or_4_Aces()
 {
     createPlayers();//de attributen van de init en cleanup methodes werken blijkbaar niet...
     for (int i = 2; i < 15; i++)
     {
         players[0].hand.AddCard(new Card(1, i));
     }
     for (int i = 2; i < 15; i++)
     {
         players[1].hand.AddCard(new Card(2, i));
     }
     for (int i = 2; i < 15; i++)
     {
         players[2].hand.AddCard(new Card(3, i));
     }
     for (int i = 2; i < 15; i++)
     {
         players[3].hand.AddCard(new Card(4, i));
     }
     foreach (Player player in players)
     {
         Console.Write("Player " + player.name + " cards: ");
         foreach (Card card in player.hand.Cards)
         {
             Console.Write(card.ToString() + ", ");
         }
         Console.WriteLine();
     }
     SpecialGameCase troel = new Troel();
     Team[] teams = troel.Teams(players.ToArray());
     Assert.IsFalse(troel.AfterDealCheck(players.ToArray()));//no troel
 }
Пример #4
0
        //Set Game Case and teams
        public ResultData FinalizeBidding()
        {
            if (GameCase == 0)//GameCase 0 is FFA, perhaps unnecessary.
            {
                if (!passedPlayers.ContainsValue(false))//Everyone passed => FFA
                {
                    GameCase = Case.UNDECIDED;
                    throw new ApplicationException();
                }
            }

            Team[] teams;
            Player firstPlayer = players[0];
            switch (GameCase)
            {
                case Case.TEAM:
                    {
                        Team teamA = new Team(new Player[] { playerA, playerB }, 8);
                        Player[] others = players.Except(teamA.Players).ToArray();
                        Team teamB = new Team(others, 6);
                        teams = new Team[] { teamA, teamB };
                        break;
                    }
                case Case.ALONE:
                    {
                        Team teamA = new Team(new Player[] { playerA }, 5);
                        Player[] others = players.Except(teamA.Players).ToArray();
                        Team teamB = new Team(others, 9);
                        teams = new Team[] { teamA, teamB };
                        break;
                    }
                case Case.TROEL:
                    {
                        Troel troel = new Troel();
                        teams = troel.Teams(players);
                        Trump = troel.GetTrump(players);
                        firstPlayer = teams.Where(t => t.objective == 8).Single().Players.Where(p => p.hand.Cards.Where(c => c.Number == Numbers.ACE).Count() <= 1).Single();
                        break;
                    }
                case Case.ABONDANCE:
                    {
                        firstPlayer = specialGameCases[Case.ABONDANCE].selectedPlayers[0];
                        teams = specialGameCases[Case.ABONDANCE].Teams(players);
                        break;
                    }
                case Case.MISERIE:
                    {
                        teams = specialGameCases[Case.MISERIE].Teams(players);
                        break;
                    }
                case Case.SOLO:
                    {
                        firstPlayer = specialGameCases[Case.SOLO].selectedPlayers[0];
                        teams = specialGameCases[Case.SOLO].Teams(players);
                        break;
                    }
                case Case.SOLOSLIM:
                    {
                        firstPlayer = specialGameCases[Case.SOLOSLIM].selectedPlayers[0];
                        teams = specialGameCases[Case.SOLOSLIM].Teams(players);
                        break;
                    }
                default: return null;
            }

            return new ResultData(teams, GameCase, firstPlayer, Trump);
        }
Пример #5
0
 public void Test_Valid_And_Invalid_Actions_When_PASS_And_No_TROEL()
 {
     SpecialGameCase troel = new Troel();
     do
     {
         createPlayers();    //Need to be sure that it isn't troel, otherwise, if it's troel, tests will fail
     } while (troel.AfterDealCheck(players.ToArray()));
     DealAndBidNormal dealAndBid = new DealAndBidNormal(players.ToArray());
     dealAndBid.DoAction(Action.PASS);
     bool containsInvalidAction = false;
     bool containsActionPASS = false;
     bool containsActionASK = false;
     bool containsActionABONDANCE = false;
     bool containsActionMISERIE = false;
     bool containsActionSOLO = false;
     bool containsActionSOLOSLIM = false;
     foreach (Action action in dealAndBid.GetPossibleActions())
     {
         if (action == Action.JOIN)
         {
             containsInvalidAction = true;
             break;
         }
     }
     foreach (Action action in dealAndBid.GetPossibleActions())
     {
         if (action == Action.PASS)
         {
             containsActionPASS = true;
         }
         else if (action == Action.ASK)
         {
             containsActionASK = true;
         }
         else if (action == Action.ABONDANCE)
         {
             containsActionABONDANCE = true;
         }
         else if (action == Action.MISERIE)
         {
             containsActionMISERIE = true;
         }
         else if (action == Action.SOLO)
         {
             containsActionSOLO = true;
         }
         else if (action == Action.SOLOSLIM)
         {
             containsActionSOLOSLIM = true;
         }
     }
     Assert.IsFalse(containsInvalidAction);
     Assert.IsTrue(containsActionPASS);
     Assert.IsTrue(containsActionASK);
     Assert.IsTrue(containsActionABONDANCE);
     Assert.IsTrue(containsActionMISERIE);
     Assert.IsTrue(containsActionSOLO);
     Assert.IsTrue(containsActionSOLOSLIM);
 }