Exemplo n.º 1
0
        public void GivePlayerCardTest()
        {
            var players = new TablePlayer[]  {
                new TablePlayer {
                    PlayerId = 1, GameVariant = GamesVariants.Normal
                },
                new TablePlayer {
                    PlayerId = 2, GameVariant = GamesVariants.Normal
                },
                new TablePlayer {
                    PlayerId = 3, GameVariant = GamesVariants.Normal
                },
                new TablePlayer {
                    PlayerId = 4, GameVariant = GamesVariants.Normal
                }
            };

            CardUtil.SetHandCards(players, false);
            bool[] playersHasDiamondClubCard = new bool[4];
            for (var i = 0; i < players.Length; i++)
            {
                var hasPlayerDiamondClubCard = HasDiamondClubCard(players[i].GetHandCards());
                Assert.True(players[i].HasClubsQueenOnHand == hasPlayerDiamondClubCard);
            }
        }
Exemplo n.º 2
0
        public bool StartNewRound(int tableId)
        {
            PlayTable table = _context.PlayTables.Find(tableId);

            if (table != null &&
                (table.Status == PlayStatus.End || table.Status == PlayStatus.None || table.Status == PlayStatus.Stop || table.Status == PlayStatus.WinnersTime))
            {
                table.SetTableToNextGameTurn();
                var clinetUpdateAction = SwitchPlayer(table);
                var tablePlayers       = GetPlayersOfTable(tableId);
                _context.PlayTables.Update(table);

                if (tablePlayers.Length < 4)
                {
                    throw new System.Exception("This Table hase not 4 players");
                }
                table.Status = PlayStatus.SelectGameVarian;
                foreach (var player in tablePlayers)
                {
                    player.ClearForNextRound();
                }
                CardUtil.SetHandCards(tablePlayers, table.WithNiner);
                _context.TablePlayer.UpdateRange(tablePlayers);
                int changeCount = _context.SaveChanges();

                OnTableChanged(table.Id);
                foreach (var player in tablePlayers)
                {
                    OnPlayerCardsChanged(player.Id, player.GetHandCards());
                }


                return(changeCount > 0);
            }
            return(false);
        }