コード例 #1
0
        private void BuildConnection(Player player)
        {
            MapConnection selectedConnection;

            while (true)
            {
                var selectedConnectionId = player.SelectConnection();

                selectedConnection = MapConnections.Single(c => c.Connection.Id == selectedConnectionId);

                if (selectedConnection.IsFree)
                {
                    break;
                }
            }
            BuildSet buildSet = new BuildSet();

            buildSet.Color =
                selectedConnection.Connection.Color == (int)CardColor.Common
                ? player.SelectColor()
                : (CardColor)selectedConnection.Connection.Color;

            buildSet.JokersToBuild = selectedConnection.Connection.JokersRequired.GetValueOrDefault(0);
            buildSet.WagonsCost    = selectedConnection.Connection.Length;

            if (selectedConnection.Connection.IsTunnel)
            {
                var tunnelCards = new List <Card>();
                for (int i = 0; i < 3; i++)
                {
                    var card = Deck.Dequeue();
                    tunnelCards.Add(card);
                    UsedCards.Add(card);
                }

                var toAddCards = tunnelCards.Count(c => c.Color == buildSet.Color || c.Color == CardColor.Joker);
                buildSet.TunnelCost = toAddCards;
            }

            var cardsToBuild = player.GetCardsToBuild(buildSet);

            if (cardsToBuild == null)
            {
                ProvideCards(player);
                return;
            }
            UsedCards.AddRange(cardsToBuild);
            player.Cards.RemoveAll(c => cardsToBuild.Contains(c));
            MapConnections.Single(c => c.Connection.Id == selectedConnection.Connection.Id).Owner = player;
        }
コード例 #2
0
        public override List <Card> GetCardsToBuild(BuildSet buildSet)
        {
            var cards       = new List <Card>();
            var tunnelCards = buildSet.TunnelCost > 0 ? $" и {buildSet.TunnelCost} карт за туннель" : string.Empty;
            var jokersCards = buildSet.JokersToBuild > 0 ? $"И {buildSet.JokersToBuild} паровозов" : string.Empty;

            Console.WriteLine($"Вы должны заплатить {buildSet.WagonsCost}{tunnelCards} {buildSet.Color} цвета. {jokersCards}");
            var wagons = SelectCardsForPayment(buildSet.WagonsToBuild, buildSet.Color);

            if (wagons == null)
            {
                return(null);
            }
            cards.AddRange(wagons);

            var jokers = SelectCardsForPayment(buildSet.JokersToBuild, CardColor.Joker);

            if (jokers == null)
            {
                return(null);
            }
            cards.AddRange(jokers);
            return(cards);
        }
コード例 #3
0
ファイル: Player.cs プロジェクト: bashnia007/Ticket2Ride
 public virtual List <Card> GetCardsToBuild(BuildSet buildSet)
 {
     throw new NotImplementedException();
 }