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


C# IGame.GetAllCardsInPlay方法代码示例

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


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

示例1: GetHandle

            public override IEffectHandle GetHandle(IGame game)
            {
                var controller = game.GetController(CardSource.Id);
                if (controller == null)
                    return base.GetHandle(game);

                var resourceful = game.GetCardInPlay<ICharacterInPlay>(CardSource.Id);
                if (resourceful == null || resourceful.Resources == 0)
                    return base.GetHandle(game);

                var creatures = game.GetAllCardsInPlay<ICharacterInPlay>().Where(x => x.HasTrait(Trait.Creature) && x.Damage > 0).ToList();
                if (creatures.Count == 0)
                    return base.GetHandle(game);

                var builder =
                    new ChoiceBuilder("Choose a Creature in play", game, controller);

                if (resourceful.Resources == 1)
                {
                    builder.Question(string.Format("'{0}' only has 1 resource available do you want to pay that one resource to heal a creature?", CardSource.Title))
                        .Answer(string.Format("Yes, I want to pay 1 resource from '{0}' to heal a creature", CardSource.Title), true)
                            .Question("Which Creature do you want to heal?")
                                .LastAnswers(creatures, item => string.Format("{0} ({1} damage, {2} hit points)", item.Title, item.Damage, item.Card.PrintedHitPoints), (source, handle, creature) => HealCreatureInPlay(source, handle, controller, resourceful, creature, 1));
                }
                else
                {
                    builder.Question("Which Creature do you want to heal?");

                    foreach (var creature in creatures)
                    {
                        //.Answers(creatures, item => string.Format("{0} ({1} damage, {2} hit points)", item.Title, item.Damage, item.Card.PrintedHitPoints), (source, handle, creature) => HealCreatureInPlay(source, handle, controller, resourceful, creature, 1));

                    //builder.Question(string.Format("How many resources do you want to pay from '{0}' to heal a creature?", CardSource.Title))
                        //.Answer(string.Format("Yes, I want to pay 1 resource from '{0}' to heal a creature", CardSource.Title), true)
                    }
                            
                }

                builder.LastAnswer(string.Format("No, I do not want to pay any resources from '{0}' to heal a creature", CardSource.Title), false, (source, handle, item) => handle.Cancel(string.Format("{0} chose not to have '{1}' pay any resources to heal a creature", controller.Name, CardSource.Title)));

                        

                
                return new EffectHandle(this, builder.ToChoice());
            }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:45,代码来源:Radagast.cs

示例2: GetHandle

            public override IEffectHandle GetHandle(IGame game)
            {
                var limit = new Limit(PlayerScope.None, TimeScope.Round, 1);

                var controller = game.GetController(CardSource.Id);
                if (controller == null)
                    return base.GetHandle(game);

                var resourceful = controller.CardsInPlay.OfType<ICharacterInPlay>().Where(x => x.Card.Id == source.Id).FirstOrDefault();
                if (resourceful == null || resourceful.Resources == 0)
                    return base.GetHandle(game);

                var characters = game.GetAllCardsInPlay<ICharacterInPlay>().Where(x => x.Damage > 0).ToList();
                if (characters.Count == 0)
                    return base.GetHandle(game);

                var builder =
                    new ChoiceBuilder("Choose a wounded character in play to heal", game, controller)
                        .Question("Which character do you want to heal 1 damage on?")
                            .Answers(characters, item => string.Format("{0} ({1} damage of {2} hit points)", item.Title, item.Damage, item.Card.PrintedHitPoints), (source, handle, character) => HealOneDamageOnCharacter(game, handle, controller, resourceful, character))
                            .LastAnswer(string.Format("No, I do not want to pay 1 resource from '{0}' to heal a character", CardSource.Title), false, (source, handle, item) => handle.Cancel(string.Format("{0} chose not to pay 1 resource from '{1}' to heal a character", controller.Name, CardSource.Title)));
                
                return new EffectHandle(this, builder.ToChoice(), limit);
            }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:24,代码来源:Glorfindel_Core.cs


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