Example #1
0
            public void SetAsideTheDrawnCards(IActionScope scope)
            {
                var action = DrawnCards.First();

                DrawnCards.Remove(action);
                SetAsideCards.Add(action, scope);
            }
Example #2
0
        public void GainCardFromSupply(Card typeToGain, IActionScope turnScope)
        {
            Card gainedCard = turnScope.Supply.AcquireCard(typeToGain, turnScope);

            turnScope.Publish(new PlayerGainedCardEvent(gainedCard, turnScope));
            DiscardPile.Discard(gainedCard, turnScope);
        }
Example #3
0
        public CardSet Draw(int cardCount, IActionScope turnScope)
        {
            var cardSet = new CardSet();

            cardCount.Times(() => cardSet.Add(Draw(turnScope), turnScope));
            return(cardSet);
        }
Example #4
0
        public void ShuffleDiscardPileIntoDeck(IActionScope turnScope)
        {
            DiscardPile.Into(Deck, turnScope);
            Deck = Deck.Shuffle();

            turnScope.Publish(new DeckReplenishedEvent(turnScope));
        }
Example #5
0
        public IEventResponse HandleGameEvent(IGameMessage @event, IActionScope scope)
        {
            var aiContext = Mapper.Map <IGameMessage, AiContext>(@event);
            var votes     = _root.Evaluate(aiContext);

            votes = votes.VoteFor(@event.GetDefaultResponse(), 1);
            return(votes.Winner);
        }
 public PlayerGainedCardEvent(CardType card, IActionScope turnScope) : base(turnScope)
 {
     _card       = card;
     Description = String.Format("{0}: gained {1}",
                                 (turnScope == null || turnScope.Player == null)
                                 ? "none" : turnScope.Player.Name,
                                 card.Create().Name);
 }
Example #7
0
 public void Discard(Card card, DiscardPile discardPile, IActionScope scope)
 {
     if (this.Contains(card))
     {
         InnerList.Remove(card);
         discardPile.Discard(card, scope);
     }
 }
Example #8
0
 public void PlayCard(Card cardToPlay, CardSet cardsInPlay, IActionScope turnScope)
 {
     if (this.Contains(cardToPlay))
     {
         InnerList.Remove(cardToPlay);
         cardsInPlay.Add(cardToPlay, turnScope);
     }
 }
Example #9
0
 public SelectReplacementCardForSaboteur(IActionScope scope, Card trashedCard) : base(scope)
 {
     Description = scope.Player.Name + ", select a card to replace the trashed card (" + trashedCard.Name +
                   ")";
     GetAvailableResponses = () => scope.Supply.FindCardsCostingUpTo(scope.GetPrice(trashedCard) - 2, scope)
                             .OrderByDescending(scope.GetPrice)
                             .Select(c => new ReplaceCardForSaboteur(scope, c));
 }
Example #10
0
 public TrashTreasureCardFromThief(IActionScope scope, IActionScope reactionScope, Card item) : base(scope, item)
 {
     Description           = "Trash " + item.Name + " [Thief]";
     _reactionScope        = reactionScope;
     GetAvailableResponses = () => new List <IEventResponse> {
         this
     };
 }
Example #11
0
 public void DiscardInto(DiscardPile discardPile, IActionScope turnScope)
 {
     this.ToList().ForEach(card =>
     {
         Remove(card);
         discardPile.Discard(card, turnScope);
     });
 }
Example #12
0
        public CardSet FindCardsCostingUpTo(Money maxCost, IActionScope scope)
        {
            var eligibleCards = this.Select(x => x.Value)
                                .Where(t => t.Type.Create().BaseCost <= maxCost && t.Count > 0)
                                .Select(z => z.Type.Create());

            return(new CardSet(eligibleCards));
        }
Example #13
0
 public ReplaceCardForSaboteur(IActionScope scope, Card card) : base(scope, card)
 {
     if (card == null)
     {
         throw new ArgumentNullException("card");
     }
     Description = "Replace trashed card with " + card.Name + ". [Saboteur]";
 }
Example #14
0
 public ChooseWhetherToGainTrashedTreasureForThief(IActionScope turnScope, Card item) : base(turnScope, item)
 {
     Description           = turnScope.Player.Name + ", would you like to gain the trashed treasure: " + item.Name + " [Thief]";
     GetAvailableResponses = () => new List <IEventResponse>
     {
         new GainTrashedTreasureForThief(turnScope, Item),
         new DoNotGainTrashedTreasureForThief(turnScope, Item)
     };
 }
        public PlayerRevealedCardEvent(IActionScope actionScope, Card card) : base(actionScope)
        {
            if (card == null)
            {
                throw new ArgumentNullException("card");
            }

            _card = card;
        }
Example #16
0
 public DoYouWantToTrashMiningVillage(IActionScope scope) : base(scope)
 {
     Description           = scope.Player.Name + ", trash Mining Village for (+2)?";
     GetAvailableResponses = () => new List <IEventResponse>
     {
         new TrashMiningVillage(scope),
         new DoNotTrashMiningVillage(scope)
     };
 }
Example #17
0
 public ChooseWhetherToPutDeckInDiscardPileFromChancellor(IActionScope scope) : base(scope)
 {
     Description           = "Place deck in discard pile [Chancellor]?";
     GetAvailableResponses = () => new List <IEventResponse>
     {
         new PlaceDeckInDiscardPileForChancellor(scope),
         new DoNotPlaceDeckInDiscardPileForChancellor(scope)
     };
 }
Example #18
0
 public void Into(CardSet targetCardSet, IActionScope turnScope)
 {
     InnerList.ToList().ForEach(
         c =>
     {
         targetCardSet.Add(c, turnScope);
         Remove(c);
     });
 }
        public IEventResponse HandleGameEvent(IGameMessage @event, IActionScope scope)
        {
            if ([email protected]().Any())
            {
                return(@event.GetDefaultResponse());
            }

            return(_ai.HandleGameEvent(@event, scope));
        }
Example #20
0
        public void Add(Card card, IActionScope turnScope)
        {
            if (card == null)
            {
                return;
            }

            InnerList.Add(card);
            OnCardAdded(card, turnScope);
        }
Example #21
0
        public IEventResponse HandleGameEvent(IGameMessage @event, IActionScope scope)
        {
            if (@event.GetAvailableResponses().Count() == 1)
            {
                return(@event.GetDefaultResponse());
            }

            //DisplayTurnInfo(scope);
            return(HandleGameEvent(@event, @event.GetAvailableResponses(), scope));
        }
Example #22
0
        public Card RevealCardFromTopOfDeck(IActionScope turnScope)
        {
            var card = Deck.Draw(turnScope);

            if (card != null)
            {
                turnScope.Publish(new PlayerRevealedCardEvent(turnScope, card));
            }
            return(card);
        }
Example #23
0
        public void Handle(IGameMessage message, IActionScope turnScope)
        {
            if (message is IPlayerScoped && turnScope.Player != this)
            {
                return;
            }

            _controller.HandleGameEvent(message, turnScope).Execute();
            Hand.Handle(message, turnScope);
        }
Example #24
0
            public ChooseToDiscardOrReturnTopCardFromSpy(IActionScope scope, IActionScope reactionScope) : base(scope)
            {
                var card = reactionScope.RevealCardFromDeck();

                Description           = reactionScope.Player.Name + " revealed " + card.Name + " [Spy]";
                GetAvailableResponses = () => new List <IEventResponse>
                {
                    new DiscardTopCardFromSpyResponse(scope, reactionScope, card),
                    new ReturnTopCardFromSpyResponse(scope, reactionScope, card)
                };
            }
Example #25
0
 public Card Draw(IActionScope turnScope)
 {
     if (Count > 0)
     {
         Count--;
         if (Count == 0)
         {
             _eventAggregator.Publish(new SupplyPileDepletedEvent(this.Type, turnScope));
         }
         return(Type.Create());
     }
     throw new SupplyEmptyException();
 }
Example #26
0
 public Card Draw(IActionScope turnScope)
 {
     if (!InnerList.Any())
     {
         turnScope.Player.Handle(new DeckDepletedEvent(turnScope), turnScope);
     }
     if (InnerList.Any())
     {
         var drawn = InnerList[0];
         InnerList.RemoveAt(0);
         return(drawn);
     }
     return(null);
 }
Example #27
0
 public void ShuffleDiscardPileIntoDeck(IActionScope turnScope)
 {
 }
Example #28
0
 public void Discard(CardSet cardsToDiscard, IActionScope turnScope)
 {
 }
Example #29
0
 public void TrashCardFromHand(Card cardToTrash, IActionScope scope)
 {
 }
Example #30
0
 public void GainCardFromSupply(Card card, IActionScope turnScope)
 {
 }