Example #1
0
        public void AddCards()
        {
            _hand.AddCards(
                new Card[] { new Card(PokerSuit.Club, PokerRank.Three),
                             new Card(PokerSuit.Club, PokerRank.Jack) }).Should().BeTrue();

            _hand.AddCards(
                new Card[] { new Card(PokerSuit.None, PokerRank.Three),
                             new Card(PokerSuit.Club, PokerRank.Nine) }).Should().BeFalse();
        }
Example #2
0
 public void DrawCards(int n)
 {
     int[] cards = new int[n];
     for (int i = 0; i < n; i++)
     {
         int cardDrawn = DrawCard();
         cards[i] = cardDrawn;
     }
     hand.AddCards(cards);
 }
        public TestModule() : base("/test")
        {
            Before += (ctx) => {
                Console.WriteLine($"Request from IP: {this.Request.UserHostAddress}");

                return(null);
            };



            Get("/HandValue", parameters => {
                //two new cards
                var card1 = CardDefinition.King | CardDefinition.Diamond;
                var card2 = CardDefinition.Ace | CardDefinition.Spade;
                var card3 = CardDefinition.Nine | CardDefinition.Club;
                var Hand  = new Hand();
                Hand.AddCards(card1, card2, card3);
                return(Hand);
            });

            Get("/Shoe", parameters => {
                var shoe = new Shoe(initialize: true);
                return(shoe.Draw());
            });

            Get("/Table", p => {
                TestModule.simpleTable = TestModule.simpleTable ?? new Table();
                return(TestModule.simpleTable);
            });

            Get("/Hand", p => {
                TestModule.simpleTable = TestModule.simpleTable ?? new Table();
                //return $"Card : {simpleTable.Shoe.Draw()}, count: {simpleTable.Shoe.CardsRemaining}";
                return(new {
                    card = simpleTable.Shoe.Draw(),
                    cardCount = simpleTable.Shoe.CardsRemaining
                });
            });

            Get("/User/", p => {
                return("");
            });

            Get("/TableStart", p => {
                var playerId           = this.Request.UserHostAddress.ToString();
                TestModule.simpleTable = TestModule.simpleTable ?? new Table();
                TestModule.simpleTable.AddPlayer(playerId);
                TestModule.simpleTable.GetPlayer(playerId).PlaceBet(10);
                TestModule.simpleTable.StartHand();
                return(TestModule.simpleTable.CurrentPlayer);
            });
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hand"></param>
        /// <param name="deck"></param>
        /// <param name="numCardsRequiredInHand"></param>
        private void DealRequiredNumberOfCardsToHand(Hand hand, Deck deck, int numCardsRequiredInHand)
        {
            var numCardsToDealToHand = numCardsRequiredInHand - hand.Cards.Count;

            if (numCardsToDealToHand <= 0)
            {
                return;
            }

            var randomCards = deck.TakeRandomCards(numCardsToDealToHand);

            hand.AddCards(randomCards);
        }
Example #5
0
        /**public void newGame()
         * {
         *  Deck theTalon = new Deck();
         *  Board theBoard = new Board();
         *  Hand playerHand = new Hand();
         *  Hand computerHand = new Hand();
         *
         *  int deckSize = 36;
         *  int handSize = 8;
         *  int roundNumber = 0;
         * }**/

        private void frmBoard_Load(object sender, EventArgs e)
        {
            //newGame();
            trumpCard         = theTalon.GetCard(deckSize - 1);
            trumpSuit         = trumpCard.Suit;
            pbTalon.Image     = trumpCard.GetCardImage();
            trumpCard.FaceUp  = true;
            pbTrumpSuit.Image = trumpCard.GetCardImage();

            playerHand.AddCards(theTalon, handSize);
            for (int i = 1; i <= handSize; i++)
            {
                playerHand[i].FaceUp = true;
                CardBox aCardBox = new CardBox(playerHand[i]);

                // Wire the apporpriate event handlers for each cardbox
                aCardBox.Click += CardBox_Click;

                // wire CardBox_MouseEnter for the "POP" visual effect
                aCardBox.MouseEnter += CardBox_MouseEnter;

                // wire CardBox_MouseLeave for the regular visual effect
                aCardBox.MouseLeave += CardBox_MouseLeave;

                pnlPlayerHand.Controls.Add(aCardBox);
                RealignCards(pnlPlayerHand);
            }

            computer.AddCards(theTalon, handSize);
            for (int i = 1; i <= handSize; i++)
            {
                computer.getCard(i).FaceUp = true;
                CardBox aCardBox = new CardBox(computer.getCard(i));

                // Wire the apporpriate event handlers for each cardbox
                aCardBox.Click += CardBox_Click;

                // wire CardBox_MouseEnter for the "POP" visual effect
                aCardBox.MouseEnter += CardBox_MouseEnter;

                // wire CardBox_MouseLeave for the regular visual effect
                aCardBox.MouseLeave += CardBox_MouseLeave;

                pnlOpponentHand.Controls.Add(aCardBox);
                RealignCards(pnlOpponentHand);
            }

            // Establish a baseline card for each player
            int playerLowest   = 0;
            int opponentLowest = 0;

            // Determine the lowest card of the proper suit - player
            foreach (CardBox cards in pnlPlayerHand.Controls)
            {
                if (cards.Card.Suit == trumpSuit)
                {
                    if (playerLowest == 0)
                    {
                        playerLowest = (int)cards.Card.Rank;
                    }
                    else if ((int)cards.Card.Rank < playerLowest)
                    {
                        playerLowest = (int)cards.Card.Rank;
                    }
                }
            }

            // Determine the lowest card of the proper suit - AI
            foreach (CardBox cards in pnlOpponentHand.Controls)
            {
                if (cards.Card.Suit == trumpSuit)
                {
                    if (opponentLowest == 0)
                    {
                        opponentLowest = (int)cards.Card.Rank;
                    }
                    else if ((int)cards.Card.Rank < playerLowest)
                    {
                        opponentLowest = (int)cards.Card.Rank;
                    }
                }
            }

            // Determine whose turn it is based on the lowest trump card
            // THIS DOESN'T ACCOUNT FOR TIES
            if (playerLowest < opponentLowest)
            {
                playerTurn  = true;
                AIAttacking = false;
            }
            else
            {
                playerTurn  = false;
                AIAttacking = true;
            }
        }
Example #6
0
 /// <summary>
 /// Add multiple cards to the players hand.
 /// </summary>
 /// <param name="cards"></param>
 public void AddCards(IEnumerable <Card> cards)
 {
     Hand.AddCards(cards);
 }
Example #7
0
 public void AddCards(Deck deck, int amount)
 {
     myHand.AddCards(deck, amount);
 }
Example #8
0
        protected override void Initialize()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            tweener = new Tweener();

            renderables = new List <IRenderable>();

            cards = new List <Card>();

            Board = new GameBoard();

            Player1Deck = new Deck(new List <Card>
            {
                new Boar(Content),
                new Boar(Content),
                new Boar(Content),
                new Boar(Content),
                new Boar(Content),
                new Boar(Content),
                new Boar(Content),
                new Boar(Content),
                new Boar(Content),
                new Possessed_Neophyte(Content),
                new Possessed_Neophyte(Content),
                new Possessed_Neophyte(Content),
                new Possessed_Neophyte(Content),
                new Possessed_Neophyte(Content)
            });

            Player1Deck.Shuffle(); // make shuffle take iterations as param

            cards.AddRange(Player1Deck._CardList);

            renderables.AddRange(Player1Deck._CardList);

            Player1Deck._CardList.ForEach(c => Console.WriteLine(c.Name));

            Player1Hand                = new Hand();
            Player1Hand.Position       = new Vector2((graphics.GraphicsDevice.Viewport.Width / 2f), graphics.GraphicsDevice.Viewport.Height - 350);
            Player1Hand.rotationOrigin = Player1Hand.Position + (Vector2.UnitY * 1600);
            rotationOrigin             = Player1Hand.Position;
            Player1Hand.AddCards(Player1Deck.Deal(3));

            basicEffect = new BasicEffect(GraphicsDevice)
            {
                TextureEnabled     = true,
                VertexColorEnabled = true,
            };

            Viewport viewport = GraphicsDevice.Viewport;

            Matrix projection      = Matrix.CreateOrthographicOffCenter(0, viewport.Width, viewport.Height, 0, 0, 1);
            Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);

            basicEffect.World      = Matrix.Identity * Matrix.CreateTranslation(0, 0, -0.5f);
            basicEffect.View       = Matrix.Identity;
            basicEffect.Projection = halfPixelOffset * projection;

            basicEffect.TextureEnabled     = true;
            basicEffect.VertexColorEnabled = true;

            base.Initialize();
        }
Example #9
0
 public void DealCard(Hand hand)
 {
     Random random = new Random();
     int index = random.Next(0, deck.Count);
     List<Card> additions = new List<Card>();
     additions.Add(this.deck[index]);
     hand.AddCards(additions);
     this.deck.RemoveAt(index);
 }
Example #10
0
 private void OnPullCard(Card[] pulled)
 {
     hand.AddCards(pulled);
 }