本文整理汇总了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();
}
示例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();
}
示例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();
}
示例4: MoveCard
private void MoveCard(int pos, Deck deck1, Deck deck2)
{
Card cardToMove = deck1[pos];
deck1.RemoveAt(pos);
deck2.Add(cardToMove);
}