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


C# IGame.HasAvailable方法代码示例

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


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

示例1: BuyPhase

        public void BuyPhase(IGame game, ITurn turn, IPlayer player)
        {
            foreach (ICard card in player.Hand)
            {
                if ((card.Type & CardType.Treasure) == CardType.Treasure)
                    turn.PlayTreasure(card);
            }

            while (turn.Buys > 0)
            {
                if (turn.Treasure >= 8 && game.HasAvailable(Game.Base.Cards.Province))
                    turn.BuyCard(Game.Base.Cards.Province);
                else if (turn.Treasure >= 6 && game.HasAvailable(Game.Base.Cards.Gold))
                    turn.BuyCard(Game.Base.Cards.Gold);
                else if (turn.Treasure >= 3 && game.HasAvailable(Game.Base.Cards.Silver))
                    turn.BuyCard(Game.Base.Cards.Silver);
                else
                    break;
            }
        }
开发者ID:mfenniak,项目名称:dominion-engine,代码行数:20,代码来源:Basic.cs

示例2: ActionPhase

        public void ActionPhase(IGame game, ITurn turn, IPlayer player)
        {
            ICard card;

            while (turn.Actions > 0)
            {
                card = Utils.GetCard<Village>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                card = Utils.GetCard<Market>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                card = Utils.GetCard<Cellar>(player.Hand);
                if (card != null)
                {
                    IList<ICard> discards = new List<ICard>();
                    foreach (ICard cardInHand in player.Hand)
                    {
                        if (!Object.ReferenceEquals(cardInHand, card))
                        {
                            if ((cardInHand.Type & CardType.Victory) == CardType.Victory &&
                                (cardInHand.Type & CardType.Action) != CardType.Action)
                                discards.Add(cardInHand);
                            else if ((Game.Base.Cards)cardInHand.CardEnum == Game.Base.Cards.Cellar)
                                discards.Add(cardInHand);
                        }
                    }
                    if (discards.Count > 0)
                    {
                        turn.PlayAction(card, discards);
                        continue;
                    }
                }

                card = Utils.GetCard<Smithy>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                card = Utils.GetCard<Mine>(player.Hand);
                if (card != null)
                {
                    ICard targetCard = Utils.GetCard<Copper>(player.Hand);
                    if (targetCard != null && game.HasAvailable(Game.Base.Cards.Silver))
                    {
                        turn.PlayAction(card, new Mine.MineData { Card = targetCard, TargetType = Game.Base.Cards.Silver });
                        continue;
                    }

                    targetCard = Utils.GetCard<Silver>(player.Hand);
                    if (targetCard != null && game.HasAvailable(Game.Base.Cards.Gold))
                    {
                        turn.PlayAction(card, new Mine.MineData { Card = targetCard, TargetType = Game.Base.Cards.Gold });
                        continue;
                    }
                }

                card = Utils.GetCard<Militia>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                card = Utils.GetCard<Woodcutter>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                card = Utils.GetCard<Moat>(player.Hand);
                if (card != null)
                {
                    turn.PlayAction(card, null);
                    continue;
                }

                break;
            }
        }
开发者ID:mfenniak,项目名称:dominion-engine,代码行数:91,代码来源:Actions1.cs

示例3: BuyPhase

        public void BuyPhase(IGame game, ITurn turn, IPlayer player)
        {
            foreach (ICard card in player.Hand)
            {
                if ((card.Type & CardType.Treasure) == CardType.Treasure)
                    turn.PlayTreasure(card);
            }

            while (turn.Buys > 0)
            {
                bool bought = true;
                if (turn.Treasure >= 8 && game.HasAvailable(Game.Base.Cards.Province))
                    turn.BuyCard(Game.Base.Cards.Province);
                else if (turn.Treasure >= 6 && game.HasAvailable(Game.Base.Cards.Gold))
                    turn.BuyCard(Game.Base.Cards.Gold);
                else if (turn.Treasure >= 5 && game.HasAvailable(Game.Base.Cards.Mine) && (Count(player, "Mine") / Count(player, "Cards")) < TuningParameters.Get<double>("MineRatio", 0))
                {
                    turn.BuyCard(Game.Base.Cards.Mine);
                    Increment(player, "Mine");
                }
                else if (turn.Treasure >= 5 && game.HasAvailable(Game.Base.Cards.Market) && (Count(player, "Market") / Count(player, "Cards")) < TuningParameters.Get<double>("MarketRatio", 0))
                {
                    turn.BuyCard(Game.Base.Cards.Market);
                    Increment(player, "Market");
                }
                else if (turn.Treasure >= 4 && game.HasAvailable(Game.Base.Cards.Smithy) && (Count(player, "Smithy") / Count(player, "Cards")) < TuningParameters.Get<double>("SmithyRatio", 0))
                {
                    turn.BuyCard(Game.Base.Cards.Smithy);
                    Increment(player, "Smithy");
                }
                else if (turn.Treasure >= 4 && game.HasAvailable(Game.Base.Cards.Militia) && (Count(player, "Militia") / Count(player, "Cards")) < TuningParameters.Get<double>("MilitiaRatio", 0))
                {
                    turn.BuyCard(Game.Base.Cards.Militia);
                    Increment(player, "Militia");
                }
                else if (turn.Treasure >= 3 && game.HasAvailable(Game.Base.Cards.Village) && (Count(player, "Village") / Count(player, "Cards")) < TuningParameters.Get<double>("VillageRatio", 0))
                {
                    turn.BuyCard(Game.Base.Cards.Village);
                    Increment(player, "Village");
                }
                else if (turn.Treasure >= 3 && game.HasAvailable(Game.Base.Cards.Woodcutter) && (Count(player, "Woodcutter") / Count(player, "Cards")) < TuningParameters.Get<double>("WoodcutterRatio", 0))
                {
                    turn.BuyCard(Game.Base.Cards.Woodcutter);
                    Increment(player, "Woodcutter");
                }
                else if (turn.Treasure >= 3 && game.HasAvailable(Game.Base.Cards.Silver))
                    turn.BuyCard(Game.Base.Cards.Silver);
                else if (turn.Treasure >= 2 && game.HasAvailable(Game.Base.Cards.Cellar) && (Count(player, "Cellar") / Count(player, "Cards")) < TuningParameters.Get<double>("CellarRatio", 0))
                {
                    turn.BuyCard(Game.Base.Cards.Cellar);
                    Increment(player, "Cellar");
                }
                else if (turn.Treasure >= 2 && game.HasAvailable(Game.Base.Cards.Moat) && (Count(player, "Moat") / Count(player, "Cards")) < TuningParameters.Get<double>("MoatRatio", 0))
                {
                    turn.BuyCard(Game.Base.Cards.Moat);
                    Increment(player, "Moat");
                }
                else if (turn.Treasure >= 2 && game.HasAvailable(Game.Base.Cards.Estate))
                    turn.BuyCard(Game.Base.Cards.Estate);
                else
                    bought = false;

                if (bought)
                {
                    Increment(player, "Cards");
                    continue;
                }
                else
                    break;
            }
        }
开发者ID:mfenniak,项目名称:dominion-engine,代码行数:71,代码来源:Actions1.cs


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