예제 #1
0
        private void GameOnPlayerBid(BidEventArgs bidEventArgs)
        {
            this.Contract = bidEventArgs.CurrentContract;
            this.Draw();

            if (bidEventArgs.Position == this.Position)
            {
                // Current player bid event
                return;
            }

            if (bidEventArgs.Position == PlayerPosition.East)
            {
                ConsoleHelper.DrawTextBoxTopRight(bidEventArgs.Bid.ToString(), 80 - 2 - this.Game[PlayerPosition.East].Name.Length - 2, 8);
            }

            if (bidEventArgs.Position == PlayerPosition.North)
            {
                ConsoleHelper.DrawTextBoxTopLeft(bidEventArgs.Bid.ToString(), 40 - (bidEventArgs.Bid.ToString().Length / 2), 4);
            }

            if (bidEventArgs.Position == PlayerPosition.West)
            {
                ConsoleHelper.DrawTextBoxTopLeft(bidEventArgs.Bid.ToString(), this.Game[PlayerPosition.West].Name.Length + 3, 8);
            }

            ConsoleHelper.WriteOnPosition(string.Format("{0} from {1} ({2} player)", bidEventArgs.Bid, this.Game[bidEventArgs.Position].Name, bidEventArgs.Position), 0, Settings.ConsoleHeight - 3);
            ConsoleHelper.WriteOnPosition("Press enter to continue...", 0, Settings.ConsoleHeight - 2);
            Console.ReadLine();
        }
예제 #2
0
        private void GameOnCardPlayed(CardPlayedEventArgs eventArgs)
        {
            this.Draw();

            if (eventArgs.Position == this.Position)
            {
                // Current player bid event
                return;
            }

            var position = eventArgs.Position;

            for (int i = eventArgs.CurrentTrickCards.Count() - 1; i >= 0; i--)
            {
                if (position == PlayerPosition.South)
                {
                    ConsoleHelper.DrawTextBoxTopLeft(eventArgs.CurrentTrickCards.ToList()[i].ToString(), 40 - (eventArgs.CurrentTrickCards.ToList()[i].ToString().Length / 2), Settings.ConsoleHeight - 9);
                    if (position == eventArgs.Position && eventArgs.PlayAction.Belote)
                    {
                        ConsoleHelper.DrawTextBoxTopLeft("Belote", 40 - ("Belote".Length / 2), Settings.ConsoleHeight - 10);
                    }
                }

                if (position == PlayerPosition.East)
                {
                    ConsoleHelper.DrawTextBoxTopRight(eventArgs.CurrentTrickCards.ToList()[i].ToString(), 80 - 2 - this.Game[PlayerPosition.East].Name.Length - 2, 8);
                    if (position == eventArgs.Position && eventArgs.PlayAction.Belote)
                    {
                        ConsoleHelper.DrawTextBoxTopLeft("Belote", 80 - 2 - this.Game[PlayerPosition.East].Name.Length - 2 - eventArgs.CurrentTrickCards.ToList()[i].ToString().Length - 2, 8);
                    }
                }

                if (position == PlayerPosition.North)
                {
                    ConsoleHelper.DrawTextBoxTopLeft(eventArgs.CurrentTrickCards.ToList()[i].ToString(), 40 - (eventArgs.CurrentTrickCards.ToList()[i].ToString().Length / 2), 4);
                    if (position == eventArgs.Position && eventArgs.PlayAction.Belote)
                    {
                        ConsoleHelper.DrawTextBoxTopLeft("Belote", 40 - ("Belote".Length / 2), 7);
                    }
                }

                if (position == PlayerPosition.West)
                {
                    ConsoleHelper.DrawTextBoxTopLeft(eventArgs.CurrentTrickCards.ToList()[i].ToString(), this.Game[PlayerPosition.West].Name.Length + 3, 8);
                    if (position == eventArgs.Position && eventArgs.PlayAction.Belote)
                    {
                        ConsoleHelper.DrawTextBoxTopLeft("Belote", this.Game[PlayerPosition.West].Name.Length + 3 + eventArgs.CurrentTrickCards.ToList()[i].ToString().Length + 2, 8);
                    }
                }

                position = position.PreviousPosition();
            }

            ConsoleHelper.WriteOnPosition(string.Format("Played {0} played {1}.", this.Game[eventArgs.Position].Name, eventArgs.PlayAction.Card), 0, Settings.ConsoleHeight - 3);
            ConsoleHelper.WriteOnPosition("Press enter to continue...", 0, Settings.ConsoleHeight - 2);
            Console.ReadLine();
        }
예제 #3
0
        private void Draw()
        {
            // TODO: Refactor (extract constants, improve code)
            ConsoleHelper.ClearAndResetConsole();
            ConsoleHelper.DrawTextBoxTopRight(string.Format("(SN){0} - {1}(EW)", this.Game.SouthNorthScore, this.Game.EastWestScore), Console.WindowWidth - 1, 0, ConsoleColor.Black, ConsoleColor.DarkGray);
            var contractString = (this.Contract.IsAvailable ? this.Game[this.Contract.PlayerPosition].Name + ": " : string.Empty) + this.Contract.ToString();

            ConsoleHelper.DrawTextBoxTopLeft(contractString, 0, 0, ConsoleColor.Black, ConsoleColor.DarkGray);
            var dealNumberString = string.Format("Deal №{0}", this.Game.DealNumber);

            ConsoleHelper.WriteOnPosition(dealNumberString, 40 - (dealNumberString.Length / 2), 0, ConsoleColor.Gray);
            var firstPlayerString = string.Format("(First: {0})", this.Game[this.Deal.FirstPlayerPosition].Name);

            ConsoleHelper.WriteOnPosition(firstPlayerString, 40 - (firstPlayerString.Length / 2), 1, ConsoleColor.Gray);
            ConsoleHelper.WriteOnPosition(this.Game[PlayerPosition.West].Name, 2, 9, ConsoleColor.Black, ConsoleColor.Gray);
            ConsoleHelper.WriteOnPosition(this.Game[PlayerPosition.East].Name, 80 - 2 - this.Game[PlayerPosition.East].Name.Length, 9, ConsoleColor.Black, ConsoleColor.Gray);
            ConsoleHelper.WriteOnPosition(this.Game[PlayerPosition.North].Name, 40 - (this.Game[PlayerPosition.North].Name.Length / 2), 3, ConsoleColor.Black, ConsoleColor.Gray);
            ConsoleHelper.WriteOnPosition(this.Game[PlayerPosition.South].Name, 40 - (this.Game[PlayerPosition.South].Name.Length / 2), Settings.ConsoleHeight - 5, ConsoleColor.Black, ConsoleColor.Gray);

            int left = 40 - (this.hand.ToString().Replace(" ", string.Empty).Length / 2);

            this.hand.Sort(ContractType.AllTrumps);
            foreach (var card in this.hand)
            {
                var          cardAsString = card.ToString();
                ConsoleColor color;
                if (card.Suit == CardSuit.Diamonds || card.Suit == CardSuit.Hearts)
                {
                    color = ConsoleColor.Red;
                }
                else
                {
                    color = ConsoleColor.Black;
                }

                ConsoleHelper.WriteOnPosition(cardAsString, left, Settings.ConsoleHeight - 6, color, ConsoleColor.White);
                left += cardAsString.Length;
            }
        }