Ejemplo n.º 1
0
        public override PlayerAction GetTurn(ITurnContext context)
        {
            this.DrawPlayerOptions(context.MoneyToCall);
            ConsoleConfig.SetInput();
            while (true)
            {
                var          key    = Console.ReadLine().ToUpper();
                PlayerAction action = null;
                switch (key)
                {
                case "C":
                    action = PlayerAction.CheckOrCall();
                    break;

                case "R":
                    action = PlayerAction.Raise(10);
                    break;

                case "F":
                    action = PlayerAction.Fold();
                    break;

                case "A":
                    action = context.MoneyLeft > 0
                                     ? PlayerAction.Raise(context.MoneyLeft)
                                     : PlayerAction.CheckOrCall();
                    break;
                }

                if (action != null)
                {
                    return(action);
                }
            }
        }
Ejemplo n.º 2
0
        private void DrawPlayerOptions(int moneyToCall)
        {
            var col = 2;

            ConsoleConfig.WriteOnConsole(22, col, "Select action: [");
            col += 16;
            ConsoleConfig.WriteOnConsole(22, col, "C", ConsoleColor.Yellow);
            col++;
            ConsoleConfig.WriteOnConsole(22, col, "]heck/[");
            col += 7;
            ConsoleConfig.WriteOnConsole(22, col, "C", ConsoleColor.Yellow);
            col++;

            var callString = moneyToCall <= 0 ? "]all, [" : "]all(" + moneyToCall + "), [";

            ConsoleConfig.WriteOnConsole(22, col, callString);
            col += callString.Length;
            ConsoleConfig.WriteOnConsole(22, col, "R", ConsoleColor.Yellow);
            col++;
            ConsoleConfig.WriteOnConsole(22, col, "]aise, [");
            col += 8;
            ConsoleConfig.WriteOnConsole(22, col, "F", ConsoleColor.Yellow);
            col++;
            ConsoleConfig.WriteOnConsole(22, col, "]old, [");
            col += 7;
            ConsoleConfig.WriteOnConsole(22, col, "A", ConsoleColor.Yellow);
            col++;
            ConsoleConfig.WriteOnConsole(22, col, "]ll-in");
        }
Ejemplo n.º 3
0
        public void ClearMsg()
        {
            ConsoleConfig.WriteOnConsole(21, 0, new string(' ', width), ConsoleColor.White);
            ConsoleConfig.WriteOnConsole(22, 0, new string(' ', width), ConsoleColor.White);
            ConsoleConfig.WriteOnConsole(23, 0, new string(' ', width), ConsoleColor.White);

            ConsoleConfig.WriteOnConsole(25, 1, new string(' ', width - 2), ConsoleColor.White);
        }
Ejemplo n.º 4
0
        private void DrawSingleCard(int row, int col, Card card)
        {
            var cardColor = this.GetCardColor(card);

            ConsoleConfig.WriteOnConsole(row, col, card.ToCard() + "  ", cardColor, ConsoleColor.White);
            ConsoleConfig.WriteOnConsole(row + 1, col, "    ", cardColor, ConsoleColor.White);
            ConsoleConfig.WriteOnConsole(row + 2, col, "  " + card.ToCard(), cardColor, ConsoleColor.White);
        }
Ejemplo n.º 5
0
 public void DrawGameBoard()
 {
     ConsoleConfig.WriteOnConsole(10, 0, "├──────╯", ConsoleColor.Green);
     ConsoleConfig.WriteOnConsole(9, 7, "│", ConsoleColor.Green);
     ConsoleConfig.WriteOnConsole(8, 7, "┬", ConsoleColor.Green);
     ConsoleConfig.DrawBox(25, 16, 13, 4, ConsoleColor.Green, "─│─│╭╮┴┴");
     ConsoleConfig.DrawBox(17, 11, 28, 4, ConsoleColor.Green, "─│─│╭╮╯╰");
 }
Ejemplo n.º 6
0
 public PlayerUI(IPlayer player, int row, int width, int commonRow)
     : base(player)
 {
     this.row       = row;
     this.width     = width;
     this.commonRow = commonRow;
     ConsoleConfig.WriteOnConsole(6, 1, "Name: " + player.Name);
 }
Ejemplo n.º 7
0
        public override void StartRound(IStartRoundContext context)
        {
            this.BoardCards = context.BoardCards;
            this.UpdateCommonRow(context.CurrentPot);

            ConsoleConfig.WriteOnConsole(this.row + 1, this.width / 2 - 5, context.RoundType + "   ");
            base.StartRound(context);
        }
Ejemplo n.º 8
0
        private void UpdateCommonRow(int pot)
        {
            this.DrawCommunityCards();

            var potAsString = "Pot: " + pot;

            ConsoleConfig.WriteOnConsole(this.commonRow, this.width - 13, new string(' ', 12));
            ConsoleConfig.WriteOnConsole(this.commonRow, this.width - potAsString.Length - 2, potAsString);
        }
Ejemplo n.º 9
0
 private void PrintIncomingMessage(PacketHeader header, Connection connection, string message)
 {
     consoleInterface.ClearMsg();
     if (message == "Your are Connected to Powker! Wait Another Player...")
     {
         ConsoleConfig.WriteOnConsole(6, 55, "Connected");
     }
     consoleInterface.SetMsg(message.ToString());
 }
Ejemplo n.º 10
0
 public ConsoleInterface(string ProgramName, int row, int width)
 {
     this.ProgramName = ProgramName;
     this.row         = row;
     this.width       = width;
     ConsoleConfig.ConfigConsole(row, width);
     DrawTitleBox();
     DrawInfoBox();
     DrawGameBox();
     DrawInputBox();
 }
Ejemplo n.º 11
0
 public static void DrawBox(int x, int y, int w, int h, ConsoleColor color, string border)
 {
     ConsoleConfig.WriteOnConsole(y, x, new string(border[0], w), color);
     ConsoleConfig.WriteOnConsole(y + h, x, new string(border[2], w), color);
     ConsoleConfig.WriteOnConsole(y, x, new string(border[4], 1), color);
     ConsoleConfig.WriteOnConsole(y, x + w - 1, new string(border[5], 1), color);
     ConsoleConfig.WriteOnConsole(y + h, x, new string(border[7], 1), color);
     ConsoleConfig.WriteOnConsole(y + h, x + w - 1, new string(border[6], 1), color);
     for (var i = 1; i < h; i++)
     {
         ConsoleConfig.WriteOnConsole(y + i, x, new string(border[3], 1), color);
         ConsoleConfig.WriteOnConsole(y + i, x + w - 1, new string(border[1], 1), color);
     }
 }
Ejemplo n.º 12
0
        public override void StartHand(IStartHandContext context)
        {
            this.UpdateCommonRow(0);
            var dealerSymbol = context.FirstPlayerName == this.Player.Name ? "Dealer" : "      ";

            ConsoleConfig.WriteOnConsole(this.row + 1, 1, dealerSymbol, ConsoleColor.Green);

            ConsoleConfig.WriteOnConsole(this.row + 11, 2, "Money: " + context.MoneyLeft.ToString());
            this.DrawSingleCard(this.row + 9, width / 2 - 6, context.FirstCard);
            this.DrawSingleCard(this.row + 9, width / 2 - 1, context.SecondCard);

            DrawSingleHideCard(this.row + 4, width / 2 - 4);
            DrawSingleHideCard(this.row + 4, width / 2 - 9);
            DrawSingleHideCard(this.row + 4, width / 2 + 1);
            DrawSingleHideCard(this.row + 4, width / 2 - 14);
            DrawSingleHideCard(this.row + 4, width / 2 + 6);

            DrawSingleHideCard(this.row + 4, width / 2 + 27);
            DrawSingleHideCard(this.row + 4, width / 2 + 22);

            base.StartHand(context);
        }
Ejemplo n.º 13
0
        public override PlayerAction GetTurn(ITurnContext context)
        {
            this.UpdateCommonRow(context.CurrentPot);
            ConsoleConfig.WriteOnConsole(this.row + 11, 2, new string(' ', 20));
            ConsoleConfig.WriteOnConsole(this.row + 11, 2, "Money: " + context.MoneyLeft.ToString());

            var action = base.GetTurn(context);

            var lastAction = (PlayerActionType)action.Type + (action.Type == (int)PlayerActionType.Fold
                ? string.Empty
                : "(" + (action.Money + ((context.MoneyToCall < 0) ? 0 : context.MoneyToCall) + ")"));

            ConsoleConfig.WriteOnConsole(this.row + 11, this.width - 26, new string(' ', 25));
            ConsoleConfig.WriteOnConsole(this.row + 11, this.width - 26, "Last act: " + lastAction);

            var moneyAfterAction = action.Type == (int)PlayerActionType.Fold
                ? context.MoneyLeft
                : context.MoneyLeft - action.Money - context.MoneyToCall;

            ConsoleConfig.WriteOnConsole(this.row + 11, 2, new string(' ', 20));
            ConsoleConfig.WriteOnConsole(this.row + 11, 2, "Money: " + context.MoneyLeft.ToString());

            return(action);
        }
Ejemplo n.º 14
0
 public void SetInput()
 {
     ConsoleConfig.WriteOnConsole(25, 1, new string(' ', width - 2), ConsoleColor.White);
     Console.SetCursorPosition(1, 25);
 }
Ejemplo n.º 15
0
 private void DrawInputBox()
 {
     ConsoleConfig.DrawBox(0, 24, this.width, 2, ConsoleColor.Green, "─│─│╭╮╯╰");
 }
Ejemplo n.º 16
0
 private void DrawGameBox()
 {
     ConsoleConfig.DrawBox(0, 8, this.width, 12, ConsoleColor.Green, "─│─│╭╮╯╰");
 }
Ejemplo n.º 17
0
 private void DrawTitleBox()
 {
     ConsoleConfig.DrawBox(0, 0, this.width, 4, ConsoleColor.Green, "═║═║╔╗╝╚");
     ConsoleConfig.WriteOnConsole(2, width / 2 - ProgramName.Length / 2 - 1, ProgramName, ConsoleColor.Green);
 }
Ejemplo n.º 18
0
 private void DrawSingleHideCard(int row, int col)
 {
     ConsoleConfig.WriteOnConsole(row, col, "?   ", ConsoleColor.Gray, ConsoleColor.DarkGray);
     ConsoleConfig.WriteOnConsole(row + 1, col, "    ", ConsoleColor.Gray, ConsoleColor.DarkGray);
     ConsoleConfig.WriteOnConsole(row + 2, col, "   ?", ConsoleColor.Gray, ConsoleColor.DarkGray);
 }
Ejemplo n.º 19
0
 public void SetMsg(string msg)
 {
     ConsoleConfig.WriteOnConsole(21, 1, msg, ConsoleColor.White);
 }