コード例 #1
0
ファイル: GameStats.cs プロジェクト: 66zjy/AllanHDT
 public void SetPlayerCards(Deck deck, List <Card> revealedCards)
 {
     PlayerCards.Clear();
     foreach (var c in revealedCards)
     {
         var card = PlayerCards.FirstOrDefault(x => x.Id == c.Id);
         if (card != null)
         {
             card.Count++;
         }
         else
         {
             PlayerCards.Add(new TrackedCard(c.Id, c.Count));
         }
     }
     if (deck != null)
     {
         foreach (var c in deck.Cards)
         {
             var e = PlayerCards.FirstOrDefault(x => x.Id == c.Id);
             if (e == null)
             {
                 PlayerCards.Add(new TrackedCard(c.Id, c.Count, c.Count));
             }
             else if (c.Count > e.Count)
             {
                 e.Unconfirmed = c.Count - e.Count;
                 e.Count       = c.Count;
             }
         }
     }
 }
コード例 #2
0
 private void FillPlayerHand()
 {
     foreach (var card in Player.Hand)
     {
         PlayerCards.Add(new PlayerCard(card.Suit, card.Nominal, true));
     }
 }
コード例 #3
0
ファイル: Hand.cs プロジェクト: kevin-lane/Texas-Holdem
 public void AddCard(Card card, bool isPlayerCard)
 {
     if (isPlayerCard == true && PlayerCards.Count < 2)
     {
         PlayerCards.Add(card);
     }
     Cards.Add(card);
 }
コード例 #4
0
 public void TakeCard(Card card)
 {
     if (card == null)
     {
         return;
     }
     PlayerCards.Add(card);
 }
コード例 #5
0
        public void GetNextCard()
        {
            var random       = new Random();
            var randomCard   = random.Next(Deck.Cards.Count);
            var selectedCard = Deck.Cards.ElementAt(randomCard);

            PlayerCards.Add(selectedCard);
            Deck.Cards.Remove(selectedCard);
        }
コード例 #6
0
ファイル: Game.cs プロジェクト: GreavesJim/BlackJack
        public void Hit()
        {
            Random rng   = new Random();
            int    index = rng.Next(Cards.Count);
            Card   Dealt = Cards[index];

            PlayerCards.Add(Dealt);
            Cards.RemoveAt(index);
            Validate();
        }
コード例 #7
0
        private void HandOutCardsToPlayer()
        {
            do
            {
                if (Deck.Count == 0)
                {
                    return;
                }
                if (PlayerCards.Count >= DefaultPlayerCardsCount)
                {
                    break;
                }

                PlayerCards.Add(Deck[Deck.Count - 1]);
                Deck.RemoveAt(Deck.Count - 1);
            } while (Deck.Count > 0);
        }
コード例 #8
0
ファイル: Game.cs プロジェクト: GreavesJim/BlackJack
 public void DealCards()
 {
     for (int i = 0; i < 2; i++)
     {
         Random rng   = new Random();
         int    index = rng.Next(Cards.Count);
         Card   Dealt = Cards[index];
         PlayerCards.Add(Dealt);
         Cards.RemoveAt(index);
     }
     for (int i = 0; i < 2; i++)
     {
         Random rng   = new Random();
         int    index = rng.Next(Cards.Count);
         Card   Dealt = Cards[index];
         CompCards.Add(Dealt);
         Cards.RemoveAt(index);
     }
 }
コード例 #9
0
ファイル: PlayerCardsViewModel.cs プロジェクト: schulzy/Dixit
        public async void GetNewCard()
        {
            _canGetNewCard = false;
            GetNewCardCommand.RaiseCanExecuteChanged();
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://localhost:44324/");
                var request         = new HttpRequestMessage(HttpMethod.Get, "api/Card");
                var responseMessage = await client.SendAsync(request);

                var byteArray = await responseMessage.Content.ReadAsByteArrayAsync();

                var image = LoadImage(byteArray);
                PlayerCards.Add(new PlayerCardModel()
                {
                    BitmapImage = image, HashCode = GetHashSHA1(byteArray)
                });
            }
            _canGetNewCard = true;
            GetNewCardCommand.RaiseCanExecuteChanged();
        }
コード例 #10
0
        public void GetAll(PlayerType player)
        {
            // There can be two types of situation
            // First: when that is player's party and enemy's turn
            // In this case we extend player's list of cards with list of cards from desc. Thern we clear desc.
            //
            // Second: when that is enemy's party and player's turn
            // In this case we make the same thing
            //
            // In other cases we just refuse action

            if (IsBlocked)
            {
                return;
            }
            switch (GameState)
            {
            case GameState.Ready: GameState = GameState.Playing; break;

            case GameState.Finished: return;

            case GameState.Playing: break;

            default: return;
            }

            if (DescPairs.Count == 0)
            {
                if (OnActionRefused != null)
                {
                    OnActionRefused(GameAction.Pass, GameError.Warning, "You cant't say get all");
                }
                return;
            }

            if (WhoseParty == PlayerType.Player)
            {
                if (player != PlayerType.Enemy)
                {
                    if (OnActionRefused != null)
                    {
                        OnActionRefused(GameAction.GetAll, GameError.Warning, "You cant't say get all");
                    }
                    return;
                }

                foreach (var cardPair in DescPairs)
                {
                    EnemyCards.Add(cardPair.LowerCard);
                    if (cardPair.UpperCard != null)
                    {
                        EnemyCards.Add((Card)cardPair.UpperCard);
                    }
                }

                DescPairs.Clear();

                if (OnGetAll != null)
                {
                    OnGetAll(player);
                }
                HandOutCards();
                WhoseTurn = PlayerType.Player;
                CheckGameState();
                return;
            }

            if (WhoseParty == PlayerType.Enemy)
            {
                if (player != PlayerType.Player)
                {
                    if (OnActionRefused != null)
                    {
                        OnActionRefused(GameAction.GetAll, GameError.Warning, "You cant't say get all");
                    }
                    return;
                }

                foreach (var cardPair in DescPairs)
                {
                    PlayerCards.Add(cardPair.LowerCard);
                    if (cardPair.UpperCard != null)
                    {
                        PlayerCards.Add((Card)cardPair.UpperCard);
                    }
                }

                DescPairs.Clear();

                if (OnGetAll != null)
                {
                    OnGetAll(player);
                }
                HandOutCards();
                WhoseTurn = PlayerType.Enemy;
                CheckGameState();
                return;
            }
        }
コード例 #11
0
 //to add a card to the pleyer
 public void AddCardToPlayer(Card newCard)
 {
     PlayerCards.Add(newCard);
 }
コード例 #12
0
 public void AddCardToHand(Card card)
 {
     PlayerCards.Add(card);
 }