Exemplo n.º 1
0
 public BjGameShared(string name, BjDealerShared dealer, Vector3 location, List <BjPlayerShared> players,
                     int minimumBet, int numberOfDecks, float blackjackBonus)
 {
     Name           = name;
     Dealer         = dealer;
     Location       = location;
     Players        = players;
     MinimumBet     = minimumBet;
     NumberOfDecks  = numberOfDecks;
     BlackjackBonus = blackjackBonus;
 }
Exemplo n.º 2
0
        /// <summary>
        ///     Converts to dealer.
        /// </summary>
        /// <param name="sharedDealer">The shared dealer.</param>
        /// <returns></returns>
        private static BjDealer ConvertToDealer(this BjDealerShared sharedDealer)
        {
            var updatedDealer = new BjDealer(sharedDealer.NetId, sharedDealer.Name)
            {
                CurrentHand = new BjHand(sharedDealer.CurrentHand.Bet,
                                         sharedDealer.CurrentHand.Cards)
                {
                    IsActive = sharedDealer.CurrentHand.IsActive
                },
                HasDeclaredActionOver = sharedDealer.HasDeclaredActionOver
            };

            return(updatedDealer);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Converts to dealer shared.
        /// </summary>
        /// <param name="dealer">The dealer.</param>
        /// <returns></returns>
        private static BjDealerShared ConvertToDealerShared(this BjDealer dealer)
        {
            var sharedDealer = new BjDealerShared(dealer.NetId, dealer.Name)
            {
                CurrentHand = new BjHandShared(dealer.CurrentHand.Bet,
                                               dealer.CurrentHand.Cards)
                {
                    IsActive = dealer.CurrentHand.IsActive
                },
                HasDeclaredActionOver = dealer.HasDeclaredActionOver
            };

            return(sharedDealer);
        }
Exemplo n.º 4
0
        public static bool TestConverters()
        {
            var dealer = new BjDealer(1, "Dealer");

            dealer.CurrentHand = new BjHand(0)
            {
                Cards = new List <PlayingCard> {
                    new PlayingCard(CardSuit.Clubs, CardFace.Ace),
                    new PlayingCard(CardSuit.Hearts, CardFace.Jack)
                }
            };

            var player = new BjPlayer(2, "Player", 1, 5000);

            player.CurrentHands = new List <BjHand> {
                new BjHand {
                    Bet      = 10,
                    IsActive = true,
                    Cards    = new List <PlayingCard> {
                        new PlayingCard(CardSuit.Spades, CardFace.Two),
                        new PlayingCard(CardSuit.Diamonds, CardFace.Three)
                    }
                }
            };

            var game = new BjGame(dealer, Vector3.One, new List <BjPlayer> {
                player
            }, 10, 4, 1.5f);

            game.IsActive = true;

            var sharedDealer = new BjDealerShared(1, "Dealer");

            sharedDealer.CurrentHand = new BjHandShared(0)
            {
                Cards = new List <PlayingCard> {
                    new PlayingCard(CardSuit.Clubs, CardFace.Ace),
                    new PlayingCard(CardSuit.Hearts, CardFace.Jack)
                }
            };

            var sharedPlayer = new BjPlayerShared(2, "Player", 1, 5000);

            sharedPlayer.CurrentHands = new List <BjHandShared> {
                new BjHandShared {
                    Bet      = 10,
                    IsActive = true,
                    Cards    = new List <PlayingCard> {
                        new PlayingCard(CardSuit.Spades, CardFace.Two),
                        new PlayingCard(CardSuit.Diamonds, CardFace.Three)
                    }
                }
            };

            var sharedGame = new BjGameShared(sharedDealer.Name, sharedDealer, Vector3.One,
                                              new List <BjPlayerShared> {
                sharedPlayer
            }, 10, 4, 1.5f);


            var gameConverted   = game.ConvertToGameShared();
            var sharedConverted = sharedGame.ConvertToGame(null);

            bool test1 = BjSharedConverters.TestConvertSharedToGame(sharedConverted, game);
            bool test2 = BjSharedConverters.TestConvertGameToShared(gameConverted, sharedGame);

            Log.ToChat($"TestConvertSharedToGame success={test1}");
            Log.ToChat($"TestConvertSharedToGame success={test2}");

            return(test1 && test2);
        }