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


C# Deck.Enqueue方法代码示例

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


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

示例1: LoadCommunityChestDeck

 public void LoadCommunityChestDeck()
 {
     CommunityChest = new Deck();
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("Advance Directly to Go");
         actor.MoveTo<GoSpace>();
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("Bank error in your favor - collect $200");
         actor.ModifyCapital(200);
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("Doctor's fee - pay $50");
         actor.Charge(50);
     }));
     CommunityChest.Enqueue(new GetOutOfJailCard(DeckType.CommunityChest, actor => actor.Tell("Get out of jail free; you can keep this card until you need it")));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("Go directly to jail.");
         actor.MoveTo<JailSpace>();
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("Opera night; collect $50 from everyone else");
         actor.ModifyCapital(actor.PlayingGame.Players.Select(p => p == actor ? 0 : p.Charge(50)).Sum());
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("Holiday fund matures - collect $100");
         actor.ModifyCapital(100);
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("Income tax refund; collect $20");
         actor.ModifyCapital(20);
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("It's your birthday; collect $10 from all other players");
         actor.ModifyCapital(actor.PlayingGame.Players.Select(p => p == actor ? 0 : p.Charge(10)).Sum());
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("Life Insurance matures - collect $100");
         actor.ModifyCapital(100);
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("Play hostpital fees of $100");
         actor.Charge(100);
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("Play school fees of $150");
         actor.Charge(150);
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("Recieve $25 consultancy fee");
         actor.ModifyCapital(25);
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("You have won second place in a beauty contest; collect $10");
         actor.ModifyCapital(10);
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         actor.Tell("You inherit $100");
         actor.ModifyCapital(100);
     }));
     CommunityChest.Enqueue(new Card(DeckType.CommunityChest, actor =>
     {
         int amount = Util.FilterSubclass<Property, ColoredProperty>(actor.GetProperties()).Select(p => p.Houses > 4 ? 115 : p.Houses * 40).Sum();
         if (amount > 0)
         {
             actor.Tell($"You are assesed for street repairs, and require a payment of ${amount}");
             actor.Charge(amount);
         }
         else
         {
             actor.Tell("You are assesed for street repairs, but are not deemed applicable for payment. You pay nothing.");
         }
     }));
 }
开发者ID:Maurdekye,项目名称:Misc-Projects,代码行数:88,代码来源:Game.cs

示例2: LoadChanceDeck

        public void LoadChanceDeck()
        {
            Chance = new Deck();
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Advance Directly to Go");
                actor.MoveTo<GoSpace>();
            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Advance to Illinois Ave");
                actor.MoveTo(s => s is PropertySpace && (s as PropertySpace).GetProperties().Single().Name == "Illinois Avenue");
                actor.PlayingGame.GameBoard[actor.BoardPosition].Land(actor);
            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Advance to St. Charles Place");
                actor.MoveTo(s => s is PropertySpace && (s as PropertySpace).GetProperties().Single().Name == "St. Charles Place");
                actor.PlayingGame.GameBoard[actor.BoardPosition].Land(actor);
            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Advance to the nearest utility and pay the owner 10 times the amount of a dice roll");
                actor.MoveTo(s => s is PropertySpace && (s as PropertySpace).GetProperties().Single() is UtilityProperty);
                UtilityProperty utility = (actor.PlayingGame.GameBoard[actor.BoardPosition] as PropertySpace).GetProperties().Single() as UtilityProperty;
                if (utility.Owner is Player)
                {
                    utility.Owner.ModifyCapital(actor.Charge(10 * Dice.Roll()));
                }
                else
                    actor.PlayingGame.GameBoard[actor.BoardPosition].Land(actor);
            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Advance token to the nearest Railroad and pay owner twice the rental to which he/she is otherwise entitled");
                actor.MoveTo(s => s is PropertySpace && (s as PropertySpace).GetProperties().Single() is StationProperty);
                StationProperty station = (actor.PlayingGame.GameBoard[actor.BoardPosition] as PropertySpace).GetProperties().Single() as StationProperty;
                if (station.Owner is Player)
                {
                    station.Owner.ModifyCapital(actor.Charge(2 * station.GetRent(actor)));
                }
                else
                    station.PlayingGame.GameBoard[actor.BoardPosition].Land(actor);

            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Bank pays you dividend of $50");
                actor.ModifyCapital(50);
            }));
            Chance.Enqueue(new GetOutOfJailCard(DeckType.Chance, actor => actor.Tell("Get out of Jail Free – This card may be kept until needed, or traded/sold")));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Go back 3 spaces");
                actor.BoardPosition = (actor.BoardPosition - 3) % actor.PlayingGame.GameBoard.Count;
                actor.PlayingGame.GameBoard[actor.BoardPosition].Land(actor);
            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Go directly to jail; do not pass go, do not collect $200");
                actor.SendToJail();
            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                int amount = Util.FilterSubclass<Property, ColoredProperty>(actor.GetProperties()).Select(p => p.Houses > 4 ? 100 : p.Houses * 25).Sum();
                if (amount > 0)
                {
                    actor.Tell($"You make general repairs on all of your properties, and end up paying ${amount}");
                    actor.Charge(amount);
                }
                else
                {
                    actor.Tell("You asses the need to make general repairs on any of your properties, but decide it is not necessary. You pay nothing.");
                }
            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Pay poor tax of $15");
                actor.Charge(15);
            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Take a trip to Reading Railroad");
                actor.MoveTo(s => s is PropertySpace && (s as PropertySpace).GetProperties().Single().Name == "Reading Railroad");
                actor.PlayingGame.GameBoard[actor.BoardPosition].Land(actor);
            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Take a walk on the Boardwalk - advance to Boardwalk");
                actor.MoveTo(s => s is PropertySpace && (s as PropertySpace).GetProperties().Single().Name == "Boardwalk");
                actor.PlayingGame.GameBoard[actor.BoardPosition].Land(actor);
            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("You have been elected Chairman of the Board; you pay each other player $50");
                actor.PlayingGame.Players.Where(p => p != actor).ToList().ForEach(p => p.ModifyCapital(actor.Charge(50)));
            }));
            Chance.Enqueue(new Card(DeckType.Chance, actor =>
            {
                actor.Tell("Your building loan matures; collect $150");
//.........这里部分代码省略.........
开发者ID:Maurdekye,项目名称:Misc-Projects,代码行数:101,代码来源:Game.cs


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