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


C# GameManager.playCard方法代码示例

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


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

示例1: makeMove

        public void makeMove(Player p, GameManager gm)
        {
            // Build the first card in the hand that we can build.  If there
            // are no buildable cards, discard the first one.
            foreach (Card c in p.hand)
            {
                if (p.isCardBuildable(c) == Buildable.True)
                {
                    gm.playCard(p, c, BuildAction.BuildStructure, true);
                    return;
                }
            }

            gm.playCard(p, p.hand[0], BuildAction.Discard, true);
        }
开发者ID:JamesFairweather,项目名称:7-Wonders-Leaders,代码行数:15,代码来源:AIMoveAlgorithm1.cs

示例2: makeMove

        public void makeMove(Player player, GameManager gm)
        {
            //go for blue cards whenever you can
            //if not, go for resources
            //otherwise, discard first card

            //look for buildable blue cards
            Card c = player.hand.Find(x => x.structureType == StructureType.Civilian && player.isCardBuildable(x) == Buildable.True);

            if (c != null)
            {
                gm.playCard(player, c, BuildAction.BuildStructure, true);
                return;
            }

            //look for buildable yellow cards that gives some resources
            c = player.hand.Find(x => x.structureType == StructureType.Commerce &&
                player.isCardBuildable(x) == Buildable.True &&
                x.effect is ResourceEffect);

            if (c != null)
            {
                gm.playCard(player, c, BuildAction.BuildStructure, true);
                return;
            }

            //look for buildable resource cards
            foreach(Card card in player.hand)
            {
                if ((card.structureType == StructureType.RawMaterial || card.structureType == StructureType.Goods) && player.isCardBuildable(card) == Buildable.True && card.effect is ResourceEffect)
                {
                    ResourceEffect e = card.effect as ResourceEffect;
                    char resource = e.resourceTypes[0];
                    int numOfResource = e.IsDoubleResource() ? 2 : 1;

                    if (resource == 'B' && numOfResource + player.brick < maxResourcesRequired ) { gm.playCard(player, card, BuildAction.BuildStructure, true); return; }
                    else if (resource == 'O' && numOfResource + player.ore < maxResourcesRequired) { gm.playCard(player, card, BuildAction.BuildStructure, true); return; }
                    else if (resource == 'T' && numOfResource + player.stone < maxResourcesRequired) { gm.playCard(player, card, BuildAction.BuildStructure, true); return; }
                    else if (resource == 'W' && numOfResource + player.wood < maxResourcesRequired) { gm.playCard(player, card, BuildAction.BuildStructure, true); return; }
                    else if (resource == 'G' && numOfResource + player.glass < maxResourcesRequired) { gm.playCard(player, card, BuildAction.BuildStructure, true); return; }
                    else if (resource == 'L' && numOfResource + player.loom < maxResourcesRequired) { gm.playCard(player, card, BuildAction.BuildStructure, true); return; }
                    else if (resource == 'P' && numOfResource + player.papyrus < maxResourcesRequired) { gm.playCard(player, card, BuildAction.BuildStructure, true); return; }
                }
            }

            //discard card[0]
            gm.playCard(player, player.hand[0], BuildAction.Discard, true);
        }
开发者ID:JamesFairweather,项目名称:7-Wonders-Leaders,代码行数:48,代码来源:AIMoveAlgorithm2.cs

示例3: makeMove

 public void makeMove(Player player, GameManager gm)
 {
     gm.playCard(player, player.hand[0], BuildAction.Discard, true);
 }
开发者ID:JamesFairweather,项目名称:7-Wonders-Leaders,代码行数:4,代码来源:AIMoveAlgorithm0.cs

示例4: makeMove

        public void makeMove(Player player, GameManager gm)
        {
            //go for blue cards only on the third age
            //if not, Discard Red Cards
            //otherwise, discard first card

            /*
            string strOutput = string.Format("{0} hand: [ ", player.nickname);

            if (gm.phase == GamePhase.LeaderRecruitment)
            {
                foreach (Card card in player.draftedLeaders)
                {
                    strOutput += card.Id;
                    strOutput += " ";
                }
            }
            else
            {
                foreach (Card card in player.hand)
                {
                    strOutput += card.Id;
                    strOutput += " ";
                }
            }

            strOutput += "]";

            logger.Info(strOutput);
            */

            if (gm.phase == GamePhase.LeaderDraft || gm.phase == GamePhase.LeaderRecruitment)
            {
                // int[] favouredLeaders = { 216, 220, 222, 232, 200, 208, 205, 221, 214, 236, 213 };
                CardId [] favouredLeaders = { CardId.Nero, CardId.Tomyris, CardId.Alexander, CardId.Hannibal, CardId.Caesar, CardId.Nefertiti, CardId.Cleopatra, CardId.Zenobia, CardId.Justinian };

                Card bestLeader = null;

                //try to find the highest rated card in hand
                //start looking for the highest rated card, then go down to the next highest, etc.
                foreach (CardId leaderName in favouredLeaders)
                {
                    if (gm.phase == GamePhase.LeaderDraft)
                    {
                        bestLeader = player.hand.Find(x => x.Id == leaderName);
                    }
                    else if (gm.phase == GamePhase.LeaderRecruitment)
                    {
                        bestLeader = player.draftedLeaders.Find(x => x.Id == leaderName);
                    }

                    if (bestLeader != null && player.isCardBuildable(bestLeader).buildable == CommerceOptions.Buildable.True)
                    {
                        break;
                    }
                }

                if (bestLeader == null && gm.phase == GamePhase.LeaderDraft)
                {
                    // this hand didn't contain a favoured leader, so draft the first one in the list.  We cannot
                    // discard during the draft.  Leaders may only be discarded for 3 coins during recruitment.
                    bestLeader = player.hand[0];
                }

                if (bestLeader != null)
                {
                    logger.Info(player.nickname + "Drafted leader: {0}", bestLeader.Id);
                    gm.playCard(player, bestLeader, BuildAction.BuildStructure, true, false, 0, 0, false);
                }
                else
                {
                    logger.Info(player.nickname + " Action: Discard {0}", player.draftedLeaders[0].Id);
                    gm.playCard(player, player.draftedLeaders[0], BuildAction.Discard, true, false, 0, 0, false);
                }

                return;
            }

            // Dictionary<Card, CardCost> cardValues = new Dictionary<Card, CardCost>(player.hand.Count);

            // Card cost:

            // NotBuildable
            // Free (the city has sufficient resources)
            // Coin cost to the bank only (flex brown, double, some City cards)
            // Commerce Required (can be constructed by paying neighbors for their resources)
            // If Commerce is required, how many coins to each neighbor and/or the bank

            CommerceOptions[] co = new CommerceOptions[player.hand.Count];
            int [] cardValues = new int[player.hand.Count];

            for (int i = 0; i < player.hand.Count; ++i)
            {
                co[i] = player.isCardBuildable(player.hand[i]);
            }

            CommerceOptions nextStageCost = player.isStageBuildable();

            for (int i = 0; i < player.hand.Count; ++i)
            {
//.........这里部分代码省略.........
开发者ID:JamesFairweather,项目名称:7-Wonders-Leaders,代码行数:101,代码来源:AIMoveAlgorithm4.cs

示例5: makeMove

        public void makeMove(Player player, GameManager gm)
        {
            //go for Red cards whenever you can
            //if not, Discard Red Cards
            //otherwise, discard first card

            string strOutput = string.Format("{0} hand: [ ", player.nickname);

            foreach (Card card in player.hand)
            {
                strOutput += card.Id;
                strOutput += " ";
            }

            strOutput += "]";

            //look for buildable Red cards
            Card c = player.hand.Find(x => x.structureType == StructureType.Military && player.isCardBuildable(x) == Buildable.True);

            if (c == null)
            {
                //look for buildable resource cards that give more than one resource ...
                foreach (Card card in player.hand)
                {
                    if ((card.structureType == StructureType.RawMaterial || card.structureType == StructureType.Goods) && player.isCardBuildable(card) == Buildable.True && card.effect is ResourceEffect)
                    {
                        string resource = ((ResourceEffect)card.effect).resourceTypes;

                        if (resource.Length < 3)
                            continue;

                        if (resource.Contains('B') && player.brick < maxOBS) { c = card; return; }
                        else if (resource.Contains('O') && player.ore < maxOBS) { c = card; return; }
                        else if (resource.Contains('S') && player.stone < maxOBS) { c = card; return; }
                        else if (resource.Contains('W') && player.wood < maxWood) { c = card; return; }
                        else if (resource.Contains('L') && player.loom < maxLoom) { c = card; return; }
                    }
                }
            }

            if (c == null)
            {
                //look for buildable resource cards that only give one ..
                foreach (Card card in player.hand)
                {
                    if ((card.structureType == StructureType.RawMaterial || card.structureType == StructureType.Goods) && player.isCardBuildable(card) == Buildable.True && card.effect is ResourceEffect)
                    {
                        ResourceEffect e = card.effect as ResourceEffect;

                        char resource = e.resourceTypes[0];
                        int numOfResource = e.IsDoubleResource() ? 2 : 1;

                        if (resource == 'B' && numOfResource + player.brick < maxOBS) { c = card; return; }
                        else if (resource == 'O' && numOfResource + player.ore < maxOBS) { c = card; return; }
                        else if (resource == 'S' && numOfResource + player.stone < maxOBS) { c = card; return; }
                        else if (resource == 'W' && numOfResource + player.wood < maxWood) { c = card; return; }
                        else if (resource == 'L' && numOfResource + player.loom < maxLoom) { c = card; return; }
                    }
                }
            }

            if (c == null)
            {
                //Discard the non-buildable Red cards
                foreach (Card card in player.hand)
                {
                    if (card.structureType == StructureType.Military && player.isCardBuildable(card) != Buildable.True)
                    {
                        Console.WriteLine(player.nickname + " Action: Discard {0}", card.Id);
                        gm.playCard(player, card, BuildAction.Discard, true);
                        return;
                    }
                }
            }

            if (c != null)
            {
                Console.WriteLine(player.nickname + " Action: Construct {0}", c.Id);
                gm.playCard(player, c, BuildAction.BuildStructure, true);
            }
            else
            {
                c = player.hand[0];
                Console.WriteLine(player.nickname + " Action: Discard {0}", c.Id);
                gm.playCard(player, c, BuildAction.Discard, true);
            }
        }
开发者ID:JamesFairweather,项目名称:7-Wonders-Leaders,代码行数:87,代码来源:AIMoveAlgorithm3.cs


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