本文整理汇总了C#中IPlayer.AddCard方法的典型用法代码示例。如果您正苦于以下问题:C# IPlayer.AddCard方法的具体用法?C# IPlayer.AddCard怎么用?C# IPlayer.AddCard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPlayer
的用法示例。
在下文中一共展示了IPlayer.AddCard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DealCardsToPlayer
public void DealCardsToPlayer(IPlayer playerToBeGivenCard, int numberOfCards)
{
Random rnd = new Random(); /*for making random numbers*/
int randomNumber = 0;
for (int i = 0; i < numberOfCards; i++)
{
if (_deck.Count > 0)
{
randomNumber = rnd.Next(0, _deck.Count); /*random number between 0 and deck.count*/
playerToBeGivenCard.AddCard(_deck[randomNumber]);
_deck.Remove(_deck[randomNumber]);
}
else
{
System.Console.WriteLine("Deck is empty, you damn noob!");
}
}
}
示例2: BuyDevelopmentCard
// 25 Development Cards (14 Knight/Soldier Cards, 6 Progress Cards, 5 Victory Point Cards)
//ore, wool and grain
public void BuyDevelopmentCard(IPlayer player, ITurn turn)
{
if (player == null)
throw new ArgumentNullException(nameof(player));
if (turn == null)
throw new ArgumentNullException(nameof(turn));
if (!player.HasResources(DEVELOPMENTCARD_COST))
throw new InvalidOperationException("Player does not have the resources to buy a Development Card");
player.TakeResources(DEVELOPMENTCARD_COST);
player.AddCard(new DevelopmentCard(deck.Pop(), turn));
}