public override void Resolve(TurnContext context, ICard source) { var deck = context.ActivePlayer.Deck; var revealZone = new RevealZone(context.ActivePlayer); while (deck.TopCard != null && MatchingActions(revealZone).Count() < 2) { deck.TopCard.MoveTo(revealZone); } revealZone.LogReveal(context.Game.Log); var actionsToPlay = MatchingActions(revealZone).ToList(); var discards = revealZone.Where(c => !actionsToPlay.Cast <ICard>().Contains(c)) .ToList(); foreach (var card in discards) { card.MoveTo(context.ActivePlayer.Discards); } var playUtil = new PlayCardUtility(context); if (actionsToPlay.AllSame(a => a.Name)) { playUtil.Play(actionsToPlay); } else { _activities.Add(CreateChooseActionActivity(context, revealZone, source)); } }
public override void Resolve(TurnContext context, ICard source) { var deck = context.ActivePlayer.Deck; var revealZone = new RevealZone(context.ActivePlayer); while (deck.TopCard != null && MatchingCards(revealZone).Count() < 2) { deck.TopCard.MoveTo(revealZone); } revealZone.LogReveal(context.Game.Log); var revealedTreasure = MatchingCards(revealZone).ToList(); var discards = revealZone.Where(c => !revealedTreasure.Cast <ICard>().Contains(c)).ToList(); foreach (var card in discards) { card.MoveTo(context.ActivePlayer.Discards); } foreach (var card in revealedTreasure) { card.MoveTo(context.ActivePlayer.Hand); } }
public void Play(TurnContext context) { var leftPlayer = context.Opponents.FirstOrDefault(); if (leftPlayer != null) { var revealZone = new RevealZone(leftPlayer); leftPlayer.Deck.MoveTop(2, revealZone); revealZone.LogReveal(context.Game.Log); foreach (var card in revealZone.WithDistinctTypes()) { if (card is IActionCard) { context.RemainingActions += 2; } if (card is ITreasureCard) { context.AvailableSpend += 2; } if (card is IVictoryCard) { context.DrawCards(2); } } revealZone.MoveAll(leftPlayer.Discards); } }
public override void Attack(Player victim, TurnContext context, ICard source) { var revealZone = new RevealZone(victim); victim.Deck.MoveTop(2, revealZone); revealZone.LogReveal(context.Game.Log); var revealedTreasures = revealZone.OfType <ITreasureCard>().WithDistinctTypes(); switch (revealedTreasures.Count()) { case 0: revealZone.MoveAll(victim.Discards); return; case 1: var trashedCard = TrashAndDiscard(context, revealZone, revealedTreasures); var gainChoiceActivity = Activities.GainOpponentsCardChoice(context, trashedCard, revealZone.Owner, source); _activities.Add(gainChoiceActivity); break; default: var chooseTreasureActivity = CreateChooseTreasureActivity(context, revealZone, source); _activities.Add(chooseTreasureActivity); break; } }
public override void Resolve(TurnContext context, ICard source) { var leftPlayer = context.Opponents.FirstOrDefault(); if (leftPlayer != null) { var revealZone = new RevealZone(context.ActivePlayer); context.ActivePlayer.Deck.MoveTop(5, revealZone); revealZone.LogReveal(context.Game.Log); if (revealZone.CardCount > 0) { var activity = CreateChooseCardActivity(context, revealZone, leftPlayer, source); _activities.Add(activity); } } }
public override void Resolve(TurnContext context, ICard source) { var revealZone = new RevealZone(context.ActivePlayer); context.ActivePlayer.Deck.MoveTop(4, revealZone); revealZone.LogReveal(context.Game.Log); revealZone.MoveWhere(c => c is Copper || c is Potion, context.ActivePlayer.Hand); if (revealZone.CardCount == 1) { context.ActivePlayer.Deck.MoveToTop(revealZone.Single()); } foreach (var activity in Activities.SelectMultipleRevealedCardsToPutOnTopOfDeck(context.Game.Log, context.ActivePlayer, revealZone, source)) { _activities.Add(activity); } }
public override void Attack(Player victim, TurnContext context, ICard source) { var revealZone = new RevealZone(victim); victim.Deck.MoveTop(3, revealZone); revealZone.LogReveal(context.Game.Log); revealZone.MoveWhere(c => c is IActionCard || c is ITreasureCard, victim.Discards); if (revealZone.CardCount == 1) { victim.Deck.MoveToTop(revealZone.Single()); } foreach (var activity in Activities.SelectMultipleRevealedCardsToPutOnTopOfDeck(context.Game.Log, victim, revealZone, source)) { _activities.Add(activity); } }
public static IActivity ChooseWhetherToMillTopCard(TurnContext context, Player choosingPlayer, Player targetPlayer, ICard source) { var revealZone = new RevealZone(targetPlayer); targetPlayer.Deck.TopCard.MoveTo(revealZone); revealZone.LogReveal(context.Game.Log); var otherPlayerMessage = string.Format("Put {0}'s card in the discard pile?", targetPlayer.Name); var selfMessage = "Put your own card in the discard pile?"; var activity = new ChooseBasedOnRevealedCardsActivity( context.Game.Log, choosingPlayer, revealZone, choosingPlayer == targetPlayer ? selfMessage : otherPlayerMessage, source, Choice.Yes, Choice.No ); activity.ActOnChoice = choice => { var card = revealZone.Single(); string actionDescription; if (choice == Choice.Yes) { actionDescription = "into the discard pile"; card.MoveTo(targetPlayer.Discards); } else { actionDescription = "back on top"; targetPlayer.Deck.MoveToTop(card); } var message = string.Format("{0} put {1}'s {2} {3}.", context.ActivePlayer, targetPlayer, card.Name, actionDescription); context.Game.Log.LogMessage(message); }; return(activity); }
public static IActivity ChooseWhetherToMillTopCard(TurnContext context, Player choosingPlayer, Player targetPlayer, ICard source) { var revealZone = new RevealZone(targetPlayer); targetPlayer.Deck.TopCard.MoveTo(revealZone); revealZone.LogReveal(context.Game.Log); var otherPlayerMessage = string.Format("Put {0}'s card in the discard pile?", targetPlayer.Name); var selfMessage = "Put your own card in the discard pile?"; var activity = new ChooseBasedOnRevealedCardsActivity( context.Game.Log, choosingPlayer, revealZone, choosingPlayer == targetPlayer ? selfMessage : otherPlayerMessage, source, Choice.Yes, Choice.No ); activity.ActOnChoice = choice => { var card = revealZone.Single(); string actionDescription; if (choice == Choice.Yes) { actionDescription = "into the discard pile"; card.MoveTo(targetPlayer.Discards); } else { actionDescription = "back on top"; targetPlayer.Deck.MoveToTop(card); } var message = string.Format("{0} put {1}'s {2} {3}.", context.ActivePlayer, targetPlayer, card.Name, actionDescription); context.Game.Log.LogMessage(message); }; return activity; }