Exemple #1
0
        public ActionResponse Execute()
        {
            ActionResponse res = new ActionResponse();

            res.AddMessage(CurrentPlayer.Hand.ToString());
            return(res);
        }
Exemple #2
0
        public override ActionResponse DrawCard()
        {
            ActionResponse res = new ActionResponse();

            if (IsAskedForFavor)
            {
                return(new ActionResponse(new Message(Enums.Severity.Error, "You can't draw when you're being asked for a favor.")));
            }
            if (IsBeingStolenFrom)
            {
                return(new ActionResponse(new Message(Enums.Severity.Error, "You can't draw when you're being stolen from.")));
            }

            Card card = _game.Deck.DrawPile.Pop();

            Hand.Cards.Add(card.Id, card);

            if (card is ExplodingKitten)
            {
                res = PlayCard(card);
            }
            else
            {
                res.AddMessage(string.Format("Player {0} picked up card {1}", _game.ActivePlayer.Id, card.ToString()));
            }



            return(res);
        }
Exemple #3
0
        public override ActionResponse Play()
        {
            ActionResponse res = new ActionResponse();

            res.AddMessage("Nope!\n");
            return(res);
        }
        public override ActionResponse Play()
        {
            ActionResponse res      = new ActionResponse();
            Stack <Card>   drawPile = Game.Deck.DrawPile;

            Card first  = drawPile.Pop();
            Card second = drawPile.Pop();
            Card third  = drawPile.Pop();

            res.AddMessage(first.ToString());
            res.AddMessage(second.ToString());
            res.AddMessage(third.ToString());

            drawPile.Push(third);
            drawPile.Push(second);
            drawPile.Push(first);

            return(res);
        }
        public override ActionResponse Play()
        {
            ActionResponse res = new ActionResponse();

            res.AddMessage(string.Format("Player {0} is under attack!", Game.NextPlayer.Id));

            Game.ActivePlayer.IsUnderAttack = false;
            Game.NextPlayer.IsUnderAttack   = true;
            Game.EndTurn();

            return(res);
        }
Exemple #6
0
        public override ActionResponse Play(Player player)
        {
            ActionResponse res = new ActionResponse();

            foreach (Card card in this.Game.ActivePlayer.Hand.Cards.Values)
            {
                if (IsPair(card))
                {
                    // play the pair card
                    Game.ActivePlayer.Hand.Cards.Remove(card.Id);
                    Game.Deck.PlayPile.Push(card);

                    Card stolenCard = player.Hand.RemoveRandomCard();
                    Game.ActivePlayer.Hand.Cards.Add(stolenCard.Id, stolenCard);
                    res.AddMessage(string.Format("Player {0} stole player {1}'s card.", Game.ActivePlayer.Id, player.Id));

                    break;
                }
            }

            return(res);
        }
        public ActionResponse Execute()
        {
            ActionResponse res = new ActionResponse();

            if (!CurrentPlayer.Hand.HasSelectedCard)
            {
                res.AddError("You must select a card to play");

                return(res);
            }

            Game.Writer.WriteLine(string.Format("Player {0} has played the card {1}\n", CurrentPlayer.Id, CurrentPlayer.Hand.SelectedCard.ToString()));

            bool   isNoped      = false;
            Player firstPlayer  = CurrentPlayer;
            Player playerToNope = Game.NextPlayer;

            while (playerToNope != firstPlayer)
            {
                Game.Writer.WriteLine(string.Format("Player {0}, would you like to 'Nope'? (y/n)\n", playerToNope.Id));
                bool hasChosen = false;

                while (!hasChosen)
                {
                    string choice = Console.ReadLine();
                    Game.Writer.WriteLine();

                    if (choice == "y" || choice == "n")
                    {
                        hasChosen = true;

                        if (choice == "y")
                        {
                            Card           nope    = playerToNope.Hand.GetNope();
                            ActionResponse nopeRes = playerToNope.PlayCard(nope);

                            if (nopeRes.IsSuccessful)
                            {
                                isNoped      = !isNoped;
                                firstPlayer  = playerToNope;
                                playerToNope = Game.GetNextPlayer(firstPlayer);
                            }
                            else
                            {
                                nopeRes.PrintErrors();
                                playerToNope = Game.GetNextPlayer(playerToNope);
                            }
                        }
                        else
                        {
                            playerToNope = Game.GetNextPlayer(playerToNope);
                        }
                    }
                }
            }

            if (isNoped)
            {
                res.AddMessage(string.Format("Player {0}'s card ({1}) was successfully 'Noped'.\n", CurrentPlayer.Id, CurrentPlayer.Hand.SelectedCard.Name));
                CurrentPlayer.DiscardCard(CurrentPlayer.Hand.SelectedCard);
            }
            else if (CurrentTargetPlayerIndex <= 0)
            {
                res = CurrentPlayer.PlayCard(CurrentPlayer.Hand.SelectedCard);
            }
            else
            {
                res = CurrentPlayer.PlayCard(CurrentPlayer.Hand.SelectedCard, Game.GetSelectedPlayer(CurrentTargetPlayerIndex));
            }

            return(res);
        }