Exemple #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnStart_Click(object sender, RoutedEventArgs e)
 {
     foreach (RadioButton rbTemp in spTrumps.Children)
     {
         if (rbTemp != null && rbTemp.IsChecked == true)
         {
             TrumpSuit = Int32.Parse(rbTemp.Tag.ToString());
         }
     }
     foreach (RadioButton rbTemp in spDeckSize.Children)
     {
         if (rbTemp != null && rbTemp.IsChecked == true)
         {
             DeckSize = (Int32.Parse(rbTemp.Content.ToString()));
         }
     }
     foreach (RadioButton rbTemp in spNumPlayers.Children)
     {
         if (rbTemp != null && rbTemp.IsChecked == true)
         {
             NumPlayers = (Int32.Parse(rbTemp.Content.ToString()));
         }
     }
     if (TrumpSuit == 4)
     {
         //if trump suit not specified, randomly generate one
         TrumpSuit = (int)RangedRandom.GenerateUnsignedNumber(4, 0);
     }
     GameGui.numPlayers = NumPlayers;
     Result             = --DeckSize + (int)DeckFlags.AceHigh + (int)DeckFlags.UseTrump + (TrumpSuit << 9);
     this.Close();
 }
Exemple #2
0
 /// <summary>
 /// Creates a game gui with a human player and a dynamix number
 /// of computer players int numPlayers, int trumpsuit, int deckSize
 /// </summary>
 /// <param name="numPlayers"></param>
 public GameGui()
 {
     InitializeComponent();
     RangedRandom.PrimeRandomNumberGenerator();
     WindowState = WindowState.Maximized;
     Initialize();
     Round temp = new Round();
 }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        private void Initialize()
        {
            m_Game = null;
            GameMenu gm = new GameMenu();

            gm.ShowDialog();
            m_nGameFlags = gm.Result;
            RangedRandom.PrimeRandomNumberGenerator();
            m_Game = new Game(numPlayers, m_nGameFlags, this);
        }
 /// <summary>
 /// Used to shuffle the deck of cards. Deletes the contents of a PlayingCards
 /// collection and recreates a new one with random cards
 /// </summary>
 public void Shuffle()
 {
     Clear();
     m_Count = 0;
     // loop is used to create cards and put them into newDeck
     // on each iteration, the class variable m_Deck is updated with the contents
     // of the newDeck array, as shown in the textbook
     for (int Counter = 0; Counter <= m_DeckSize; Counter++)
     {
         PlayingCard pCard = null;
         do
         {
             uint floor   = (uint)PlayingCard.baseRank;
             uint ceiling = (uint)Util.CalculateOffsetSuitSize(m_SuitSize);
             uint myRank  = 0;
             uint mySuit  = RangedRandom.GenerateUnsignedNumber(4, 0);
             if (PlayingCard.isAceHigh && (int)DeckFlags.Large != m_DeckSize)
             {
                 ceiling++;
                 floor--;
                 myRank = RangedRandom.GenerateUnsignedNumber(floor, ceiling, (uint)m_Entropy) + 1;
             }
             else
             {
                 myRank = RangedRandom.GenerateUnsignedNumber(ceiling, (uint)m_Entropy) + 1;
             }
             pCard = new PlayingCard((Suit)mySuit, (Rank)myRank, m_SuitSize, true);
         } while (IsCardAlreadyInDeck(pCard));// if an existing card with the same suit and rank is there, don't add it
         Add(pCard);
         m_Count++;
     }
     //unfortunately the shuffle loop has a limitation that, when given a deck with an abnormal size
     //and aces high, the loop cannot accomodate the gap in ranks, so just set the rank ceiling to 14
     //and change numeric 14 cards to aces afterwards
     if (PlayingCard.isAceHigh && (int)DeckFlags.Large != m_DeckSize)
     {
         foreach (PlayingCard card in this)
         {
             if (14 == (uint)card.rank)
             {
                 card.rank = Rank.Ace;
             }
         }
     }
     Turnover();
 }