Beispiel #1
0
        public override void PlayerDecisionFlop()
        {
            do
            {
                Console.SetCursorPosition(0, DrawCards.DiscardingSpace);
                Console.WriteLine("What card to discard?");
                int toDiscard = int.Parse(Console.ReadLine());
                if (toDiscard <= _player1.Hand.Count && toDiscard >= 1)
                {
                    _player1.Hand.Remove(_player1.Hand.Take(toDiscard).Last());
                }
                //
                // 11
                Console.SetCursorPosition(0, 1);
                for (int i = 0; i < 12; i++)
                {
                    for (int j = 0; j < 50; j++)
                    {
                        Console.Write(' ');
                    }
                    Console.WriteLine();
                }
                DrawCards.DisplayCards(_player1.Hand, 1);
            } while (_player1.Hand.Count != 2);

            Console.SetCursorPosition(0, DrawCards.DiscardingSpace);
            Console.WriteLine("                         \n              \n");
        }
Beispiel #2
0
        protected override bool Flop()
        {
            _table.Add(_deck.Pop());
            _table.Add(_deck.Pop());
            _table.Add(_deck.Pop());
            DrawCards.DisplayCards(_table, 2);
            decision player1Decision = _player1.PerformAction();

            switch (player1Decision)
            {
            case decision.Fold:
                Console.WriteLine("Player 2 wins!\n\n\n\n");
                _player2.WinBank(_bank);

                return(false);

            case decision.Call:
                _player1.MakeBet(_biggestBet);
                _bank += _biggestBet;
                break;

            case decision.Raise:
                _biggestBet += _smallBlind;
                _player1.MakeBet(_biggestBet);
                _bank += _biggestBet;
                break;

            default:
                break;
            }


            decision player2Decision = _player2.PerformAction();

            switch (player2Decision)
            {
            case decision.Fold:
                Console.WriteLine("Player 1 wins!\n\n\n\n");
                _player1.WinBank(_bank);
                _bank = 0;
                return(false);

            case decision.Call:
                _player2.MakeBet(_biggestBet);
                _bank += _biggestBet;
                break;

            case decision.Raise:
                _biggestBet += _smallBlind;
                _player2.MakeBet(_biggestBet);
                _bank += _biggestBet;
                break;

            default:
                break;
            }
            Console.WriteLine(" Biggest Bet:{0}        ", _biggestBet);
            return(true);
        }
Beispiel #3
0
 public Draw2Cards(Player owner)
 {
     Owner      = owner;
     Controller = owner;
     Title      = "Debug.Draw2Cards";
     SetCode    = SetCodes.DebugDraw2Cards;
     Skill      = new DrawCards(this);
 }
Beispiel #4
0
        /// <summary>
        /// Executes the Preflop part of poker gaeme.
        /// </summary>
        protected virtual void Preflop()
        {
            Console.Clear();
            Console.WriteLine("PlayerNand:");
            DrawCards.DisplayCards(_player1.Hand, 1);

            DisplayBanks();

            // Set blinds
            Console.SetCursorPosition(0, DrawCards.SmallBlindSpace);
            Console.Write("Your small blind: ");
            _smallBlind = uint.Parse(Console.ReadLine());
            _biggestBet = 2 * _smallBlind;
            _player1.MakeBet(_smallBlind);
            _player2.MakeBet(_biggestBet);
            _bank += _smallBlind + _biggestBet;
            DisplayBanks();
        }
Beispiel #5
0
        private void CardPickerHelper(Picker picker, PlayerBase player, DrawCards drawCards)
        {
            if (picker.SelectedIndex > -1)
            {
                string   cardStr  = picker.Items[picker.SelectedIndex];
                CardName cardName = cardOptions[cardStr];
                game.AddCard(cardName, player);

                // show stats grid if players have appropriate amount of cards
                if (game.Dealer.CurrentHand.Cards.Count >= 1 && game.Player.CurrentHand.Cards.Count >= 2)
                {
                    probTable.IsVisible          = true;
                    decisionLabel.IsVisible      = true;
                    addDealerCardLabel.IsVisible = false;
                    addPlayerCardLabel.IsVisible = false;

                    game.UpdateStats();
                }
                // dealer must have at least 1 card
                else if (game.Dealer.CurrentHand.Cards.Count < 1)
                {
                    probTable.IsVisible          = false;
                    decisionLabel.IsVisible      = false;
                    addDealerCardLabel.IsVisible = true;
                    addPlayerCardLabel.IsVisible = false;
                }
                // player must have at least 2 cards
                else if (game.Player.CurrentHand.Cards.Count < 2)
                {
                    probTable.IsVisible          = false;
                    decisionLabel.IsVisible      = false;
                    addDealerCardLabel.IsVisible = false;
                    addPlayerCardLabel.IsVisible = true;
                }

                UpdateStatsProperties();
                drawCards();
            }

            picker.SelectedIndex = -1;
            picker.Unfocus();
        }
        //Set Starting Data and the Game
        private void Start()
        {
            prog = 0;

            // Create the delays so they only have to be made once.
            m_StartWait = new WaitForSeconds(m_StartDelay);
            m_EndWait   = new WaitForSeconds(m_EndDelay);
            initialDraw = true;
            timer       = gameObject.GetComponent <Timer>();

            //Set Start Data
            turn          = Turn.MyTurn;
            maxMana       = 1;
            MyMana        = 1;
            AIMana        = 1;
            endTurnButton = false;
            AIDone        = false;

            //Managers
            tutorialManager = gameObject.GetComponent <GameTutorialManager>();
            drawCards       = gameObject.GetComponent <DrawCards>();
            UpdateGame();

            //Slider
            endTurn = endTurnObject.GetComponent <EndTurn>();
            endTurnObject.SetActive(false);

            //Disable TextBoxes
            MessageBox.SetActive(false);
            DrawBox.SetActive(false);

            //Check if tutorial is enabled
            if (tutorialManager.GetTutorialStatus() == true)
            {
                StartCoroutine(tutorialManager.RunTutorial());
            }

            //Draw Cards for your hand
            InitialDraw();
        }
Beispiel #7
0
        /// <summary>
        /// Runs the algorythm of showdown of poker game.
        /// </summary>
        protected void Showdown()
        {
            foreach (Card card in _table)
            {
                _player1.Hand.Add(card);
                _player2.Hand.Add(card);
            }
            DrawCards.DisplayCards(_player1.Hand, 1);
            Console.SetCursorPosition(0, 14);
            Console.WriteLine("COMPUTER'S HAND");
            DrawCards.DisplayCards(_player2.Hand, 2);

            // processing the hands
            HandValue p1Hand = _firstChecker.CheckCombination(_player1.Hand);
            HandValue p2Hand = _firstChecker.CheckCombination(_player2.Hand);



            DisplayBanks();
            Console.SetCursorPosition(0, 36);
            if (p1Hand > p2Hand)
            {
                Console.WriteLine("Player1 wins");
                Console.WriteLine("Player1 Combination: {0}", p1Hand.Combination);
                Console.WriteLine("Player2 Combination: {0}", p2Hand.Combination);
                _player1.WinBank(_bank);
            }
            else
            {
                Console.WriteLine("Player2 wins");
                Console.WriteLine("Player1 Combination: {0}", p1Hand.Combination);
                Console.WriteLine("Player2 Combination: {0}", p2Hand.Combination);
                _player2.WinBank(_bank);
            }
            _bank = 0;
            DisplayBanks();
        }
    public void initialSetup()
    {
        cards.Clear();

        players = new List <PlayerBase>(gameObject.FindComponentsInChildrenWithTag <PlayerBase>("player"));

        middleArea = transform.Find("MiddleArea").gameObject;

        DrawCards drawCards = GetComponent <DrawCards>();

        //Check if trigger lonely wolf setup
        int count = 0;

        foreach (PlayerBase player in players)
        {
            player.initialize();
            player.receiveCard(drawCards.getCard());

            if (!player.isHumanPlayer())
            {
                botsCards.Add(player.getCurrentCardName());
            }
            else
            {
                this.playerController = player as PlayerController;
                setHasHumanPlayer(true);
                ActionsArea.SetActive(true);
            }

            if (player.isWerewolf())
            {
                wolfs.Add(player);
                count++;
                setHasWerewolf(true);
            }

            if (count > 1)
            {
                lonelyWolf = false;
            }

            cards.Add(player.getCurrentCard().GetComponent <CardController>());
        }

        foreach (Transform middleCard in middleArea.transform)
        {
            cards.Add(middleCard.gameObject.GetComponent <CardController>());
        }

        //Configure player interactable cards
        if (isHasHumanPlayer())
        {
            foreach (var card in cards)
            {
                GameObject area     = card.transform.parent.gameObject;
                string     areaName = card.transform.parent.name;

                PlayerBase player = card.transform.parent.GetComponentInParent <PlayerBase>();

                if (player != null && player.isHumanPlayer())
                {
                    if (!player.isVillager())
                    {
                        toggleCard(card, true);
                    }
                }

                switch (playerController.getCurrentCardName())
                {
                case "Seer":
                    setPlayerCardText("Vidente", "Você pode olhar duas cartas ao centro ou a carta de um jogador.");
                    playerController.setMaxInteractions(2);

                    if (areaName != PlayersAreasConstants.player1)
                    {
                        card.CanPlayerInteract = true;
                    }
                    break;

                case "Robber":
                    setPlayerCardText("Ladrão", "Você deve escolher a carta de outro jogador e trocar pela sua.");
                    playerController.setMaxInteractions(1);
                    if (areaName != PlayersAreasConstants.middle && areaName != PlayersAreasConstants.player1)
                    {
                        card.CanPlayerInteract = true;
                    }
                    break;

                case "Werewolf":
                    if (lonelyWolf)
                    {
                        setPlayerCardText("Lobisomem", "Você é o único lobisomem, por isso deve olhar uma carta ao centro.");
                        playerController.setMaxInteractions(1);
                    }
                    else
                    {
                        setPlayerCardText("Lobisomem", "Neste momento os lobisomens devem conhecer um ao outro.");
                        if (card.getCharacter().Equals(CharactersNamesConstants.werewolf) && !card.isInMiddle())
                        {
                            // card.transform.GetChild(0).gameObject.SetActive(true);
                            // card.transform.GetChild(1).gameObject.SetActive(false);
                            card.show();

                            string parentName = card.transform.parent.name;
                            if (!parentName.Equals(PlayersAreasConstants.player1))
                            {
                                playerController.addCardAndPlace(parentName, card.gameObject);
                            }
                        }
                    }

                    if (areaName == PlayersAreasConstants.middle)
                    {
                        card.CanPlayerInteract = true;
                    }
                    break;

                default:
                    setPlayerCardText("Aldeão", "Como um aldeão, você não possui ações na etapa da noite");
                    card.CanPlayerInteract = false;
                    break;
                }
            }
        }
        else
        {
            toggleAllCardsVisible(true);
        }

        doneSetup = true;
    }