public override IEffectHandle GetHandle(IGame game) { var limit = new Limit(PlayerScope.Controller, TimeScope.Round, 1); var controller = game.GetController(CardSource.Id); if (controller == null) return base.GetHandle(game); var exhaustable = controller.CardsInPlay.OfType<IExhaustableInPlay>().Where(x => x.BaseCard.Id == source.Id).FirstOrDefault(); if (exhaustable == null || exhaustable.IsExhausted) return base.GetHandle(game); var builder = new ChoiceBuilder(string.Format("Exhaust '{0}' to have a plyer draw 2 cards", CardSource.Title), game, controller); if (game.Players.Count() == 1) { builder.Question(string.Format("You are the only player, exhaust '{0}' to draw 2 cards?", CardSource.Title)) .Answer(string.Format("Yes, I want to exhaust '{0}' to draw 2 cards", CardSource.Title), controller, (source, handle, player) => ExhaustAndPlayerDrawsTwoCards(source, handle, controller, exhaustable, player)) .LastAnswer("No, I do not want to exhaust '{0}' to draw 2 cards", false, (source, handle, item) => CancelEffect(source, handle, controller)); } else { builder.Question(string.Format("{0}, do you want to exhaust '{1}' to have a player draw 2 cards?", controller.Name)) .Answer(string.Format("Yes, I will exhaust '{0}' to have a player draw 2 cards", CardSource.Title), true) .Question("Which player should draw 2 cards?") .LastAnswers(game.Players.ToList(), item => item.Name, (source, handle, player) => ExhaustAndPlayerDrawsTwoCards(game, handle, controller, exhaustable, player)) .LastAnswer(string.Format("No, I do not want to exhaust '{0}' to have a player draw 2 cards", CardSource.Title), false, (source, handle, item) => CancelEffect(source, handle, controller)); } var choice = builder.ToChoice(); return new EffectHandle(this, choice, limit); }
public override IEffectHandle GetHandle(IGame game) { var questPhase = game.CurrentPhase as IQuestPhase; if (questPhase == null) { return(new EffectHandle(this)); } var builder = new ChoiceBuilder("Each player must choose 1 character currently commited to the quest", game, game.FirstPlayer); foreach (var player in game.Players) { var characters = questPhase.GetCharactersCommitedToTheQuest(player.StateId); var count = characters.Count(); if (count == 0) { continue; } else if (count == 1) { var first = characters.First(); builder.Question(string.Format("{0}, '{1}' is your only character committed to the quest. You must remove them from the quest", player.Name, first.Title)) .Answer(string.Format("Ok, remove '{0}' from the quest", first.Title), first, (source, handle, character) => RemoveCharacterFromQuest(source, handle, character, player, questPhase)); } else { builder.Question(string.Format("{0}, which character do you want to remove from the quest?", player.Name)) .Answers(characters, (item) => string.Format("{0} ({1} willpower)", item.Title, item.Willpower), (source, handle, character) => RemoveCharacterFromQuest(source, handle, character, player, questPhase)); } } return(new EffectHandle(this, builder.ToChoice())); }
public override IEffectHandle GetHandle(IGame game) { IChoiceBuilder builder = new ChoiceBuilder("Quest Resolution", game, game.FirstPlayer); var check = Math.Abs(outcome.TotalWillpower - outcome.TotalThreat); byte difference = check <= 255 ? (byte)check : (byte)255; if (outcome.IsQuestSuccessful && difference > 0) { var description = GetProgressDescription(difference); builder.Question("The total willpower of committed characters is greater than the total threat of all cards in the staging area.") .LastAnswer(string.Format("Ok, questing was successful. {0} will be added to the current quest.", description), difference, (source, handle, item) => ResolveSuccessfulQuest(source, handle, item)); } else if (outcome.IsQuestFailed && difference > 0) { builder.Question("The total willpower of committed characters is less than the total threat of all cards in the staging area.") .LastAnswer(string.Format("Ok, questing was unsuccessful. Each player's threat will be raised by {0}.", difference), difference, (source, handle, item) => ResolveFailedQuest(source, handle, item)); } else { builder.Question("The total willpower of committed characters is equal to the total threat of all cards in the staging area.") .LastAnswer("Ok, questing was neither successful nor a failure", difference, (source, handle, item) => ResolveTiedQuest(source, handle)); } return(new EffectHandle(this, builder.ToChoice())); }
public override IEffectHandle GetHandle(IGame game) { var questPhase = game.CurrentPhase as IQuestPhase; if (questPhase == null) return new EffectHandle(this); var builder = new ChoiceBuilder("Each player must choose 1 character currently commited to the quest", game, game.FirstPlayer); foreach (var player in game.Players) { var characters = questPhase.GetCharactersCommitedToTheQuest(player.StateId); var count = characters.Count(); if (count == 0) continue; else if (count == 1) { var first = characters.First(); builder.Question(string.Format("{0}, '{1}' is your only character committed to the quest. You must remove them from the quest", player.Name, first.Title)) .Answer(string.Format("Ok, remove '{0}' from the quest", first.Title), first, (source, handle, character) => RemoveCharacterFromQuest(source, handle, character, player, questPhase)); } else { builder.Question(string.Format("{0}, which character do you want to remove from the quest?", player.Name)) .Answers(characters, (item) => string.Format("{0} ({1} willpower)", item.Title, item.Willpower), (source, handle, character) => RemoveCharacterFromQuest(source, handle, character, player, questPhase)); } } return new EffectHandle(this, builder.ToChoice()); }
public override IEffectHandle GetHandle(IGame game) { var limit = new Limit(PlayerScope.AnyPlayer, TimeScope.Round, 1); var handSize = game.ActivePlayer.Hand.Cards.Count(); if (handSize == 0) { return(base.GetHandle(game)); } else { var builder = new ChoiceBuilder(string.Format("The active player may discard a card from their hand to give '{0}' +1 Willpower until the end of the phase", CardSource.Title), game, game.ActivePlayer); if (handSize == 1) { builder.Question("You only have 1 card in your hand, do you want to discard it?") .Answer("Yes, I will discard it", game.ActivePlayer.Hand.Cards.First(), (source, handle, card) => PlayerDiscardsOneCard(source, handle, game.ActivePlayer, card)) .LastAnswer("No, I will not discard my last card from my hand", false, (source, handle, item) => CancelDiscard(source, handle, game.ActivePlayer)); } else { builder.Question(string.Format("{0}, do you want to discard a card from your hand?", game.ActivePlayer.Name)) .Answer("Yes, I will discard a card from my hand", true) .Question("Which card will you discard?") .LastAnswers(game.ActivePlayer.Hand.Cards.ToList(), (item) => item.Title, (source, handle, card) => PlayerDiscardsOneCard(source, handle, game.ActivePlayer, card)) .LastAnswer("No, I will not discard a card from my hand", false, (source, handle, item) => CancelDiscard(source, handle, game.ActivePlayer)); } return(new EffectHandle(this, builder.ToChoice())); } }
public override IEffectHandle GetHandle(IGame game) { var builder = new ChoiceBuilder(GetText(player), game, player); var characters = GetReadyCharacters(); if (characters.Count == 0) { builder.Question("You do not have any ready characters available to commit to the quest") .LastAnswer("Ok, I will not commit any characters to the quest", false, (source, handle, item) => DoNotCommitAnyCharactersToTheQuest(handle)); } else { var description = characters.Count > 1 ? string.Format("{0} characters", characters.Count) : "1 character"; var threat = game.StagingArea.CardsInStagingArea.OfType <IThreateningInPlay>().Sum(x => x.Threat); builder.Question(string.Format("You have {0} available to commit to the quest and there is currently {1} threat in the staging area.\r\nDo you want to commit any characters to the quest?", description, threat)) .Answer("Yes, I want to commit characters to the quest", true) .Question("Which characters do you want to commit to the quest?", 0, (uint)characters.Count) .LastAnswers(characters, (item) => string.Format("{0} ({1} willpower)", item.Title, item.Willpower), (source, handle, character) => CommitCharacterToTheQuest(source, handle, character)) .LastAnswer("No, I do not want to commit characters to the quest", false, (source, handle, item) => DoNotCommitAnyCharactersToTheQuest(handle)); } return(new EffectHandle(this, builder.ToChoice())); }
public override IEffectHandle GetHandle(IGame game) { IChoiceBuilder builder = new ChoiceBuilder("Quest Resolution", game, game.FirstPlayer); var check = Math.Abs(outcome.TotalWillpower - outcome.TotalThreat); byte difference = check <= 255 ? (byte)check : (byte)255; if (outcome.IsQuestSuccessful && difference > 0) { var description = GetProgressDescription(difference); builder.Question("The total willpower of committed characters is greater than the total threat of all cards in the staging area.") .LastAnswer(string.Format("Ok, questing was successful. {0} will be added to the current quest.", description), difference, (source, handle, item) => ResolveSuccessfulQuest(source, handle, item)); } else if (outcome.IsQuestFailed && difference > 0) { builder.Question("The total willpower of committed characters is less than the total threat of all cards in the staging area.") .LastAnswer(string.Format("Ok, questing was unsuccessful. Each player's threat will be raised by {0}.", difference), difference, (source, handle, item) => ResolveFailedQuest(source, handle, item)); } else { builder.Question("The total willpower of committed characters is equal to the total threat of all cards in the staging area.") .LastAnswer("Ok, questing was neither successful nor a failure", difference, (source, handle, item) => ResolveTiedQuest(source, handle)); } return new EffectHandle(this, builder.ToChoice()); }
public override IEffectHandle GetHandle(IGame game) { var builder = new ChoiceBuilder(GetText(player), game, player); var characters = GetReadyCharacters(); if (characters.Count == 0) { builder.Question("You do not have any ready characters available to commit to the quest") .LastAnswer("Ok, I will not commit any characters to the quest", false, (source, handle, item) => DoNotCommitAnyCharactersToTheQuest(handle)); } else { var description = characters.Count > 1 ? string.Format("{0} characters", characters.Count) : "1 character"; var threat = game.StagingArea.CardsInStagingArea.OfType<IThreateningInPlay>().Sum(x => x.Threat); builder.Question(string.Format("You have {0} available to commit to the quest and there is currently {1} threat in the staging area.\r\nDo you want to commit any characters to the quest?", description, threat)) .Answer("Yes, I want to commit characters to the quest", true) .Question("Which characters do you want to commit to the quest?", 0, (uint)characters.Count) .LastAnswers(characters, (item) => string.Format("{0} ({1} willpower)", item.Title, item.Willpower), (source, handle, character) => CommitCharacterToTheQuest(source, handle, character)) .LastAnswer("No, I do not want to commit characters to the quest", false, (source, handle, item) => DoNotCommitAnyCharactersToTheQuest(handle)); } return new EffectHandle(this, builder.ToChoice()); }
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 limit = new Limit(PlayerScope.AnyPlayer, TimeScope.Round, 1); var handSize = game.ActivePlayer.Hand.Cards.Count(); if (handSize == 0) { return base.GetHandle(game); } else { var builder = new ChoiceBuilder(string.Format("The active player may discard a card from their hand to give '{0}' +1 Willpower until the end of the phase", CardSource.Title), game, game.ActivePlayer); if (handSize == 1) { builder.Question("You only have 1 card in your hand, do you want to discard it?") .Answer("Yes, I will discard it", game.ActivePlayer.Hand.Cards.First(), (source, handle, card) => PlayerDiscardsOneCard(source, handle, game.ActivePlayer, card)) .LastAnswer("No, I will not discard my last card from my hand", false, (source, handle, item) => CancelDiscard(source, handle, game.ActivePlayer)); } else { builder.Question(string.Format("{0}, do you want to discard a card from your hand?", game.ActivePlayer.Name)) .Answer("Yes, I will discard a card from my hand", true) .Question("Which card will you discard?") .LastAnswers(game.ActivePlayer.Hand.Cards.ToList(), (item) => item.Title, (source, handle, card) => PlayerDiscardsOneCard(source, handle, game.ActivePlayer, card)) .LastAnswer("No, I will not discard a card from my hand", false, (source, handle, item) => CancelDiscard(source, handle, game.ActivePlayer)); } return new EffectHandle(this, builder.ToChoice()); } }
public override IEffectHandle GetHandle(IGame game) { var availableCards = new Dictionary <Guid, IList <IPlayerCard> >(); foreach (var player in game.Players) { var topFive = player.Deck.GetFromTop(5).ToList(); availableCards.Add(player.StateId, topFive); } var builder = new ChoiceBuilder("Each player may search the top 5 cards of his deck for 1 card of their choice", game, game.FirstPlayer, true) .Question("Each play searches") .Answer("Yes", 1); foreach (var player in game.Players) { var cards = player.Deck.GetFromTop(5).ToList(); if (cards.Count == 0) { continue; } builder.Question(string.Format("{0}, which card would you like to add to your hand?", player.Name)) .Answers(cards, item => item.Title, (source, handle, card) => AddChosenCardToHand(game, handle, player, card)); } return(new EffectHandle(this, builder.ToChoice())); }
public override IEffectHandle GetHandle(IGame game) { var builder = new ChoiceBuilder <IGame>("The players determine a first player based on a majority group decision. If this proves impossible, determine a first player at random.", game, game.Players.First()); if (game.Players.Count() > 1) { builder.Question("Who will be first player?") .Answers(game.Players, (player) => player.Name, (source, handle, item) => ChooseFirstPlayer(handle, item)) .Answer("Determine a first player at random", game.Players.GetRandomItem(), (source, handle, item) => ChooseFirstPlayerRandomly(handle, item)); } else { var first = game.Players.First(); builder.Question(string.Format("{0} is the only player so there is no need to determine first player", first.Name)) .LastAnswer(string.Format("{0} is first player", first.Name), first, (source, handle, item) => ChooseFirstPlayer(handle, first)); } return(new EffectHandle(this, builder.ToChoice())); }
public override IEffectHandle GetHandle(IGame game) { var builder = new ChoiceBuilder<IGame>("The players determine a first player based on a majority group decision. If this proves impossible, determine a first player at random.", game, game.Players.First()); if (game.Players.Count() > 1) { builder.Question("Who will be first player?") .Answers(game.Players, (player) => player.Name, (source, handle, item) => ChooseFirstPlayer(handle, item)) .Answer("Determine a first player at random", game.Players.GetRandomItem(), (source, handle, item) => ChooseFirstPlayerRandomly(handle, item)); } else { var first = game.Players.First(); builder.Question(string.Format("{0} is the only player so there is no need to determine first player", first.Name)) .LastAnswer(string.Format("{0} is first player", first.Name), first, (source, handle, item) => ChooseFirstPlayer(handle, first)); } return new EffectHandle(this, builder.ToChoice()); }
public override IEffectHandle GetHandle(IGame game) { var limit = new Limit(PlayerScope.Controller, TimeScope.Round, 1); var controller = game.GetController(CardSource.Id); if (controller == null) { return(base.GetHandle(game)); } var exhaustable = controller.CardsInPlay.OfType <IExhaustableInPlay>().Where(x => x.BaseCard.Id == source.Id).FirstOrDefault(); if (exhaustable == null || exhaustable.IsExhausted) { return(base.GetHandle(game)); } var builder = new ChoiceBuilder(string.Format("Exhaust '{0}' to have a plyer draw 2 cards", CardSource.Title), game, controller); if (game.Players.Count() == 1) { builder.Question(string.Format("You are the only player, exhaust '{0}' to draw 2 cards?", CardSource.Title)) .Answer(string.Format("Yes, I want to exhaust '{0}' to draw 2 cards", CardSource.Title), controller, (source, handle, player) => ExhaustAndPlayerDrawsTwoCards(source, handle, controller, exhaustable, player)) .LastAnswer("No, I do not want to exhaust '{0}' to draw 2 cards", false, (source, handle, item) => CancelEffect(source, handle, controller)); } else { builder.Question(string.Format("{0}, do you want to exhaust '{1}' to have a player draw 2 cards?", controller.Name)) .Answer(string.Format("Yes, I will exhaust '{0}' to have a player draw 2 cards", CardSource.Title), true) .Question("Which player should draw 2 cards?") .LastAnswers(game.Players.ToList(), item => item.Name, (source, handle, player) => ExhaustAndPlayerDrawsTwoCards(game, handle, controller, exhaustable, player)) .LastAnswer(string.Format("No, I do not want to exhaust '{0}' to have a player draw 2 cards", CardSource.Title), false, (source, handle, item) => CancelEffect(source, handle, controller)); } var choice = builder.ToChoice(); return(new EffectHandle(this, choice, limit)); }
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 spiders = game.StagingArea.EncounterDeck.Cards.OfType<IEnemyCard>().Where(x => x.PrintedTraits.Contains(Trait.Spider)) .Concat(game.StagingArea.EncounterDeck.DiscardPile.OfType<IEnemyCard>().Where(x => x.PrintedTraits.Contains(Trait.Spider))).ToList(); if (spiders.Count == 0) return base.GetHandle(game); var builder = new ChoiceBuilder("Each player must search the encounter deck and discard pile for 1 Spider card of his choice", game, game.FirstPlayer) .Question("Each player must choose a Spider") .Answer("Yes", 1); foreach (var player in game.Players) { builder.Question(string.Format("{0}, which Spider card do you want to add to the staging area?", player.Name)) .Answers(spiders, (item) => GetSpiderDescription(game, item), (source, handle, spider) => AddSpiderToTheStagingArea(source, handle, spider)); } return new EffectHandle(this, builder.ToChoice()); }
public override IEffectHandle GetHandle(IGame game) { var spiders = game.StagingArea.EncounterDeck.Cards.OfType <IEnemyCard>().Where(x => x.PrintedTraits.Contains(Trait.Spider)) .Concat(game.StagingArea.EncounterDeck.DiscardPile.OfType <IEnemyCard>().Where(x => x.PrintedTraits.Contains(Trait.Spider))).ToList(); if (spiders.Count == 0) { return(base.GetHandle(game)); } var builder = new ChoiceBuilder("Each player must search the encounter deck and discard pile for 1 Spider card of his choice", game, game.FirstPlayer) .Question("Each player must choose a Spider") .Answer("Yes", 1); foreach (var player in game.Players) { builder.Question(string.Format("{0}, which Spider card do you want to add to the staging area?", player.Name)) .Answers(spiders, (item) => GetSpiderDescription(game, item), (source, handle, spider) => AddSpiderToTheStagingArea(source, handle, spider)); } 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 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 availableCards = new Dictionary<Guid, IList<IPlayerCard>>(); foreach (var player in game.Players) { var topFive = player.Deck.GetFromTop(5).ToList(); availableCards.Add(player.StateId, topFive); } var builder = new ChoiceBuilder("Each player may search the top 5 cards of his deck for 1 card of their choice", game, game.FirstPlayer, true) .Question("Each play searches") .Answer("Yes", 1); foreach (var player in game.Players) { var cards = player.Deck.GetFromTop(5).ToList(); if (cards.Count == 0) continue; builder.Question(string.Format("{0}, which card would you like to add to your hand?", player.Name)) .Answers(cards, item => item.Title, (source, handle, card) => AddChosenCardToHand(game, handle, player, card)); } return new EffectHandle(this, builder.ToChoice()); }