private void Button_Click(object sender, RoutedEventArgs e)
 {
     Navigator.Login(this);
 }
Beispiel #2
0
        internal void ChooseAttribute(GameProcessPage gameProcessPage, string selectedAttribute, bool IsUserMove)
        {
            gameProcessPage.BotCardImage.Source = CurrentBot.Deck.Cards[0].PathToImage;
            gameProcessPage.tBotCunning.Text    = CurrentBot.Deck.Cards[0].Cunning.ToString();
            gameProcessPage.tBotIntell.Text     = CurrentBot.Deck.Cards[0].Intelligence.ToString();
            gameProcessPage.tBotPower.Text      = CurrentBot.Deck.Cards[0].Power.ToString();
            gameProcessPage.tBotCardName.Text   = CurrentBot.Deck.Cards[0].Title.ToString();
            Random rnd     = new Random();
            bool   UserWon = false;

            selectedAttribute = selectedAttribute.ToLower();
            if ((CurrentUser.CurrentCard.GetAttributeRank(selectedAttribute) == 1) && (CurrentBot.CurrentCard.GetAttributeRank(selectedAttribute) == 3))
            {
                UserWon = true;
            }
            if ((CurrentUser.CurrentCard.GetAttributeRank(selectedAttribute) == 1) && (CurrentBot.CurrentCard.GetAttributeRank(selectedAttribute) == 2))
            {
                UserWon = false;
            }

            if ((CurrentUser.CurrentCard.GetAttributeRank(selectedAttribute) == 2) && (CurrentBot.CurrentCard.GetAttributeRank(selectedAttribute) == 3))
            {
                UserWon = false;
            }
            if ((CurrentUser.CurrentCard.GetAttributeRank(selectedAttribute) == 2) && (CurrentBot.CurrentCard.GetAttributeRank(selectedAttribute) == 1))
            {
                UserWon = true;
            }
            if ((CurrentUser.CurrentCard.GetAttributeRank(selectedAttribute) == 3) && (CurrentBot.CurrentCard.GetAttributeRank(selectedAttribute) == 2))
            {
                UserWon = true;
            }
            if ((CurrentUser.CurrentCard.GetAttributeRank(selectedAttribute) == 3) && (CurrentBot.CurrentCard.GetAttributeRank(selectedAttribute) == 1))
            {
                UserWon = false;
            }
            if ((CurrentUser.CurrentCard.GetAttributeRank(selectedAttribute) == (CurrentBot.CurrentCard.GetAttributeRank(selectedAttribute))))
            {
                if (selectedAttribute.ToLower() == "intelligence")
                {
                    if (CurrentUser.CurrentCard.Intelligence > CurrentBot.CurrentCard.Intelligence)
                    {
                        UserWon = true;
                    }
                    else if (CurrentUser.CurrentCard.Intelligence < CurrentBot.CurrentCard.Intelligence)
                    {
                        UserWon = false;
                    }
                }
                else if (selectedAttribute.ToLower() == "power")
                {
                    if (CurrentUser.CurrentCard.Power > CurrentBot.CurrentCard.Power)
                    {
                        UserWon = true;
                    }
                    else if (CurrentUser.CurrentCard.Power < CurrentBot.CurrentCard.Power)
                    {
                        UserWon = false;
                    }
                }
                else if (selectedAttribute.ToLower() == "cunning")
                {
                    if (CurrentUser.CurrentCard.Cunning > CurrentBot.CurrentCard.Cunning)
                    {
                        UserWon = true;
                    }
                    else if (CurrentUser.CurrentCard.Cunning < CurrentBot.CurrentCard.Cunning)
                    {
                        UserWon = false;
                    }
                }
                else
                {
                    if (rnd.Next(0, 1) == 0)
                    {
                        UserWon = false;
                    }
                    else
                    {
                        UserWon = true;
                    }
                }
            }
            if (UserWon)
            {
                CurrentBot.Deck.Cards.RemoveAt(0);
                gameProcessPage.tBotNumberOfCards.Text = "Deck: " + (CurrentBot.Deck.Cards.Count - 1).ToString();
                //gameProcessPage.BotCardImage.Source = new BitmapImage(new Uri("Resources/Death.png", UriKind.Relative));
                if (selectedAttribute.ToLower() == "power")
                {
                    gameProcessPage.tBotPower.Foreground  = new SolidColorBrush(Colors.Red);
                    gameProcessPage.tUserPower.Foreground = new SolidColorBrush(Colors.Green);
                }
                else if (selectedAttribute.ToLower() == "cunning")
                {
                    gameProcessPage.tBotCunning.Foreground  = new SolidColorBrush(Colors.Red);
                    gameProcessPage.tUserCunning.Foreground = new SolidColorBrush(Colors.Green);
                }
                else
                {
                    gameProcessPage.tBotIntell.Foreground  = new SolidColorBrush(Colors.Red);
                    gameProcessPage.tUserIntell.Foreground = new SolidColorBrush(Colors.Green);
                }
            }
            else
            {
                UserPlayedCards.Add(CurrentUser.CurrentCard);
                CurrentUser.Deck.Cards.RemoveAt(0);
                gameProcessPage.tUserNumberOfCards.Text = "Deck: " + (CurrentUser.Deck.Cards.Count - 1).ToString();
                //gameProcessPage.UserCardImage.Source = new BitmapImage(new Uri("Resources/Death.png", UriKind.Relative));
                if (selectedAttribute.ToLower() == "power")
                {
                    gameProcessPage.tUserPower.Foreground = new SolidColorBrush(Colors.Red);
                    gameProcessPage.tBotPower.Foreground  = new SolidColorBrush(Colors.Green);
                }
                else if (selectedAttribute.ToLower() == "cunning")
                {
                    gameProcessPage.tUserCunning.Foreground = new SolidColorBrush(Colors.Red);
                    gameProcessPage.tBotCunning.Foreground  = new SolidColorBrush(Colors.Green);
                }
                else
                {
                    gameProcessPage.tUserIntell.Foreground = new SolidColorBrush(Colors.Red);
                    gameProcessPage.tBotIntell.Foreground  = new SolidColorBrush(Colors.Green);
                }
            }
            if (CurrentBot.Deck.Cards.Count == 0)
            {
                Navigator.ShowResult(gameProcessPage, true);
            }
            else if (CurrentUser.Deck.Cards.Count == 0)
            {
                Navigator.ShowResult(gameProcessPage, false);
            }
            else
            {
                CurrentUser.Deck.Shuffle();
                CurrentBot.Deck.Shuffle();
                CurrentBot.CurrentCard  = CurrentBot.Deck.Cards[0];
                CurrentUser.CurrentCard = CurrentUser.Deck.Cards[0];
                if (IsUserMove)
                {
                    IsUserLastMove = true;
                    gameProcessPage.bUserCunning.IsEnabled      = false;
                    gameProcessPage.bUserIntelligence.IsEnabled = false;
                    gameProcessPage.bUserPower.IsEnabled        = false;
                    gameProcessPage.bNext.IsEnabled             = true;
                }
                else
                {
                    IsUserLastMove = false;
                    gameProcessPage.bNext.IsEnabled = true;
                    gameProcessPage.bShow.IsEnabled = false;
                }
            }
        }