Ejemplo n.º 1
0
        /*On turn start
         * - Screen should be either cleared or hidden
         * - The Game should prompt the user by name if they are ready to began their turn
         * - Once ready the screen should display as normal with players hand, last played card and number of turns
         *
         * On card drawn, 2 turns
         * - card is added to player hand
         *
         * On card drawn, 1 turn
         * - card is added to player hand
         * - The Game should prompt the user by name if they are ready to end their turn
         */


        #region Mouse Downs
        private void DrawBtn_Click(object sender, RoutedEventArgs e)
        {
            WPFPlayer p = new WPFPlayer(game.ActivePlayer.Id, game, game.ActivePlayer.Name);

            p.Hand          = game.ActivePlayer.Hand;
            p.IsUnderAttack = game.ActivePlayer.IsUnderAttack;
            int  num       = p.Hand.Cards.Count;
            bool bombnext  = game.Deck.DrawPile.Peek().GetType() == typeof(ExplodingKitten);
            bool hasDefuse = p.Hand.GetDefuse().GetType() == typeof(Defuse);

            p.DrawCard();
            if (bombnext)
            {
                //Card bomb = game.Deck.PlayPile.Pop();
                Card defuse = p.Hand.GetDefuse();
                Card bomb   = p.Hand.GetBomb();
                if (hasDefuse)
                {
                    bombId = bomb.Id;
                    p.Hand.Cards.Remove(defuse.Id);
                    p.Hand.Cards.Remove(bomb.Id);
                    MessageBox.Show($"Fwew, you drew an Exploding Kitten, but you had a defuse.");//todo MessageBox
                    //game.ActivePlayer.Hand.Cards.Add(bomb.Id, bomb);
                    //game.ActivePlayer.SelectCard(bomb.Id);
                    //ExplodePanel_Slider.Maximum = game.Deck.DrawPile.Count;

                    //ExplodePanel.Visibility = Visibility.Visible;
                    //PlayOverlay.Visibility = Visibility.Visible;
                }
                else
                {
                    MessageBox.Show($"Oh no! You drew an Exploding Kitten, but you didn't have a defuse.");//todo MessageBox
                    if (game.Players.Count == 1)
                    {
                        this.NavigationService.Navigate(new VictoryPage(game.Players.First.Value.Name));
                    }
                }
            }
            //game.ActivePlayer.Hand = p.Hand;
            //game.ActivePlayer.IsUnderAttack = p.IsUnderAttack;
            if (!game.HasFinished)
            {
                ShowHand();
                if (!game.ActivePlayer.IsUnderAttack)
                {
                    MessageBox.Show("Your turn is now over.");//todo MessageBox
                }
                if (!bombnext)
                {
                    game.ActivePlayer.Hand          = p.Hand;
                    game.ActivePlayer.IsUnderAttack = p.IsUnderAttack;
                }
                game.EndTurn();
                ClearBoard();
                StartPlayerTurn();
            }
        }
Ejemplo n.º 2
0
        private void PlayOverlay_Play_MouseDown(object sender, MouseButtonEventArgs e)
        {
            WPFPlayer p = new WPFPlayer(game.ActivePlayer.Id, game, game.ActivePlayer.Name);

            //Player p = game.ActivePlayer;
            p.Hand          = game.ActivePlayer.Hand;
            p.IsUnderAttack = game.ActivePlayer.IsUnderAttack;
            Image _img = new Image();

            _img.Source = PlayOverlay_Card.Source;
            _img.Uid    = PlayOverlay_Card.Uid;
            Card selectedCard = null;

            foreach (KeyValuePair <int, Card> card in game.ActivePlayer.Hand.Cards)
            {
                if (sCard.Uid == card.Value.Id.ToString())
                {
                    selectedCard = card.Value;
                    break;
                }
            }
            if (selectedCard.GetType() == typeof(Favor) || selectedCard.GetType() == typeof(Pair))
            {
                p.SelectCard(selectedCard.Id);
                AddPlayerSelectPanelBtns();
                PlayerSelectPanel.Visibility = Visibility.Visible;
            }
            else if (selectedCard.GetType() == typeof(Attack))
            {
                p.PlayCard(selectedCard);
                Player prev = game.PreviousPlayer;
                game.ActivePlayer.IsActive = false;
                prev.IsActive = true;
                ClearBoard();
                AddNopeTrackBtns();
                NopeTrack.Visibility = Visibility.Visible;
            }
            else
            {
                p.PlayCard(selectedCard);
                Player prev = game.PreviousPlayer;
                game.ActivePlayer.IsActive = false;
                prev.IsActive = true;
                ClearBoard();
                AddNopeTrackBtns();
                NopeTrack.Visibility = Visibility.Visible;
            }
            game.EndTurn();
            game.ActivePlayer.Hand          = p.Hand;
            game.ActivePlayer.IsUnderAttack = p.IsUnderAttack;
        }