Ejemplo n.º 1
0
        public void LogPlayerCards(Player player, Card[] cards)
        {
            PlayerCardsInfo pci = new PlayerCardsInfo(cards[0].getCardId(), cards[1].getCardId(), game.Id, player.PlayerId, player.Username);
            string          str = PlayerCardsInfo.ConvertToString(pci);

            LatestAction = str;
            logOfCards.Add(str);
            game.Subject.NotifyCards(player.Username);
        }
Ejemplo n.º 2
0
        public void UpdatePlayerCardsInfo(string content)
        {
            PlayerCardsInfo playerCardsInfo = new PlayerCardsInfo(content);

            foreach (GameListener gameListener in RECEIVER.gameListeners)
            {
                gameListener.Update(playerCardsInfo);
            }
        }
Ejemplo n.º 3
0
 public void Update(PlayerCardsInfo playerCardsInfo)
 {
     if (playerCardsInfo.GameID == gameID && playerCardsInfo.PlayerID == playerID)
     {
         this.Dispatcher.Invoke(() =>
         {
             hole1.Source = GUICards.GetImageSource(playerCardsInfo.PlayerCards[0]);
             hole2.Source = GUICards.GetImageSource(playerCardsInfo.PlayerCards[1]);
         });
     }
 }
        public StartGameResult StartGame(Guid playerId)
        {
            var player = _playerRepository.GetById(playerId);

            if (player == null)
            {
                throw new NullReferenceException($"Отсутствует пользователь с id = {playerId}");
            }

            var gameTable = _gameTableRepository.GetByOwner(player);

            if (gameTable == null)
            {
                throw new Exception($"Игрок с Id = {playerId} не является создателем игрового стола");
            }

            gameTable.StartNewGame(player);

            var result = new StartGameResult()
            {
                GameTableId = gameTable.Id,
                MoverId     = gameTable.CurrentMover.Id,
                PlayerCards = new List <PlayerCardsInfo>()
            };

            foreach (var item in gameTable.Players)
            {
                var playerCards = gameTable.GetPlayerCards(item.Player.Id);

                var playerCardsItem = new PlayerCardsInfo()
                {
                    PlayerId   = item.Player.Id,
                    CardsCount = playerCards.Count,
                    Cards      = playerCards.Select(c => new PlayingCardDto()
                    {
                        Id = c.Id, Rank = (int)c.Rank, Suit = (int)c.Suit
                    }).ToList()
                };

                result.PlayerCards.Add(playerCardsItem);
            }

            return(result);
        }
Ejemplo n.º 5
0
 public void Update(PlayerCardsInfo playerCardsInfo)
 {
 }