Beispiel #1
0
        public void RemoveFromLine(int Line, GwentCard Card, bool IsToUsed)
        {
            int Ind = GetInd(Card, Lines[Line - 1]);

            Lines[Line - 1].RemoveAt(Ind);
            if (IsUserTurn)
            {
                Net.SendSimpleCommand(this.AffectedCardID, Line, Card.CardID,
                                      Card.IsSpecialAbilitiPerformed, true, IsToUsed);
            }
            if (this.IsUserTurn)
            {
                if (IsToUsed)
                {
                    UsedCards.Add(Card);
                    UsedCardsChanged();
                }
            }
            else
            {
                if (IsToUsed)
                {
                    OponentUsedCards.Add(Card);
                    OponentUsedCardsChanged();
                }
            }
            LineCardsChanged(Line);
        }
Beispiel #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;
        }
        /// <summary>
        ///   Get random card from the current deck
        /// </summary>
        /// <returns></returns>
        public GameCard Take()
        {
            var random = new Random();
            var index  = random.Next(Cards.Count);
            var card   = Cards[index];

            Cards.Remove(card);
            UsedCards.Add(card);
            // print this message to the debug console of visual studio
            Debug.WriteLine($"DeckHelper.Take: Random Index: {index}");
            Debug.WriteLine($"DeckHelper.Take: Card: Id {card.Id} - Suit: {card.Suit} - Value: {card.Value}");
            Debug.WriteLine($"DeckHelper.Take: Cards Length: {Cards.Count}");
            Debug.WriteLine($"DeckHelper.Take: Used Cards Length: {UsedCards.Count}");
            return(card);
        }
Beispiel #4
0
 public void EndRound()
 {
     this.UserCardsPower = 0;
     foreach (List <GwentCard> Cards in Lines)
     {
         foreach (GwentCard Card in Cards)
         {
             if (Card.CardLine > 3)
             {
                 OponentUsedCards.Add(Card);
             }
             else
             {
                 UsedCards.Add(Card);
             }
         }
         Cards.Clear();
     }
     OponentUsedCardsChanged();
     UsedCardsChanged();
     this.UserCardsPower = 0;
     RoundEnded();
 }