Пример #1
0
        public static bool IsCanBuyCard(this Price price, PlayerData player)
        {
            var additionalGold = 0;
            foreach (var gem in price.Gems)
            {
                var requiredGems = gem.Value;
                var playerGemsCount = player.GemHolder.Gems[gem.Key] + player.BoughtCards.Count(x => x.GemProduct == gem.Key);
                var difference = playerGemsCount - requiredGems;

                if (difference > 0)
                {
                    additionalGold += difference;
                }
            }

            return player.GemHolder.Gems[Gem.Gold] >= additionalGold;
        }
Пример #2
0
        public static void BuyCard(this Price priceDto, PlayerData player)
        {
            var additionalGold = 0;
            foreach (var gem in priceDto.Gems)
            {
                var requiredGems = gem.Value;
                var playerGemsFromCardsCount = player.BoughtCards.Count(x => x.GemProduct == gem.Key);
                var requiredGemsFromRepository = Math.Min(requiredGems - playerGemsFromCardsCount, 0);

                if (player.GemHolder.Gems[gem.Key] < requiredGemsFromRepository)
                {
                    additionalGold += requiredGemsFromRepository - player.GemHolder.Gems[gem.Key];
                }
            }

            if (additionalGold > player.GemHolder.Gems[Gem.Gold])
            {
                throw new InvalidOperationException("Can't buy card");
            }

            player.GemHolder.Gems[Gem.Gold] -= additionalGold;
        }
 public PlayerActionProcessorManager(GameData gameData, PlayerData playerData, PlayerRoundStatus playerRoundStatus)
 {
     _gameData = gameData;
     _playerData = playerData;
     _playerRoundStatus = playerRoundStatus;
 }
Пример #4
0
 public void BuyCard(int id, PlayerData playerData)
 {
     TransferCardTo(id, playerData.BoughtCards);
 }
Пример #5
0
 public void BookCard(int id, PlayerData playerData)
 {
     TransferCardTo(id, playerData.BookedCards);
 }
Пример #6
0
 public Player(PlayerData data, IPlayerConnection connection)
 {
     PlayerData = data;
     Connection = connection;
     RoundStatus = new PlayerRoundStatus();
 }