/// <summary> /// Deals the specified players. /// </summary> /// <param name="players">The players.</param> /// <param name="cardsOnBoard">The cards on board.</param> public void Deal(IList<IParticipant> players, ICard[] cardsOnBoard) { this.Shuffle(); int toTakeFromDeckIndex = 0; // deal cards to players foreach (IParticipant player in players.Where(p => p.IsInGame)) { this.DealCardsToPlayers(player, ref toTakeFromDeckIndex); } // place cards on board Point boardCardsPosition = GlobalVariables.BoardCardsPlace; int positionCardChangeX = boardCardsPosition.X; for (int i = 0; i < 5; i++) { this.DealCardsOnBoard( cardsOnBoard, i, ref toTakeFromDeckIndex, boardCardsPosition, ref positionCardChangeX); } // turn the player cards up foreach (var player in players.Where(p => p.IsInGame && p is Player)) { player.Hand.CurrentCards[0].IsFacingUp = true; player.Hand.CurrentCards[1].IsFacingUp = true; } }
protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard) { IUiProxy ui = Game.CurrentGame.UiProxies[dest]; HuoGongCardChoiceVerifier v1 = new HuoGongCardChoiceVerifier(); ISkill s; List<Player> p; List<Card> cards; if (dest.IsDead) return; if (!ui.AskForCardUsage(new CardUsagePrompt("HuoGong", source), v1, out s, out cards, out p)) { Trace.TraceInformation("Player {0} Invalid answer", dest); cards = new List<Card>(); if (Game.CurrentGame.Decks[dest, DeckType.Hand].Count == 0) { Trace.TraceError("HuoGong Cannot Show Card! This should NOT have happened!"); return; } cards.Add(Game.CurrentGame.Decks[dest, DeckType.Hand][0]); } Trace.TraceInformation("Player {0} HuoGong showed {1}, ", dest.Id, cards[0].Suit); if (source.IsDead) return; ui = Game.CurrentGame.UiProxies[source]; HuoGongCardMatchVerifier v2 = new HuoGongCardMatchVerifier(cards[0].Suit); v2.Owner = source; if (ui.AskForCardUsage(new CardUsagePrompt("HuoGong2", dest, cards[0].Suit), v2, out s, out cards, out p)) { Game.CurrentGame.HandleCardDiscard(source, cards); Game.CurrentGame.DoDamage(source, dest, 1, DamageElement.Fire, card, readonlyCard); } else { Trace.TraceInformation("HuoGong aborted, failed to provide card"); } }
protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo) { DeckType wuguDeck = new DeckType("WuGu"); DeckType wuguFakeDeck = new DeckType("WuGuFake"); List<List<Card>> answer; if (!Game.CurrentGame.UiProxies[dest].AskForCardChoice(new CardChoicePrompt("WuGuFengDeng"), new List<DeckPlace>() { new DeckPlace(null, wuguFakeDeck) }, new List<string>() { "WuGu" }, new List<int>() { 1 }, new WuGuCardChoiceVerifier(FakeMapping), out answer, new AdditionalCardChoiceOptions() { IsWuGu = true })) { Trace.TraceInformation("Invalid answer for WuGu, choosing for you"); answer = new List<List<Card>>(); answer.Add(new List<Card>()); answer[0].Add(Game.CurrentGame.Decks[null, wuguDeck][0]); } else { if (!FakeMapping.ContainsKey(answer[0][0]) || FakeMapping[answer[0][0]] == null) { answer[0] = new List<Card>() { Game.CurrentGame.Decks[null, wuguDeck][0] }; } var theCard = answer[0][0]; answer[0] = new List<Card>() { FakeMapping[theCard] }; FakeMapping[theCard] = null; } Game.CurrentGame.HandleCardTransferToHand(null, dest, answer[0], new MovementHelper() { IsWuGu = true }); }
protected override VerifierResult Verify(Player source, ICard card, List<Player> targets) { if (targets == null || targets.Count == 0) { return VerifierResult.Partial; } if (targets.Count > 1) { return VerifierResult.Fail; } Player player = targets[0]; if (player == source) { return VerifierResult.Fail; } if (!ShunChaiAdditionalCheck(source, player, card)) { return VerifierResult.Fail; } if (Game.CurrentGame.Decks[player, DeckType.Hand].Count == 0 && Game.CurrentGame.Decks[player, DeckType.DelayedTools].Count == 0 && Game.CurrentGame.Decks[player, DeckType.Equipment].Count == 0) { return VerifierResult.Fail; } return VerifierResult.Success; }
public override void Resolve(TurnContext context, ICard source) { base.Resolve(context, source); if(context.ActivePlayer.Deck.TopCard != null) _activities.Add(Activities.ChooseWhetherToMillTopCard(context, context.ActivePlayer, context.ActivePlayer, source)); }
/// <summary> /// The entry point of the program. /// </summary> private static void Main() { try { IHandEvaluator handEvaluator = new HandEvaluator(); ICard[] cards = new ICard[] { new Card(CardRank.Queen, CardSuit.Hearts), new Card(CardRank.Queen, CardSuit.Spades), new Card(CardRank.Ten, CardSuit.Hearts), new Card(CardRank.Queen, CardSuit.Diamonds), new Card(CardRank.Queen, CardSuit.Clubs) }; IHand hand = new Hand(cards); Console.WriteLine(handEvaluator.GetCategory(hand) == HandCategory.FourOfAKind); IHand handFromString = new Hand("7♠ 5♣ 4♦ 3♦ 2♣"); Console.WriteLine(handFromString); } catch (ArgumentException aex) { Console.WriteLine(aex.Message); } }
public void CardValuesTest() { Assert.AreEqual(Face.Ace, _card.Face); Assert.AreEqual(1, _card.Value); _card = _CARD_BUILDER.HasFace(Face.Two).Build(); Assert.AreEqual(2, _card.Value); _card = _CARD_BUILDER.HasFace(Face.Three).Build(); Assert.AreEqual(3, _card.Value); _card = _CARD_BUILDER.HasFace(Face.Four).Build(); Assert.AreEqual(4, _card.Value); _card = _CARD_BUILDER.HasFace(Face.Five).Build(); Assert.AreEqual(5, _card.Value); _card = _CARD_BUILDER.HasFace(Face.Six).Build(); Assert.AreEqual(6, _card.Value); _card = _CARD_BUILDER.HasFace(Face.Seven).Build(); Assert.AreEqual(7, _card.Value); _card = _CARD_BUILDER.HasFace(Face.Eight).Build(); Assert.AreEqual(8, _card.Value); _card = _CARD_BUILDER.HasFace(Face.Nine).Build(); Assert.AreEqual(9, _card.Value); _card = _CARD_BUILDER.HasFace(Face.Ten).Build(); Assert.AreEqual(10, _card.Value); _card = _CARD_BUILDER.HasFace(Face.Jack).Build(); Assert.AreEqual(10, _card.Value); _card = _CARD_BUILDER.HasFace(Face.King).Build(); Assert.AreEqual(10, _card.Value); _card = _CARD_BUILDER.HasFace(Face.Queen).Build(); Assert.AreEqual(10, _card.Value); _card = _CARD_BUILDER.HasFace(Face.undefined).Build(); Assert.AreEqual(0, _card.Value); }
public void TestHandToString1() { ICard[] cards = new ICard[0]; IHand hand = new Hand(cards); Assert.AreEqual(string.Empty, hand.ToString(), "Hand constructor does not work correctly."); }
protected override VerifierResult Verify(Player source, ICard card, List<Player> targets) { if (Game.CurrentGame.IsDying.Count == 0 && targets != null && targets.Count >= 1) { return VerifierResult.Fail; } if (Game.CurrentGame.IsDying.Count > 0 && (targets == null || targets.Count != 1)) { return VerifierResult.Fail; } Player p; if (Game.CurrentGame.IsDying.Count == 0) { p = source; } else { p = targets[0]; } if (p.Health >= p.MaxHealth) { return VerifierResult.Fail; } return VerifierResult.Success; }
protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo) { IUiProxy ui = Game.CurrentGame.UiProxies[source]; if (source.IsDead) return; List<DeckPlace> places = new List<DeckPlace>(); places.Add(new DeckPlace(dest, DeckType.Hand)); places.Add(new DeckPlace(dest, DeckType.Equipment)); places.Add(new DeckPlace(dest, DeckType.DelayedTools)); List<string> resultDeckPlace = new List<string>(); resultDeckPlace.Add(ResultDeckName); List<int> resultDeckMax = new List<int>(); resultDeckMax.Add(1); List<List<Card>> answer; if (!ui.AskForCardChoice(new CardChoicePrompt(ChoicePrompt), places, resultDeckPlace, resultDeckMax, new RequireOneCardChoiceVerifier(true), out answer)) { Trace.TraceInformation("Player {0} Invalid answer", source.Id); answer = new List<List<Card>>(); answer.Add(Game.CurrentGame.PickDefaultCardsFrom(places)); } Card theCard = answer[0][0]; if (ShunChaiDest(source, dest).DeckType == DeckType.Discard) { Game.CurrentGame.HandleCardDiscard(dest, new List<Card>() { theCard }); } else { Game.CurrentGame.HandleCardTransferToHand(dest, source, new List<Card>() { theCard }); } }
public override void Resolve(TurnContext context, ICard source) { var estate = context.ActivePlayer.Hand.OfType<Estate>().FirstOrDefault(); Action discardAction = () => { context.AvailableSpend += 4; context.DiscardCard(context.ActivePlayer, estate); }; Action gainAction = () => new GainUtility(context, context.ActivePlayer).Gain<Estate>(); if (estate != null) { var activity = Activities.ChooseYesOrNo (context.Game.Log, context.ActivePlayer, "Discard an Estate?", source, discardAction, gainAction); _activities.Add(activity); } else { gainAction(); } }
public override void Process(Player source, List<Player> dests, ICard card, ReadOnlyCard cardr) { Trace.Assert(dests == null || dests.Count == 0); Trace.Assert(card is Card); Card c = (Card)card; Install(source, c); }
public void Setup() { player = new Player("name"); banker = new Banker(new[] { player }); collectCard = new FlatCollectCard("collect", 10, banker); }
protected override VerifierResult Verify(Player source, ICard card, List<Player> targets) { if (Game.CurrentGame.IsDying.Count == 0 && targets != null && targets.Count >= 1) { return VerifierResult.Fail; } if (Game.CurrentGame.IsDying.Count > 0 && (targets == null || targets.Count != 1)) { return VerifierResult.Fail; } if (Game.CurrentGame.IsDying.Count == 0) { if (source[JiuUsed] == 1) { return VerifierResult.Fail; } } else { if (targets[0] != source) { return VerifierResult.Fail; } } return VerifierResult.Success; }
public override void Resolve(TurnContext context, ICard source) { var upgradeActivity = new SelectCardsActivity(context, "Select a card to Upgrade", SelectionSpecifications.SelectExactlyXCards(1), source); upgradeActivity.AfterCardsSelected = cardList => { var player = context.ActivePlayer; var cardToUpgrade = cardList.Single(); var upgradeCost = cardToUpgrade.Cost + 1; context.Trash(player, cardToUpgrade); if (context.Game.Bank.Piles.Any(p => !p.IsEmpty && p.TopCard.Cost == upgradeCost)) { var gainActivity = Activities.GainACardCostingExactlyX(context.Game.Log, player, upgradeCost, player.Discards, source); _activities.Add(gainActivity); } else { context.Game.Log.LogMessage("{0} could gain no card of appropriate cost", player); } }; _activities.Add(upgradeActivity); }
public override VerifierResult Verify(Player source, ICard card, List<Player> targets, bool isLooseVerify) { if (targets == null || targets.Count == 0) { return VerifierResult.Partial; } if (!isLooseVerify && targets.Count > 1) { return VerifierResult.Fail; } foreach (var player in targets) { if (player == source) { return VerifierResult.Fail; } if (!ShunChaiAdditionalCheck(source, player, card)) { return VerifierResult.Fail; } if (Game.CurrentGame.Decks[player, DeckType.Hand].Count == 0 && Game.CurrentGame.Decks[player, DeckType.DelayedTools].Count == 0 && Game.CurrentGame.Decks[player, DeckType.Equipment].Count == 0) { return VerifierResult.Fail; } } return VerifierResult.Success; }
public void Count(ICard card) { if (card.Value == 1 || card.Value == 10) _count--; else if (card.Value > 1 && card.Value < 7) _count++; }
public void Setup() { player = new Player("name"); banker = new Banker(new[] { player }); payCard = new FlatPayCard("pay", 10, banker); }
public ICard SaveCard(IUserSession session, ICard newCard) { CardEffect effect = new CardEffect { Affected = (int)newCard.Effect.Affected, CardAttackChange = newCard.Effect.CardAttackChange, CardAttackMultiplier = newCard.Effect.CardAttackMultiplier, Description = newCard.Effect.Description, DisableOpponentEffect = newCard.Effect.DisableOpponentEffect, EffectTiming = (int)newCard.Effect.EffectTiming, LifePointsChange = newCard.Effect.LifePointsChange, Name = newCard.Effect.Name, ProbabilityOfEffect = newCard.Effect.ProbabilityOfEffect }; Card created = new Card { Name = newCard.Name, ImageUrl = newCard.ImageUrl, Effect = effect, AttackPoints = newCard.AttackPoints, DefensePoints = newCard.DefensePoints }; RequestContext.Model<Entities>().AddToCards(created); RequestContext.Model<Entities>().SaveChanges(); return created; }
public override void Resolve(TurnContext context, ICard source) { var player = context.ActivePlayer; var log = context.Game.Log; if (player.Hand.OfType<IActionCard>().Any()) { var activity = new SelectCardsActivity( log, player, "Select an action to play twice", SelectionSpecifications.SelectExactlyXCards(1), source); activity.Hint = ActivityHint.PlayCards; activity.Specification.CardTypeRestriction = typeof (IActionCard); activity.AfterCardsSelected = cards => { var actionCard = cards.OfType<IActionCard>().Single(); log.LogMessage("{0} selected {1} to be played twice.", player.Name, actionCard.Name); actionCard.MoveTo(context.ActivePlayer.PlayArea); context.AddEffect(source, new PlayCardEffect(actionCard)); context.AddEffect(source, new PlayCardEffect(actionCard)); }; _activities.Add(activity); } }
public DamageDealt(IGame game, ICard source, ICardInPlay target, byte damage) : base(game) { this.Source = source; this.Target = target; this.damage = damage; }
public void AddCard(ICard card) { if (card == null) throw new ArgumentNullException("Card must not be null!"); else _hand.AddCard(card); }
public override void Process(Player source, List<Player> dests, ICard card, ReadOnlyCard readonlyCard) { DeckType wuguDeck = new DeckType("WuGu"); DeckType wuguFakeDeck = new DeckType("WuGuFake"); CardsMovement move = new CardsMovement(); move.Cards = new List<Card>(); for (int i = 0; i < dests.Count; i++) { Game.CurrentGame.SyncImmutableCardAll(Game.CurrentGame.PeekCard(0)); Card c = Game.CurrentGame.DrawCard(); move.Cards.Add(c); } move.To = new DeckPlace(null, wuguDeck); Game.CurrentGame.MoveCards(move); fakeMapping = new Dictionary<Card, Card>(); Game.CurrentGame.Decks[null, wuguFakeDeck].Clear(); foreach (var c in Game.CurrentGame.Decks[null, wuguDeck]) { var faked = new Card(c); faked.Place = new DeckPlace(null, wuguFakeDeck); Game.CurrentGame.Decks[null, wuguFakeDeck].Add(faked); fakeMapping.Add(faked, c); } Game.CurrentGame.NotificationProxy.NotifyWuGuStart(new DeckPlace(null, wuguFakeDeck)); base.Process(source, dests, card, readonlyCard); Game.CurrentGame.NotificationProxy.NotifyWuGuEnd(); Game.CurrentGame.Decks[null, wuguFakeDeck].Clear(); if (Game.CurrentGame.Decks[null, wuguDeck].Count > 0) { move = new CardsMovement(); move.Cards = new List<Card>(Game.CurrentGame.Decks[null, wuguDeck]); move.To = new DeckPlace(null, DeckType.Discard); Game.CurrentGame.MoveCards(move); } }
public override void TagAndNotify(Player source, List<Player> dests, ICard card, GameAction action = GameAction.Use) { if (this.IsReforging(source, null, null, dests)) { if (card is CompositeCard) { foreach (Card c in (card as CompositeCard).Subcards) { c.Log.Source = source; c.Log.GameAction = GameAction.Reforge; } } else { var c = card as Card; Trace.Assert(card != null); c.Log.Source = source; c.Log.GameAction = GameAction.Reforge; } Game.CurrentGame.NotificationProxy.NotifyReforge(source, card); return; } base.TagAndNotify(source, dests, card, action); }
public void TestCompareHands_HighCard() { ICard[] cards1 = new ICard[5] { new Card(CardFace.Ace, CardSuit.Clubs), new Card(CardFace.Ten, CardSuit.Diamonds), new Card(CardFace.Nine, CardSuit.Clubs), new Card(CardFace.Five, CardSuit.Clubs), new Card(CardFace.Four, CardSuit.Clubs) }; IHand hand1 = new Hand(cards1); ICard[] cards2 = new ICard[5] { new Card(CardFace.King, CardSuit.Clubs), new Card(CardFace.Queen, CardSuit.Clubs), new Card(CardFace.Jack, CardSuit.Clubs), new Card(CardFace.Eight, CardSuit.Spades), new Card(CardFace.Six, CardSuit.Diamonds) }; IHand hand2 = new Hand(cards2); int compareResult = handChecker.CompareHands(hand1, hand2); Assert.IsTrue(compareResult > 0); }
public GetJudgeCardTrigger(Player p, ISkill skill, ICard card, bool permenant = false) { Owner = p; jSkill = skill; jCard = card; doNotUnregister = permenant; }
public override void Attack(Player victim, TurnContext context, ICard source) { var swindledCard = victim.Deck.TopCard; if(swindledCard == null) { context.Game.Log.LogMessage("{0} did not have any cards to be swindled.", victim.Name); return; } context.Trash(victim, swindledCard); var candidates = context.Game.Bank.Piles.Where(p => p.IsEmpty == false && p.TopCard.Cost == swindledCard.Cost); if(candidates.Count() == 0) { context.Game.Log.LogMessage("There are no cards of cost {0}.", swindledCard.Cost); } else if (candidates.Count() == 1) { var pile = candidates.Single(); var card = pile.TopCard; card.MoveTo(victim.Discards); context.Game.Log.LogGain(victim, card); } else { var activity = Activities.SelectACardForOpponentToGain(context, context.ActivePlayer, victim, swindledCard.Cost, source); _activities.Add(activity); } }
public void CmdDestroyCard(ICard card) { if(card.cardtype == ECardType.MONSTER_CARD) { for(int i = 0; i < monsterCards.Length; i++) { if(card == monsterCards[i]) { DestroyMonsterCard(i); return; } } } else if(card.cardtype != ECardType.UNKNOWN) { for(int i = 0; i < effectCards.Length; i++) { if(card == effectCards[i]) { DestroyEffectCard(i); return; } } } }
public override void Attack(Player victim, TurnContext context, ICard source) { var victoryTypes = victim.Hand.OfType<IVictoryCard>() .WithDistinctTypes() .ToList(); if(victoryTypes.Count() > 1) { var activity = Activities.PutCardOfTypeFromHandOnTopOfDeck(context.Game.Log, victim, "Select a victory card to put on top", typeof (IVictoryCard), source); _activities.Add(activity); } else if(victoryTypes.Any()) { var card = victoryTypes.Single(); victim.Deck.MoveToTop(card); context.Game.Log.LogMessage("{0} put a {1} on top of the deck.", victim.Name, card.Name); } else { context.Game.Log.LogRevealHand(victim); } }
private void SaveChangesToCard(IUserSet currentUserSet, ICard currentCard) { Card existingCard = FindCard(currentUserSet, currentCard); Card modifiedCard = (Card)currentCard; Type typeOfExistingCard = existingCard.GetType(); Type typeOfModifiedCard = modifiedCard.GetType(); List<PropertyInfo> propertiesExistingCard = new List<PropertyInfo>(typeOfExistingCard.GetRuntimeProperties()); List<PropertyInfo> propertiesModifiedCard = new List<PropertyInfo>(typeOfModifiedCard.GetRuntimeProperties()); // check if the properties are changed in the meantime. Should not be. for (int i = 0; i < propertiesExistingCard.Count; i++) { if(propertiesExistingCard[i].Name == propertiesModifiedCard[i].Name) { propertiesExistingCard[i].SetValue(existingCard, propertiesModifiedCard[i].GetValue(modifiedCard)); } else { throw new ArrayTypeMismatchException("Cannot save the modified Card information", new Exception( "The type of the card is changed, because the properties ofthe existing and modified cards are not the same ")); } } }
public override void Resolve(TurnContext context, ICard source) { _card.Play(context); }
public Card(ICard card) : this(card.Id, card.SetId, card.Name.Clone() as string, card.ImageUri.Clone() as string, card.Alternate.Clone() as string, card.Size, card.CloneProperties()) { }
private static SkillResponse BuildResponse(IOutputSpeech outputSpeech, bool shouldEndSession, Session sessionAttributes, Reprompt reprompt, ICard card) { SkillResponse response = new SkillResponse { Version = "1.0" }; if (sessionAttributes != null) { response.SessionAttributes = sessionAttributes.Attributes; } ResponseBody body = new ResponseBody { ShouldEndSession = shouldEndSession, OutputSpeech = outputSpeech }; if (reprompt != null) { body.Reprompt = reprompt; } if (card != null) { body.Card = card; } response.Response = body; return(response); }
public void AddCards(ICard card) { dealerCards.Add(card); }
public override async Task <MessageView> BuildView(ICard item) { Embed embed = await BuildEmbed(item); return(new MessageView(embed)); }
public static bool CheckMatch(this ICard lCard, ICard rCard) { return(lCard.Value == rCard.Value); }
public void AddCardToHand(ICard card) { _hand.AddCard(card); }
public void ShowCard(ICard card) { _view.Cards.FirstOrDefault(x => ((ICard)(x.Tag))?.Number == card.Number).Left = 0; }
public void TrashCard(ICard card) { Cards.Add(card); }
public void AddCardToDeck(ICard card) { Cards.Add(card); }
public void DecreaseTemplateDominance(ICard copy) { DominanceDegree[copy] = DominanceDegree[copy] + 1; }
public void RegisterCopy(ICard copy) { DominanceDegree.Add(copy, 0); }
public void Discard(ICard card) { this.DiscardPile.Push(card); }
public override ICard PlayCard(Prompt prompt, List <IRound> rounds, IPlayer picker, IBlind blind, ICard partnerCard) { var trick = rounds.Last().Trick; var cards = Hand.GetPlayableCards(trick.LeadingCard()); cards.Sort(); cards.Reverse(); ICard playThis; if (!_isPartner && picker != this) { _isPartner = Hand.Contains(partnerCard); } if (!trick.Any()) { if (picker == this) { playThis = cards[0]; } else if (_isPartner) { playThis = cards[0]; } else { playThis = cards.Aggregate((acc, next) => acc.IsTrump() && !next.IsTrump() ? next : acc); } } else { var winCard = trick.TheWinnerCard(); var isPickerWinning = trick.TheWinnerPlayer() == picker; if (isPickerWinning && _isPartner) { playThis = cards.Aggregate((acc, next) => acc.Value >= next.Value ? acc : next); } else if (!isPickerWinning && _isPartner) { playThis = cards[0]; } else if (isPickerWinning && !_isPartner) { if (cards[0].Power > winCard.Power) { playThis = cards[0]; } else { cards.Sort(); playThis = cards.Aggregate((acc, next) => acc.Value <= next.Value ? acc : next); } } else { playThis = cards[0].Power > winCard.Power ? cards[0] : cards.Last(); } } Hand.RemoveCard(playThis); prompt(PromptType.BotPlayCard, new Dictionary <PromptData, object> { { PromptData.Player, this }, { PromptData.Card, playThis }, { PromptData.Trick, rounds.Last().Trick } }); return(playThis); }
public void Add(ICard card) { _hand.Add(card); }
public void Remove(ICard card) { _hand.Remove(card); }
public void PickCardResponse(ICard cardSelected) { _selectedCard = cardSelected; }
/// <summary> /// The NewCard. /// </summary> /// <param name="card">The card<see cref="ICard{V}"/>.</param> /// <returns>The <see cref="ICard{V}"/>.</returns> public override ICard <V> NewCard(ICard <V> card) { return(new Card64 <V>(card)); }
public static IActivity GainOpponentsCardChoice(TurnContext context, Card card, Player cardOwner, ICard source) { var activity = new ChoiceActivity(context, context.ActivePlayer, string.Format("Gain {0}'s {1}?", cardOwner.Name, card), source, Choice.Yes, Choice.No); activity.ActOnChoice = choice => { if (choice == Choice.Yes) { card.MoveTo(context.ActivePlayer.Discards); context.Game.Log.LogGain(context.ActivePlayer, card); } }; activity.Hint = ActivityHint.GainCards; return(activity); }
public void RevealCard(ICard card) { RevealCardHandler(Id, card); }
public static GainACardActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost, CardZone destination, ICard source) { return(new GainACardActivity(log, player, string.Format("Select a card to gain of cost {0} or less.", cost), SelectionSpecifications.SelectPileCostingUpToX(cost), destination, source)); }
public static ISelectCardsActivity DiscardCards(TurnContext context, Player player, int numberToDiscard, ICard source) { return(new SelectCardsActivity( context.Game.Log, player, string.Format("Select {0} card(s) to discard.", numberToDiscard), SelectionSpecifications.SelectExactlyXCards(numberToDiscard), source) { AfterCardsSelected = cards => context.DiscardCards(player, cards), Hint = ActivityHint.DiscardCards }); }
public static IEnumerable <ISelectCardsActivity> PutMultipleCardsFromHandOnTopOfDeck(IGameLog log, Player player, int count, ICard source) { return(count.Items(i => PutCardFromHandOnTopOfDeck(log, player, string.Format("Select the {0} (of {1}) card to put on top of the deck.", i.ToOrderString(), count), source))); }
public static GainACardActivity GainACardCostingExactlyX(IGameLog log, Player player, CardCost cost, CardZone destination, ICard source) { return(new GainACardActivity(log, player, string.Format("Select a card to gain with a cost of exactly {0}.", cost), SelectionSpecifications.SelectPileCostingExactlyX(cost), destination, source)); }
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 GainACardActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost, ICard source) { return(GainACardCostingUpToX(log, player, cost, player.Discards, source)); }
public bool Apply(ICard card) => card is ITreasure;
public static ISelectCardsActivity PutCardOfTypeFromHandOnTopOfDeck(IGameLog log, Player player, string message, Type cardType, ICard source) { var spec = SelectionSpecifications.SelectExactlyXCards(1); spec.CardTypeRestriction = cardType; return(new SelectCardsActivity (log, player, message, spec, source) { AfterCardsSelected = cards => { var card = cards.Single(); player.Deck.MoveToTop(card); log.LogMessage("{0} put a {1} on top of the deck.", player.Name, card.Name); }, Hint = ActivityHint.RedrawCards }); }
public static void RemoveCard(ICard removeCard) { fiftyTwo.Remove(removeCard); }
public static ISelectCardsActivity SelectActionToPlayMultipleTimes(TurnContext context, Player player, IGameLog log, ICard source, int count) { var activity = new SelectCardsActivity( log, player, string.Format("Select an action to play {0} times", count), SelectionSpecifications.SelectExactlyXCards(1), source); activity.Hint = ActivityHint.PlayCards; activity.Specification.CardTypeRestriction = typeof(IActionCard); activity.AfterCardsSelected = cards => { var actionCard = cards.OfType <IActionCard>().Single(); log.LogMessage("{0} selected {1} to be played {2} times.", player.Name, actionCard.Name, count); actionCard.MoveTo(context.ActivePlayer.PlayArea); count.Times(() => context.AddEffect(source, new PlayCardEffect(actionCard))); }; return(activity); }