예제 #1
0
        private void BuildStation(Player player)
        {
            var stationSelection = player.SelectStation();

            UsedCards.AddRange(stationSelection.Cards);
            player.Cards.RemoveAll(c => stationSelection.Cards.Contains(c));

            MapCities.Single(c => c.City.Id == stationSelection.StationId).Owner = player;
        }
예제 #2
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;
        }