Ejemplo n.º 1
0
        private static void MakeTurn(Player player1, Player player2, Deck deck)
        {
            //give card
            var card = MovementUtil.MakeTurn(player1, player2, deck, null);

            //Check for additional point -> (20 or 40)
            //TODO Idea for modification: Player choose if he wants to call his announce. If has more than one announce can choose which one wants to play.
            if (SixtySixUtil.HasForty(player1.Cards, card, deck))
            {
                SixtySixUtil.CallForty(player1);
                player1.HasTwentyForty.Add(new Card()
                {
                    Suit = card.Suit, Value = card.Value == CardValue.QUEEN ? CardValue.KING : CardValue.QUEEN
                });
            }
            else if (SixtySixUtil.HasTwenty(player1.Cards, card, deck))
            {
                SixtySixUtil.CallTwenty(player1);
                player1.HasTwentyForty.Add(new Card()
                {
                    Suit = card.Suit, Value = card.Value == CardValue.QUEEN ? CardValue.KING : CardValue.QUEEN
                });
            }

            var otherCard = MovementUtil.MakeTurn(player2, player1, deck, card);
            var handScore = (int)card.Value + (int)otherCard.Value;

            deck.ThrownCards.Add(card);
            deck.ThrownCards.Add(otherCard);

            // player1 plays first, so if first card wins, then the first player wins
            if (SixtySixUtil.WinsFirstCard(card, otherCard, deck.TrumpSuit))
            {
                if (!(player1.IsSilent && player2.IsSilent))
                {
                    Console.WriteLine("Winning card {0}", card);
                }
                player1.Score         += handScore;
                player1.HasWonLastHand = true;
                player2.HasWonLastHand = false;
                SixtySixUtil.DrawCard(player1, deck);
                SixtySixUtil.DrawCard(player2, deck);
            }
            else
            {
                if (!(player1.IsSilent && player2.IsSilent))
                {
                    Console.WriteLine("Winning card {0}", otherCard);
                }
                player2.Score         += handScore;
                player2.HasWonLastHand = true;
                player1.HasWonLastHand = false;
                SixtySixUtil.DrawCard(player2, deck);
                SixtySixUtil.DrawCard(player1, deck);
            }
        }
Ejemplo n.º 2
0
        public static Card MakeTurn(Player player, Deck deck, Card playedFromOther = null)
        {
            if (!player.IsSilent)
            {
                Console.WriteLine();
                if (playedFromOther != null)
                {
                    Console.WriteLine("Other player played: " + playedFromOther);
                }
                Console.WriteLine("Your Hand: " + player.ToStringPlayerCards());
            }
            Card card = null;

            do
            {
                Console.WriteLine("Ender the choosen card in format <<<cardValue cardSuit>>>");
                String input = Console.ReadLine();
                var    parts = input.Split(null);
                var    value = ParseInputToCardValue(parts[0]);
                var    suit  = ParseInputToCardSuit(parts[1]);

                card = new Card()
                {
                    Value = value, Suit = suit
                };
            } while (card == null || card.Suit == 0);

            if (SixtySixUtil.HasForty(player.Cards, card, deck))
            {
                SixtySixUtil.CallForty(player);
            }
            else if (SixtySixUtil.HasTwenty(player.Cards, card, deck))
            {
                SixtySixUtil.CallTwenty(player);
            }

            player.GiveCard(card);

            return(card);
        }