예제 #1
0
        public static void Configure()
        {
            Server.Utility.PushColor(ConsoleColor.White);

            Card[] testHand = new Card[7]
            {
                new Card(CardSuit.Clubs, CardValue.Two),
                new Card(CardSuit.Diamonds, CardValue.Two),
                new Card(CardSuit.Hearts, CardValue.Three),
                new Card(CardSuit.Spades, CardValue.Three),
                new Card(CardSuit.Diamonds, CardValue.Three),
                new Card(CardSuit.Hearts, CardValue.Seven),
                new Card(CardSuit.Spades, CardValue.King)
            };
            CardValue highCard;

            Console.WriteLine("\n===== hand eval result: {0} [high card={1}]\n", HandEvaluator.EvaluateHand(testHand, out highCard), highCard);

            #region old tests
            CardDeck deck = new CardDeck(DeckSize.One);
            Console.WriteLine("\n===== single deck contents:\n{0}\n", deck.PrintContents());

            Card c = new Card(CardSuit.Diamonds, CardValue.Ten);
            Console.WriteLine("\n===== Ten of Diamonds: {0} | {1}\n", c.ToSimpleString(), c.ToString());

            PokerHand hand1 = new PokerHand(5);
            PokerHand hand2 = new PokerHand(5);
            deck.DealCards(new PokerHand[] { hand1, hand2 }, 6);

            Console.WriteLine("\n===== hand1: {0}", hand1.ToString());
            Console.WriteLine("===== hand2: {0}", hand2.ToString());
            Console.WriteLine("\n===== new deck contents:\n{0}\n", deck.PrintContents());

            hand1.ReturnToDeck();
            hand2.ReturnToDeck();

            Stopwatch sw         = new Stopwatch();
            byte      shuffleAmt = byte.MaxValue;
            Console.WriteLine("===== hands returned to deck...shuffling {0} times", shuffleAmt);
            sw.Start();
            deck.ShuffleDeck(shuffleAmt);
            sw.Stop();
            Console.WriteLine("===== deck shuffled, time taken: {0} milliseconds | {1} seconds", sw.ElapsedMilliseconds, (sw.ElapsedMilliseconds / 1000));
            Console.WriteLine("\n===== deck contents:\n{0}\n", deck.PrintContents());
            Console.WriteLine("===== deck length={0}", deck.deck.Count);

            PokerHand pkh = new PokerHand(7);
            deck.DealCards(new PokerHand[] { pkh }, 7);
            Console.WriteLine("\n===== unsorted: {0}", pkh.ToString());
            Array.Sort <Card>(pkh.Cards);
            Console.WriteLine("===== sorted: {0}", pkh.ToString());
            #endregion

            Server.Utility.PopColor();
        }
예제 #2
0
		public static void Configure()
		{
			Server.Utility.PushColor( ConsoleColor.White );

			Card[] testHand = new Card[7]
		    {
		        new Card( CardSuit.Clubs, CardValue.Two ),
		        new Card( CardSuit.Diamonds, CardValue.Two ),
		        new Card( CardSuit.Hearts, CardValue.Three ),
		        new Card( CardSuit.Spades, CardValue.Three ),
		        new Card( CardSuit.Diamonds, CardValue.Three ),
		        new Card( CardSuit.Hearts, CardValue.Seven ),
		        new Card( CardSuit.Spades, CardValue.King )
		    };
			CardValue highCard;

			Console.WriteLine( "\n===== hand eval result: {0} [high card={1}]\n", HandEvaluator.EvaluateHand( testHand, out highCard ), highCard );

			#region old tests
			CardDeck deck = new CardDeck( DeckSize.One );
			Console.WriteLine( "\n===== single deck contents:\n{0}\n", deck.PrintContents() );

			Card c = new Card( CardSuit.Diamonds, CardValue.Ten );
			Console.WriteLine( "\n===== Ten of Diamonds: {0} | {1}\n", c.ToSimpleString(), c.ToString() );

			PokerHand hand1 = new PokerHand( 5 );
			PokerHand hand2 = new PokerHand( 5 );
			deck.DealCards( new PokerHand[] { hand1, hand2 }, 6 );

			Console.WriteLine( "\n===== hand1: {0}", hand1.ToString() );
			Console.WriteLine( "===== hand2: {0}", hand2.ToString() );
			Console.WriteLine( "\n===== new deck contents:\n{0}\n", deck.PrintContents() );

			hand1.ReturnToDeck();
			hand2.ReturnToDeck();

			Stopwatch sw = new Stopwatch();
			byte shuffleAmt = byte.MaxValue;
			Console.WriteLine( "===== hands returned to deck...shuffling {0} times", shuffleAmt );
			sw.Start();
			deck.ShuffleDeck( shuffleAmt );
			sw.Stop();
			Console.WriteLine( "===== deck shuffled, time taken: {0} milliseconds | {1} seconds", sw.ElapsedMilliseconds, (sw.ElapsedMilliseconds / 1000) );
			Console.WriteLine( "\n===== deck contents:\n{0}\n", deck.PrintContents() );
			Console.WriteLine( "===== deck length={0}", deck.deck.Count );

			PokerHand pkh = new PokerHand( 7 );
			deck.DealCards( new PokerHand[] { pkh }, 7 );
			Console.WriteLine( "\n===== unsorted: {0}", pkh.ToString() );
			Array.Sort<Card>( pkh.Cards );
			Console.WriteLine( "===== sorted: {0}", pkh.ToString() );
			#endregion

			Server.Utility.PopColor();
		}
예제 #3
0
        protected virtual void EndRemovePlayer(Mobile from, object target)
        {
            if (target is PlayerMobile)
            {
                if (CardGame.IsPlaying((PlayerMobile)target))
                {
                    PokerHand hand = CardGame.Players[(PlayerMobile)target];
                    hand.ReturnToDeck();

                    CardGame.RemovePlayer((PlayerMobile)target);
                }
            }
            else
            {
                BeginRemovePlayer();
                from.SendMessage("That cannot be a player of this game.");
            }
        }