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


C# Deck.AddCard方法代码示例

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


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

示例1: Read

        public static Deck Read(string name, byte[] content)
        {
            using (var reader = new StreamReader(new MemoryStream(content)))
            {
                string line;
                var lineNumber = 0;

                var deck = new Deck();
                deck.Name = name;

                while ((line = reader.ReadLine()) != null)
                {
                    lineNumber++;
                    line = line.Trim();

                    if (line.Trim().Length == 0)
                        continue;

                    if (line.StartsWith("#"))
                    {
                        var match = DescriptionRegex.Match(line);
                        if (match.Success)
                        {
                            deck.Description = match.Groups[1].Value;
                            continue;
                        }

                        match = RatingRegex.Match(line);
                        int rating;
                        if (match.Success)
                        {
                            int.TryParse(match.Groups[1].Value, out rating);
                            deck.Rating = rating;
                            continue;
                        }

                        match = LimitedCodeRegex.Match(line);
                        int limitedCode;
                        if (match.Success)
                        {
                            int.TryParse(match.Groups[1].Value, out limitedCode);
                            deck.LimitedCode = limitedCode;
                            continue;
                        }

                        continue;
                    }

                    var row = ParseRow(line, lineNumber);

                    deck.AddCard(row.Card, row.Count);
                }
                return deck;
            }
        }
开发者ID:BlacksheepNZ,项目名称:BattleOn,代码行数:55,代码来源:DeckFile.cs

示例2: Main

        static void Main(string[] args)
        {
            /* Making objects assigning ctor's the stuff */
            var myDeck = new Deck();
            IGame myGame = new LowGame(myDeck);
            var myPlayers = new List<IPlayer>();

            /* Filling deck with 1 of every card */
            for (var i = 1; i < 9; i++)             /* There are 8 different numbervalues */
            {
                for (var u = 1; u < 6; u++)         /* There are 5 different cardtypes */
                {
                    ICard myCard = new Card(i, u);  /* Making instans of every card */
                    myDeck.AddCard(myCard);         /* Adding card to deck */
                }
            }

            /* Making players, both weak and normal */
            myPlayers.Add(new WeakPlayer("Dennis"));
            myPlayers.Add(new WeakPlayer("Joachim"));
            myPlayers.Add(new Player("Bjørn"));
            //myPlayers.Add(new Player("Maria"));
            //myPlayers.Add(new Player("Tobias"));
            //myPlayers.Add(new WeakPlayer("Jacob"));

            /* Adding players to the game */
            foreach (var myPlayer in myPlayers)
            {
                myGame.AddPlayer(myPlayer);
            }

            /* Making console output pretty */
            System.Console.WriteLine("");

            /* Giving each player some cards */
            myGame.DealCards();

            /* Outputting players hands to console */
            foreach (var myPlayer in myPlayers)
            {
                myPlayer.ShowHand();
            }

            /* Determining who wins and outputting result */
            myGame.AnnounceWinner();
        }
开发者ID:BjornNorgaard,项目名称:I4SWD,代码行数:46,代码来源:Program.cs

示例3: CreateDeckFromCardList

        private static Deck CreateDeckFromCardList(List<Card> cards, IEnumerable<CardInfo> library)
        {
            var deck = new Deck();

              foreach (var card in cards)
              {
            var info = library.FirstOrDefault(x => x.Name.Equals(card.Name)) ??
              new CardInfo(card.Name, Rarity.C); // basic lands are not included in library

            deck.AddCard(info);
              }

              return deck;
        }
开发者ID:leloulight,项目名称:magicgrove,代码行数:14,代码来源:DeckBuilder.cs


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