示例#1
0
 //this draws the card
 public int draw(cards deck)
 {
     if (deck.deck.Count == 0) //THIS KILLS THE DECK
     {
         System.Windows.Forms.MessageBox.Show("THE DECK IS EMPTY.  REPEAT.  THE DECK HAS RUN DRY.  PANIC MODE COMMENCE.  wait, never mind, new deck generating.","HALT",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error);
         generate();
         System.Windows.Forms.MessageBox.Show("new deck generated, game on.  note that this will result in, quite literally, doubles of every card.", "carry on", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
     }
     int drawncard, cardordinal;
     cardordinal = r.Next(0, deck.deck.Count); //random int between 0 and deck size
     drawncard = (int)deck.deck[cardordinal]; //choose this card by the deck indexer
     deck.deck.Remove(deck.deck[cardordinal]); //this card is no longer usable by anyone else and should now belong to a player's hand
     return drawncard; //let caller know what card you just got
 }
示例#2
0
        public int draw(cards deck)   //this draws the card
        {
            if (deck.deck.Count == 0) //THIS KILLS THE DECK
            {
                System.Windows.Forms.MessageBox.Show("THE DECK IS EMPTY.  REPEAT.  THE DECK HAS RUN DRY.  PANIC MODE COMMENCE.  wait, never mind, new deck generating.", "HALT", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                generate();
                System.Windows.Forms.MessageBox.Show("new deck generated, game on.  note that this will result in, quite literally, doubles of every card.", "carry on", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
            }
            int drawncard, cardordinal;

            cardordinal = r.Next(0, deck.deck.Count);  //random int between 0 and deck size
            drawncard   = (int)deck.deck[cardordinal]; //choose this card by the deck indexer
            deck.deck.Remove(deck.deck[cardordinal]);  //this card is no longer usable by anyone else and should now belong to a player's hand
            return(drawncard);                         //let caller know what card you just got
        }
示例#3
0
        //ctor makes a game thingy and draws cards for players to start with
        public game(player[] players)
        {
            playerList = players;
            gameDeck = new cards();
            for (int i = 0; i < 5; i++) //5 cards per player to start
            {
                for (int j = 0; j < playerList.Length; j++) //card 1 player 1 2 3 card 2 player 1 2 3...
                {
                    playerList[j].hand.Add(gameDeck.draw(gameDeck)); //draw a new random card from deck
                    playerList[j].hand.Sort();
                }
            }
            currentPlayer = players[0]; //start with player 1

            playArea = new playarea(this); //be sure the playarea can reference the game variables, pass it along
            playArea.Show();
            playArea.roundUpdate(currentPlayer);
            //game has started, thanks ctor
        }
示例#4
0
        public game(player[] players) //ctor makes a game thingy and draws cards for players to start with
        {
            playerList = players;
            gameDeck   = new cards();
            for (int i = 0; i < 5; i++)                              //5 cards per player to start
            {
                for (int j = 0; j < playerList.Length; j++)          //card 1 player 1 2 3 card 2 player 1 2 3...
                {
                    playerList[j].hand.Add(gameDeck.draw(gameDeck)); //draw a new random card from deck
                    playerList[j].hand.Sort();
                }
            }
            currentPlayer = players[0];    //start with player 1

            playArea = new playarea(this); //be sure the playarea can reference the game variables, pass it along
            playArea.Show();
            playArea.roundUpdate(currentPlayer);
            //game has started, thanks ctor
        }