コード例 #1
0
        internal void SetSavedData(Deck deck, HandsFromServer hfs, List <CardView> cribCards, List <CardView> playedCards, PlayerType dealer, Dictionary <string, string> countingState)
        {
            _dealer = dealer;
            NewGame(_dealer, deck);
            _deck.SharedCard = hfs.SharedCard;
            _player.Hand     = new Hand(hfs.PlayerCards);
            _computer.Hand   = new Hand(hfs.ComputerCards);

            if (dealer == PlayerType.Player)
            {
                _player.Crib      = new Crib(cribCards);
                _player.HasCrib   = true;
                _computer.HasCrib = false;
            }
            else
            {
                _computer.Crib    = new Crib(cribCards);
                _player.HasCrib   = false;
                _computer.HasCrib = true;
            }

            if (countingState != null && countingState.Count != 0)
            {
                _countingPhase = new CountingPhase(_player, _player.Hand.Cards, _computer, _computer.Hand.Cards);

                _countingPhase.Deserialize(countingState);
                CountingState state = new CountingState(_player, _computer);

                _countingPhase.State = state;
            }
        }
コード例 #2
0
        public HandsFromServer GetHfs()
        {
            HandsFromServer hfs = new HandsFromServer();

            hfs.ComputerCards = _computer.Hand.Cards;
            hfs.PlayerCards   = _player.Hand.Cards;
            hfs.SharedCard    = GetSharedCard();
            return(hfs);
        }
コード例 #3
0
        /// <summary>
        ///     Gives a new random set of 13 cards
        ///     also changes who the dealer is
        ///
        ///     you can pass in a set of cards for the game to deal (for testing only! :))
        /// </summary>
        public HandsFromServer ShuffleAndReturnAllCards(HandsFromServer hfs = null)
        {
            if (hfs == null)
            {
                _deck.Shuffle();
                _player.Hand   = new Hand(_deck.FirstHand);
                _computer.Hand = new Hand(_deck.SecondHand);

                hfs               = new HandsFromServer();
                hfs.PlayerCards   = _player.Hand.Cards;
                hfs.ComputerCards = _computer.Hand.Cards;
                hfs.SharedCard    = _deck.SharedCard;
            }
            else
            {
                _player.Hand     = new Hand(hfs.PlayerCards);
                _computer.Hand   = new Hand(hfs.ComputerCards);
                _deck.SharedCard = hfs.SharedCard;
            }



            //
            //  if the shared card is a Jack, the dealer gets 2 points
            if (_deck.SharedCard.Rank == 11) // jack
            {
                if (_dealer == PlayerType.Player)
                {
                    _player.Score += 2;
                }
                else
                {
                    _computer.Score += 2;
                }
            }

            return(hfs);
        }