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)); }
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())); }
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 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 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()); }
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); }