示例#1
0
            public override IEffectHandle GetHandle(IGame game)
            {
                var controller = game.GetController(CardSource.Id);

                if (controller == null)
                {
                    throw new InvalidOperationException("Could not determine the controll of Gandalf after he entered play");
                }

                var enemies = GetEnemiesInPlay(game);

                var builder =
                    new ChoiceBuilder(string.Format("Choose which effect you want to trigger on '{0}' after he enters play", CardSource.Title), game, controller)
                    .Question(string.Format("{0}, which effect do you want to trigger on '{1}'?", controller.Name, CardSource.Title))
                    .Answer("Draw 3 cards", 1, (source, handle, item) => DrawThreeCards(game, handle, controller));

                if (enemies.Count() > 0)
                {
                    builder.Answer("Deal 4 damage to 1 enemy in play", 2)
                    .Question("Which enemy do you want to deal 4 damage to?")
                    .LastAnswers(enemies, (item) => string.Format("'{0}' ({1} damage of {2} hit points)", item.Title, item.Damage, item.Card.PrintedHitPoints), (source, handle, enemy) => DealFourDamageToEnemyInPlay(game, handle, controller, enemy));
                }

                builder.LastAnswer("Reduce your threat by 5", 3, (source, handle, item) => ReduceYourThreatByFive(game, handle, controller));

                var choice = builder.ToChoice();

                return(new EffectHandle(this, choice));
            }
示例#2
0
            public override IEffectHandle GetHandle(IGame game)
            {
                var enemyAttack = game.CurrentPhase.GetEnemyAttacks().Where(x => x.ShadowCards.Any(y => y.Card.Id == CardSource.Id)).FirstOrDefault();

                if (enemyAttack == null)
                {
                    return(base.GetHandle(game));
                }

                var player = enemyAttack.DefendingPlayer;

                if (enemyAttack.IsUndefended)
                {
                    var undefendedChoiceBuilder =
                        new ChoiceBuilder("Defending player must discard all attachments they control", game, player)
                        .Question(string.Format("{0} must discard all attachments they control", player))
                        .Answer("Yes", player, (source, handle, item) => DiscardAllAttachmentsControlledByDefendingPlayer(source, handle, item));

                    return(new EffectHandle(this, undefendedChoiceBuilder.ToChoice()));
                }

                var builder =
                    new ChoiceBuilder("Choose and discard 1 attachment from defending character", game, player)
                    .Question("Which defending character must discard an attachment?");

                var attachedDefenders = 0;

                foreach (var defender in enemyAttack.Defenders.OfType <IAttachmentHostInPlay>())
                {
                    var controller = game.GetController(defender.Card.Id);
                    if (controller == null)
                    {
                        continue;
                    }

                    var attachments = defender.Attachments.OfType <IAttachableInPlay>().Where(x => (x.Card is IObjectiveCard || x.Card is IPlayerCard) && (x.AttachedTo != null)).ToList();

                    if (attachments.Count == 0)
                    {
                        continue;
                    }

                    attachedDefenders++;

                    builder.Answer(string.Format("{0} (controlled by {1}", defender.Title, controller.Name), defender)
                    .Question(string.Format("Which attachment will be discarded from '{0}'?", defender.Title))
                    .Answers(attachments, item => item.Title, (source, handle, attachment) => DiscardOneAttachmentFromDefendingCharacter(game, handle, player, attachment));
                }

                if (attachedDefenders == 0)
                {
                    return(base.GetHandle(game));
                }

                return(new EffectHandle(this, builder.ToChoice()));
            }
        public override IEffectHandle GetHandle(IGame game)
        {
            var playableCards   = GetPlayableCardsInHand(game);
            var playableEffects = GetPlayableEffects(game);

            var builder =
                new ChoiceBuilder <IGame>(string.Format("{0} can choose to take an action during the {1} step of the {2} phase", player.Name, game.CurrentPhase.StepName, game.CurrentPhase.Name), game, player);

            if (playableCards.Count == 0 && playableEffects.Count == 0)
            {
                builder.Question(string.Format("{0}, there are no actions that you can take right now", player.Name))
                .LastAnswer("Ok, I will pass on taking actions right now", false, (source, handle, number) => PassOnTakingAnAction(source, handle));
            }
            else
            {
                builder.Question(string.Format("{0}, do you want to take an action?", player.Name));

                if (playableCards.Count > 0)
                {
                    builder.Answer <uint>("Yes, I would like to play a card from my hand", 1)
                    .Question("Which card would you like to play from your hand?")
                    .LastAnswers(playableCards, (item) => item.Title, (source, handle, costlyCard) => PlayCardFromHand(game, handle, costlyCard));
                }

                if (playableEffects.Count > 0)
                {
                    builder.Answer <uint>("Yes, I would like to trigger an effect on a card I control", 2)
                    .Question("Which effect would you like to trigger?")
                    .LastAnswers(playableEffects, (item) => item.ToString(), (source, handle, cardEffect) => TriggerEffect(source, handle, cardEffect));
                }

                builder.LastAnswer("No, I will pass on taking an action right now", false, (source, handle, number) => PassOnTakingAnAction(source, handle));
            }

            return(new EffectHandle(this, builder.ToChoice())); //new ChoosePlayerAction(game, player));
        }
示例#4
0
            public override IEffectHandle GetHandle(IGame game)
            {
                var mostThreateningPlayers = game.Players.Where(x => x.CurrentThreat == game.Players.Max(y => y.CurrentThreat)).ToList();

                var attachable = CardSource as IAttachableCard;

                if (mostThreateningPlayers.Count == 0)
                {
                    return new EffectHandle(this);
                }
                else if (mostThreateningPlayers.Count == 1)
                {
                    var player = mostThreateningPlayers.First();

                    var builder =
                        new ChoiceBuilder(string.Format("{0} has the highest threat and must choose a hero to attach '{0}' to", player.Name, CardSource.Title), game, player)
                            .Question(string.Format("{0}, which hero do you want to attach '{1}' to?", player.Name, CardSource.Title))
                                .LastAnswers(GetAttachableHeros(game, player, attachable), item => item.Title, (source, handle, hero) => AttachCaughtInAWebToHero(game, handle, player, attachable, hero));

                    return new EffectHandle(this, builder.ToChoice());
                }
                else
                {
                    var builder =
                        new ChoiceBuilder(string.Format("Multiple players are tied for the highest threat, The first player, {0}, must choose which of these players will attach '{1}' to one of their heroes.", game.FirstPlayer.Name, CardSource.Title), game, game.FirstPlayer)
                            .Question(string.Format("Which player will attach '{0}' to one of their heroes?", CardSource.Title));

                    foreach (var player in mostThreateningPlayers)
                    {
                        builder.Answer(player.Name, player)
                            .Question(string.Format("{0}, which hero do you want to attach '{1}' to?", player.Name, CardSource.Title))
                                .LastAnswers(GetAttachableHeros(game, player, attachable), item => item.Title, (source, handle, hero) => AttachCaughtInAWebToHero(game, handle, player, attachable, hero));
                    }

                    return new EffectHandle(this, builder.ToChoice());
                }
            }
示例#5
0
            public override IEffectHandle GetHandle(IGame game)
            {
                var mostThreateningPlayers = game.Players.Where(x => x.CurrentThreat == game.Players.Max(y => y.CurrentThreat)).ToList();

                var attachable = CardSource as IAttachableCard;

                if (mostThreateningPlayers.Count == 0)
                {
                    return(new EffectHandle(this));
                }
                else if (mostThreateningPlayers.Count == 1)
                {
                    var player = mostThreateningPlayers.First();

                    var builder =
                        new ChoiceBuilder(string.Format("{0} has the highest threat and must choose a hero to attach '{0}' to", player.Name, CardSource.Title), game, player)
                        .Question(string.Format("{0}, which hero do you want to attach '{1}' to?", player.Name, CardSource.Title))
                        .LastAnswers(GetAttachableHeros(game, player, attachable), item => item.Title, (source, handle, hero) => AttachCaughtInAWebToHero(game, handle, player, attachable, hero));

                    return(new EffectHandle(this, builder.ToChoice()));
                }
                else
                {
                    var builder =
                        new ChoiceBuilder(string.Format("Multiple players are tied for the highest threat, The first player, {0}, must choose which of these players will attach '{1}' to one of their heroes.", game.FirstPlayer.Name, CardSource.Title), game, game.FirstPlayer)
                        .Question(string.Format("Which player will attach '{0}' to one of their heroes?", CardSource.Title));

                    foreach (var player in mostThreateningPlayers)
                    {
                        builder.Answer(player.Name, player)
                        .Question(string.Format("{0}, which hero do you want to attach '{1}' to?", player.Name, CardSource.Title))
                        .LastAnswers(GetAttachableHeros(game, player, attachable), item => item.Title, (source, handle, hero) => AttachCaughtInAWebToHero(game, handle, player, attachable, hero));
                    }

                    return(new EffectHandle(this, builder.ToChoice()));
                }
            }
示例#6
0
        public override IEffectHandle GetHandle(IGame game)
        {
            var hosts       = GetAttachmentHosts(game);
            var characters  = GetCharactersWithResourceMatch();
            var description = attachmentCard != null ? "attachment card" : "treasure card";
            var sum         = characters.Sum(x => x.Resources);

            var builder =
                new ChoiceBuilder(GetChoiceText(), game, player);

            if (characters.Count == 0)
            {
                builder.Question(string.Format("You do not have any characters with a resource match to pay for '{0}'", attachableCard.Title))
                .Answer(string.Format("Ok, cancel playing this {0} from my hand", description), false, (source, handle, item) => CancelPayingCost(source, handle, player));
            }
            else if (hosts.Count == 0)
            {
                builder.Question(string.Format("There are no valid targets to which you can attach '{0}'", attachableCard.Title))
                .Answer(string.Format("Ok, cancel playing this {0} from my hand", description), false, (source, handle, item) => CancelPayingCost(source, handle, player));
            }
            else if (isVariableCost)
            {
                if (characters.Count == 1)
                {
                    var first   = characters.First();
                    var amounts = new List <byte>();
                    for (byte i = 1; i <= first.Resources; i++)
                    {
                        amounts.Add(i);
                    }

                    builder.Question(string.Format("'{0}' has a resource match, and this {1} has a variable cost. How many resources do you want to spend from their resource pool?", first.Title, description))
                    .Answers(amounts, (item) => item == 1 ? "1 resource" : string.Format("{0} resources", item), (source, handle, number) => PayResourcesFromCharacter(source, handle, first, player, number))
                    .LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                }
                else
                {
                    builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                    foreach (var host in hosts)
                    {
                        builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                        builder.Question(string.Format("This {0} has a variable cost. Do you want to pay this cost?", description))
                        .Answer("Yes, pay this cost", true);

                        foreach (var character in characters)
                        {
                            var amounts = new List <byte>();
                            for (byte i = 1; i <= character.Resources; i++)
                            {
                                amounts.Add(i);
                            }

                            builder.Question(string.Format("'{0}' has a resource match, and this {1} has a variable cost. How many resources do you want to spend from their resource pool?", character.Title, description))
                            .LastAnswers(amounts, (item) => item == 1 ? "1 resource" : string.Format("{0} resources", item), (source, handle, number) => PayResourcesFromCharacter(source, handle, character, player, number));
                        }

                        builder.LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                    }

                    builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
                }
            }
            else if (numberOfResources == 0)
            {
                var character = characters.First();

                builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                foreach (var host in hosts)
                {
                    builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                    builder.Question("This card does not have any cost. Do you want to play it?")
                    .Answer("Yes, I want to play this card", true, (source, handle, item) => PayResourcesFromCharacter(game, handle, character, player, 0))
                    .LastAnswer("No, I do not want to play this card", false, (source, handle, item) => CancelPayingCost(game, handle, player));
                }

                builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
            }
            else if (sum < numberOfResources)
            {
                builder.Question("You do not have characters with enough resources available to pay this cost")
                .LastAnswer("Ok, cancel this payment", false, (source, handle, item) => UnableToPayCost(source, handle, player));
            }
            else if (characters.Count == 1)
            {
                var first = characters.First();
                if (first.Resources < numberOfResources)
                {
                    builder.Question(string.Format("'{0}' has a resource match but does not have enough resources to pay this cost", first.Title))
                    .LastAnswer("Ok, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                }
                else
                {
                    builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                    foreach (var host in hosts)
                    {
                        builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                        var paymentText = numberOfResources == 1 ? "1 resource" : string.Format("{0} resources", numberOfResources);

                        builder.Question(string.Format("'{0}' has a resource match, do you want to pay {1} from their resource pool?", first.Title, paymentText))
                        .Answer("Yes, make this payment", first, (source, handle, character) => PayResourcesFromCharacter(source, handle, character, player, numberOfResources))
                        .LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                    }

                    builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
                }
            }
            else
            {
                if (numberOfResources == 1)
                {
                    builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                    foreach (var host in hosts)
                    {
                        builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                        builder.Question(string.Format("Multiple characters have a resource match, and this {0} costs 1 resource. Which character do you want to use to pay this cost?", description))
                        .Answers(characters, (item) => item.Title, (source, handle, character) => PayResourcesFromCharacter(source, handle, character, player, numberOfResources))
                        .LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                    }

                    builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
                }
                else
                {
                    if (sum == numberOfResources)
                    {
                        var paymentText           = GetPaymentText(characters);
                        var charactersAndPayments = new List <Tuple <ICharacterInPlay, byte> >();

                        foreach (var character in characters)
                        {
                            charactersAndPayments.Add(new Tuple <ICharacterInPlay, byte>(character, character.Resources));
                        }

                        builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                        foreach (var host in hosts)
                        {
                            builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                            builder.Question("You have just enough resources on your character to pay this cost. Do you want to pay all of the resources from matching characters?")
                            .Answer(string.Format("Yes, pay {0}", paymentText), characters, (source, handle, item) => PayResourcesFromCharacters(source, handle, charactersAndPayments, player))
                            .LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                        }

                        builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
                    }
                    else
                    {
                        var characterNames = GetCharacterNames(characters);

                        builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                        foreach (var host in hosts)
                        {
                            builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                            builder.Question("You have muliple characters with a resource match to pay this cost. Do you want to choose the resources to pay from matching characters?")
                            .Answer(string.Format("Yes, pay resources as follows:", characterNames), true);

                            AddPaymentAnswers(builder, characters, numberOfResources);

                            builder.LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                        }

                        builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
                    }
                }
            }

            return(new EffectHandle(this, builder.ToChoice()));
        }
        public override IEffectHandle GetHandle(IGame game)
        {
            var hosts = GetAttachmentHosts(game);
            var characters = GetCharactersWithResourceMatch();
            var description = attachmentCard != null ? "attachment card" : "treasure card";
            var sum = characters.Sum(x => x.Resources);

            var builder =
                new ChoiceBuilder(GetChoiceText(), game, player);

            if (characters.Count == 0)
            {
                builder.Question(string.Format("You do not have any characters with a resource match to pay for '{0}'", attachableCard.Title))
                    .Answer(string.Format("Ok, cancel playing this {0} from my hand", description), false, (source, handle, item) => CancelPayingCost(source, handle, player));
            }
            else if (hosts.Count == 0)
            {
                builder.Question(string.Format("There are no valid targets to which you can attach '{0}'", attachableCard.Title))
                    .Answer(string.Format("Ok, cancel playing this {0} from my hand", description), false, (source, handle, item) => CancelPayingCost(source, handle, player));
            }
            else if (isVariableCost)
            {
                if (characters.Count == 1)
                {
                    var first = characters.First();
                    var amounts = new List<byte>();
                    for (byte i = 1; i <= first.Resources; i++)
                    {
                        amounts.Add(i);
                    }

                    builder.Question(string.Format("'{0}' has a resource match, and this {1} has a variable cost. How many resources do you want to spend from their resource pool?", first.Title, description))
                        .Answers(amounts, (item) => item == 1 ? "1 resource" : string.Format("{0} resources", item), (source, handle, number) => PayResourcesFromCharacter(source, handle, first, player, number))
                        .LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                }
                else
                {
                    builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                    foreach (var host in hosts)
                    {
                        builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                        builder.Question(string.Format("This {0} has a variable cost. Do you want to pay this cost?", description))
                            .Answer("Yes, pay this cost", true);

                        foreach (var character in characters)
                        {
                            var amounts = new List<byte>();
                            for (byte i = 1; i <= character.Resources; i++)
                            {
                                amounts.Add(i);
                            }

                            builder.Question(string.Format("'{0}' has a resource match, and this {1} has a variable cost. How many resources do you want to spend from their resource pool?", character.Title, description))
                                .LastAnswers(amounts, (item) => item == 1 ? "1 resource" : string.Format("{0} resources", item), (source, handle, number) => PayResourcesFromCharacter(source, handle, character, player, number));

                        }

                        builder.LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                    }

                    builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
                }
            }
            else if (numberOfResources == 0)
            {
                var character = characters.First();

                builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                foreach (var host in hosts)
                {
                    builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                    builder.Question("This card does not have any cost. Do you want to play it?")
                        .Answer("Yes, I want to play this card", true, (source, handle, item) => PayResourcesFromCharacter(game, handle, character, player, 0))
                        .LastAnswer("No, I do not want to play this card", false, (source, handle, item) => CancelPayingCost(game, handle, player));
                }

                builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
            }
            else if (sum < numberOfResources)
            {
                builder.Question("You do not have characters with enough resources available to pay this cost")
                    .LastAnswer("Ok, cancel this payment", false, (source, handle, item) => UnableToPayCost(source, handle, player));
            }
            else if (characters.Count == 1)
            {
                var first = characters.First();
                if (first.Resources < numberOfResources)
                {
                    builder.Question(string.Format("'{0}' has a resource match but does not have enough resources to pay this cost", first.Title))
                        .LastAnswer("Ok, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                }
                else
                {
                    builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                    foreach (var host in hosts)
                    {
                        builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                        var paymentText = numberOfResources == 1 ? "1 resource" : string.Format("{0} resources", numberOfResources);

                        builder.Question(string.Format("'{0}' has a resource match, do you want to pay {1} from their resource pool?", first.Title, paymentText))
                            .Answer("Yes, make this payment", first, (source, handle, character) => PayResourcesFromCharacter(source, handle, character, player, numberOfResources))
                            .LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                    }

                    builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
                }
            }
            else
            {
                if (numberOfResources == 1)
                {
                    builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                    foreach (var host in hosts)
                    {
                        builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                        builder.Question(string.Format("Multiple characters have a resource match, and this {0} costs 1 resource. Which character do you want to use to pay this cost?", description))
                            .Answers(characters, (item) => item.Title, (source, handle, character) => PayResourcesFromCharacter(source, handle, character, player, numberOfResources))
                            .LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                    }

                    builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
                }
                else
                {
                    if (sum == numberOfResources)
                    {
                        var paymentText = GetPaymentText(characters);
                        var charactersAndPayments = new List<Tuple<ICharacterInPlay, byte>>();

                        foreach (var character in characters)
                        {
                            charactersAndPayments.Add(new Tuple<ICharacterInPlay, byte>(character, character.Resources));
                        }

                        builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                        foreach (var host in hosts)
                        {
                            builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                            builder.Question("You have just enough resources on your character to pay this cost. Do you want to pay all of the resources from matching characters?")
                                .Answer(string.Format("Yes, pay {0}", paymentText), characters, (source, handle, item) => PayResourcesFromCharacters(source, handle, charactersAndPayments, player))
                                .LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                        }

                        builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
                    }
                    else
                    {
                        var characterNames = GetCharacterNames(characters);

                        builder.Question(string.Format("Which card do you want to attach '{0}' to?", attachableCard.Title));

                        foreach (var host in hosts)
                        {
                            builder.Answer(host.Title, host, (source, handle, item) => handle.SetTarget(item));

                            builder.Question("You have muliple characters with a resource match to pay this cost. Do you want to choose the resources to pay from matching characters?")
                                .Answer(string.Format("Yes, pay resources as follows:", characterNames), true);

                            AddPaymentAnswers(builder, characters, numberOfResources);

                            builder.LastAnswer("No, cancel this payment", false, (source, handle, item) => CancelPayingCost(source, handle, player));
                        }

                        builder.LastAnswer(string.Format("No, I do not want to attach '{0}' to any of these cards", attachableCard.Title), false, (source, handle, item) => CancelPayingCost(source, handle, player));
                    }
                }
            }

            return new EffectHandle(this, builder.ToChoice());
        }
        public override IEffectHandle GetHandle(IGame game)
        {
            var playableCards = GetPlayableCardsInHand(game);
            var playableEffects = GetPlayableEffects(game);

            var builder =
                    new ChoiceBuilder<IGame>(string.Format("{0} can choose to take an action during the {1} step of the {2} phase", player.Name, game.CurrentPhase.StepName, game.CurrentPhase.Name), game, player);

            if (playableCards.Count == 0 && playableEffects.Count == 0)
            {
                builder.Question(string.Format("{0}, there are no actions that you can take right now", player.Name))
                        .LastAnswer("Ok, I will pass on taking actions right now", false, (source, handle, number) => PassOnTakingAnAction(source, handle));
            }
            else
            {
                builder.Question(string.Format("{0}, do you want to take an action?", player.Name));

                if (playableCards.Count > 0)
                {
                    builder.Answer<uint>("Yes, I would like to play a card from my hand", 1)
                        .Question("Which card would you like to play from your hand?")
                            .LastAnswers(playableCards, (item) => item.Title, (source, handle, costlyCard) => PlayCardFromHand(game, handle, costlyCard));
                }

                if (playableEffects.Count > 0)
                {
                    builder.Answer<uint>("Yes, I would like to trigger an effect on a card I control", 2)
                        .Question("Which effect would you like to trigger?")
                            .LastAnswers(playableEffects, (item) => item.ToString(), (source, handle, cardEffect) => TriggerEffect(source, handle, cardEffect));
                }

                builder.LastAnswer("No, I will pass on taking an action right now", false, (source, handle, number) => PassOnTakingAnAction(source, handle));
            }

            return new EffectHandle(this, builder.ToChoice()); //new ChoosePlayerAction(game, player));
        }
            public override IEffectHandle GetHandle(IGame game)
            {
                var enemyAttack = game.CurrentPhase.GetEnemyAttacks().Where(x => x.ShadowCards.Any(y => y.Card.Id == CardSource.Id)).FirstOrDefault();
                if (enemyAttack == null)
                    return base.GetHandle(game);

                var player = enemyAttack.DefendingPlayer;

                if (enemyAttack.IsUndefended)
                {
                    var undefendedChoiceBuilder =
                        new ChoiceBuilder("Defending player must discard all attachments they control", game, player)
                            .Question(string.Format("{0} must discard all attachments they control", player))
                                .Answer("Yes", player, (source, handle, item) => DiscardAllAttachmentsControlledByDefendingPlayer(source, handle, item));

                    return new EffectHandle(this, undefendedChoiceBuilder.ToChoice());
                }

                var builder =
                    new ChoiceBuilder("Choose and discard 1 attachment from defending character", game, player)
                        .Question("Which defending character must discard an attachment?");

                var attachedDefenders = 0;
                foreach (var defender in enemyAttack.Defenders.OfType<IAttachmentHostInPlay>())
                {
                    var controller = game.GetController(defender.Card.Id);
                    if (controller == null)
                        continue;

                    var attachments = defender.Attachments.OfType<IAttachableInPlay>().Where(x => (x.Card is IObjectiveCard || x.Card is IPlayerCard) && (x.AttachedTo != null)).ToList();

                    if (attachments.Count == 0)
                        continue;

                    attachedDefenders++;

                    builder.Answer(string.Format("{0} (controlled by {1}", defender.Title, controller.Name), defender)
                        .Question(string.Format("Which attachment will be discarded from '{0}'?", defender.Title))
                            .Answers(attachments, item => item.Title, (source, handle, attachment) => DiscardOneAttachmentFromDefendingCharacter(game, handle, player, attachment));
                }

                if (attachedDefenders == 0)
                    return base.GetHandle(game);

                return new EffectHandle(this, builder.ToChoice());
            }
示例#10
0
            public override IEffectHandle GetHandle(IGame game)
            {
                var controller = game.GetController(CardSource.Id);
                if (controller == null)
                    throw new InvalidOperationException("Could not determine the controll of Gandalf after he entered play");

                var enemies = GetEnemiesInPlay(game);

                var builder =
                    new ChoiceBuilder(string.Format("Choose which effect you want to trigger on '{0}' after he enters play", CardSource.Title), game, controller)
                        .Question(string.Format("{0}, which effect do you want to trigger on '{1}'?", controller.Name, CardSource.Title))
                            .Answer("Draw 3 cards", 1, (source, handle, item) => DrawThreeCards(game, handle, controller));

                if (enemies.Count() > 0)
                {
                    builder.Answer("Deal 4 damage to 1 enemy in play", 2)
                        .Question("Which enemy do you want to deal 4 damage to?")
                            .LastAnswers(enemies, (item) => string.Format("'{0}' ({1} damage of {2} hit points)", item.Title, item.Damage, item.Card.PrintedHitPoints), (source, handle, enemy) => DealFourDamageToEnemyInPlay(game, handle, controller, enemy));

                }

                builder.LastAnswer("Reduce your threat by 5", 3, (source, handle, item) => ReduceYourThreatByFive(game, handle, controller));

                var choice = builder.ToChoice();

                return new EffectHandle(this, choice);
            }