当前位置: 首页>>代码示例>>C#>>正文


C# Deck.RemoveAt方法代码示例

本文整理汇总了C#中Deck.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# Deck.RemoveAt方法的具体用法?C# Deck.RemoveAt怎么用?C# Deck.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Deck的用法示例。


在下文中一共展示了Deck.RemoveAt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DealCards

 public void DealCards(Deck deck)
 {
     rwl.AcquireWriterLock(10000);
     string filename = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"/Table1.xml";
     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.Load(filename);
     XmlNodeList players = xmlDoc.SelectNodes("/Table/Players/Player");
     for(int i = 0; i < 2; i++)
     {
         int count = 0;
         foreach (XmlNode player in players)
         {
             count++;
             XmlElement card = xmlDoc.CreateElement("Card");
             card.SetAttribute("CardRank", deck[0].Rank);
             card.SetAttribute("CardSuit", deck[0].Suit);
             card.SetAttribute("CardValue", deck[0].CardValue.ToString());
             player.FirstChild.FirstChild.FirstChild.AppendChild(card);
             deck.RemoveAt(0);
         }
         XmlElement dealerCard = xmlDoc.CreateElement("Card");
         dealerCard.SetAttribute("CardRank", deck[0].Rank);
         dealerCard.SetAttribute("CardSuit", deck[0].Suit);
         dealerCard.SetAttribute("CardValue", deck[0].CardValue.ToString());
         XmlNode dealerCards = xmlDoc.SelectSingleNode("Table/Dealer/DealerCards");
         dealerCards.AppendChild(dealerCard);
         deck.RemoveAt(0);
     }
     xmlDoc.Save(filename);
     rwl.ReleaseWriterLock();
 }
开发者ID:no1spirite,项目名称:BlackJack,代码行数:31,代码来源:XmlWriter.cs

示例2: PlayerHit

 public void PlayerHit(HitMessageToServer msg, Deck deck)
 {
     rwl.AcquireWriterLock(10000);
     string filename = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"/Table1.xml";
     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.Load(filename);
     XmlNode hand = xmlDoc.SelectSingleNode("/Table/Players/Player[@PlayerId='" + msg.playerId + "']/Hands/Hand[@HandId='"+ msg.handId +"']");
     XmlElement card = xmlDoc.CreateElement("Card");
     card.SetAttribute("CardRank", deck[0].Rank);
     card.SetAttribute("CardSuit", deck[0].Suit);
     card.SetAttribute("CardValue", deck[0].CardValue.ToString());
     hand.FirstChild.AppendChild(card);
     deck.RemoveAt(0);
     xmlDoc.Save(filename);
     rwl.ReleaseWriterLock();
 }
开发者ID:no1spirite,项目名称:BlackJack,代码行数:16,代码来源:XmlWriter.cs

示例3: PlayerSplit

        public void PlayerSplit(SplitMessageToServer msg, Deck deck)
        {
            rwl.AcquireWriterLock(10000);
            string filename = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"/Table1.xml";
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(filename);
            XmlNode hands = xmlDoc.SelectSingleNode("/Table/Players/Player[@PlayerId='" + msg.playerId + "']/Hands");
            XmlElement newHand = xmlDoc.CreateElement("Hand");
            XmlElement newCards = xmlDoc.CreateElement("Cards");
            XmlElement newChips = xmlDoc.CreateElement("Chips");
            newHand.SetAttribute("HandId", (msg.handId + 1).ToString());

            XmlNode card = null;
            XmlNodeList cards = xmlDoc.SelectNodes("/Table/Players/Player[@PlayerId='" + msg.playerId + "']/Hands/Hand[@HandId='" + msg.handId + "']/Cards/Card");
            for (int i = 0; i < cards.Count; i++)
            {
                if (i == 1)
                    card = cards[i];
            }
            newCards.AppendChild(card);

            XmlNode hand = xmlDoc.SelectSingleNode("/Table/Players/Player[@PlayerId='" + msg.playerId + "']/Hands/Hand[@HandId='" + msg.handId + "']");
            XmlElement firstCard = xmlDoc.CreateElement("Card");
            firstCard.SetAttribute("CardRank", deck[0].Rank);
            firstCard.SetAttribute("CardSuit", deck[0].Suit);
            firstCard.SetAttribute("CardValue", deck[0].CardValue.ToString());
            hand.FirstChild.AppendChild(firstCard);
            deck.RemoveAt(0);

            XmlElement secondCard = xmlDoc.CreateElement("Card");
            secondCard.SetAttribute("CardRank", deck[0].Rank);
            secondCard.SetAttribute("CardSuit", deck[0].Suit);
            secondCard.SetAttribute("CardValue", deck[0].CardValue.ToString());
            newCards.AppendChild(secondCard);
            deck.RemoveAt(0);

            newHand.AppendChild(newCards);

            XmlNode chips = xmlDoc.SelectSingleNode("/Table/Players/Player[@PlayerId='" + msg.playerId + "']/Hands/Hand[@HandId='" + msg.handId+1 + "']/Chips");
            XmlNodeList currentChips = xmlDoc.SelectNodes("/Table/Players/Player[@PlayerId='" + msg.playerId + "']/Hands/Hand[@HandId='" + msg.handId + "']/Chips/Chip");
            for (int i = 0; i < currentChips.Count; i++)
            {
                XmlElement newChip = xmlDoc.CreateElement("Chip");
                newChip.SetAttribute("ChipAmount", currentChips[i].Attributes["ChipAmount"].Value);
                newChips.AppendChild(newChip);
            }
            newHand.AppendChild(newChips);

            hands.AppendChild(newHand);
            xmlDoc.Save(filename);
            rwl.ReleaseWriterLock();
        }
开发者ID:no1spirite,项目名称:BlackJack,代码行数:52,代码来源:XmlWriter.cs

示例4: MoveCard

 private void MoveCard(int pos, Deck deck1, Deck deck2)
 {
     Card cardToMove = deck1[pos];
     deck1.RemoveAt(pos);
     deck2.Add(cardToMove);
 }
开发者ID:pietroiusti,项目名称:HFCS,代码行数:6,代码来源:Form1.cs


注:本文中的Deck.RemoveAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。