Esempio n. 1
0
 private void BtnReset_Click(object sender, RoutedEventArgs e)
 {
     DisableMinusButtons();
     TogglePlusButtons(true);
     _createUser = new User(_defaultUser);
     DataContext = _createUser;
     TxtUsername.Clear();
     PswdPassword.Clear();
     PswdConfirm.Clear();
     TxtUsername.Focus();
 }
Esempio n. 2
0
        /// <summary>Clears all the fields on the form.</summary>
        private void Clear()
        {
            _blnNewUser = false;
            LstUsers.UnselectAll();

            // character
            TxtName.Clear();
            TxtLevel.Clear();
            TxtExperience.Clear();
            TxtSkillPoints.Clear();
            ChkAlive.IsChecked       = false;
            CmbLocation.SelectedItem = "Streets";
            TxtCurrentEndurance.Clear();
            TxtMaximumEndurance.Clear();
            TxtHunger.Clear();
            TxtThirst.Clear();

            // inventory
            CmbCurrentWeapon.SelectedIndex = 0;
            CmbLightWeapon.SelectedIndex   = 0;
            CmbHeavyWeapon.SelectedIndex   = 0;
            CmbTwoHWeapon.SelectedIndex    = 0;
            CmbArmor.SelectedIndex         = 0;
            CmbPotion.SelectedIndex        = 0;
            TxtLockpicks.Clear();
            TxtGoldOnHand.Clear();
            TxtGoldInBank.Clear();
            TxtGoldOnLoan.Clear();
            ChkShovel.IsChecked  = false;
            ChkLantern.IsChecked = false;
            ChkAmulet.IsChecked  = false;

            // stats
            TxtLightWeaponSkill.Clear();
            TxtHeavyWeaponSkill.Clear();
            TxtTwoHWeaponSkill.Clear();
            TxtBlockingSkill.Clear();
            TxtSlippingSkill.Clear();
            TxtStealthSkill.Clear();

            // henchmen
            TxtHenchmenLevel1.Clear();
            TxtHenchmenLevel2.Clear();
            TxtHenchmenLevel3.Clear();
            TxtHenchmenLevel4.Clear();
            TxtHenchmenLevel5.Clear();

            // password change fields
            PswdPassword.Clear();
            PswdConfirm.Clear();

            ToggleControls(false);
        }
Esempio n. 3
0
 /// <summary>Clears all text from the labels and resets the Page to default.</summary>
 private void Clear()
 {
     _selectedClass = new HeroClass();
     _compareClass  = new HeroClass();
     LstClasses.UnselectAll();
     TxtHeroName.Clear();
     TxtHeroName.GrabFocus();
     PswdPassword.Clear();
     PswdConfirm.Clear();
     ChkHardcore.Pressed = false;
     LblError.Text       = "";
     CheckSkillPoints();
     DisableMinus();
     TogglePlus(false);
 }
Esempio n. 4
0
 /// <summary>Saves a new <see cref="User"/> to the database.</summary>
 private async void SaveNewUser()
 {
     if (PswdPassword.Password.Trim().Length > 0 && PswdConfirm.Password.Trim().Length > 0)
     {
         if (PswdPassword.Password.Trim() == PswdConfirm.Password.Trim())
         {
             if (!GameState.AllUsers.Exists(user => user.Name == TxtName.Text.Trim()))
             {
                 if (!string.Equals(_selectedUser.Name, "Computer", StringComparison.OrdinalIgnoreCase) && !string.Equals(_selectedUser.Name, "Rathskeller", StringComparison.OrdinalIgnoreCase) && !string.Equals(_selectedUser.Name, "The Master", StringComparison.OrdinalIgnoreCase))
                 {
                     AssignSelectedUser(true);
                     if (await GameState.NewUser(_selectedUser))
                     {
                         GameState.DisplayNotification("New user successfully created.", "Assassin");
                         Clear();
                         RefreshItemsSource();
                     }
                 }
                 else
                 {
                     GameState.DisplayNotification("That username is reserved and cannot be chosen.", "Assassin");
                 }
             }
             else
             {
                 GameState.DisplayNotification("The username you have chosen is already in use.", "Assassin");
                 TxtName.Clear();
                 TxtName.Focus();
             }
         }
         else
         {
             GameState.DisplayNotification("Your passwords don't match.", "Assassin");
             PswdPassword.Clear();
             PswdConfirm.Clear();
             PswdPassword.Focus();
         }
     }
     else
     {
         GameState.DisplayNotification("Please enter a password and confirm it.", "Assassin");
     }
 }
Esempio n. 5
0
        /// <summary>Modifies an existing <see cref="User"/> and saves it to the database.</summary>
        private async void ModifyExistingUser()
        {
            // if changing password
            bool blnChangePass = false;

            if (PswdPassword.Password.Trim().Length > 0 && PswdConfirm.Password.Trim().Length > 0 && PswdPassword.Password.Trim() == PswdConfirm.Password.Trim())
            {
                blnChangePass = true;
            }
            else if (PswdPassword.Password.Trim() != PswdConfirm.Password.Trim())
            {
                GameState.DisplayNotification("Your passwords don't match.", "Assassin");
                PswdPassword.Clear();
                PswdConfirm.Clear();
                PswdPassword.Focus();
                return;
            }

            // if changing user name
            bool blnChangeName = false;

            if (TxtName.Text.Trim() != GameState.CurrentUser.Name)
            {
                if (!GameState.AllUsers.Exists(user => user.Name == TxtName.Text.Trim()) &&
                    !GameState.ReservedNames.Any(name => name.Equals(TxtName.Text.Trim(), StringComparison.OrdinalIgnoreCase)))
                {
                    blnChangeName = true;
                }
                else
                {
                    if (GameState.ReservedNames.Any(name => name.Equals(TxtName.Text.Trim(), StringComparison.OrdinalIgnoreCase)))
                    {
                        GameState.DisplayNotification("That username is reserved and cannot be chosen.", "Assassin");
                    }
                    else
                    {
                        GameState.DisplayNotification("The new username you have chosen is already in use.", "Assassin");
                    }
                    TxtName.Clear();
                    TxtName.Focus();
                    return;
                }
            }

            AssignSelectedUser(blnChangePass);

            if (blnChangeName && await GameState.DatabaseInteraction.SaveUser(_selectedUser, TxtName.Text.Trim()))
            {
                foreach (Guild guild in GameState.AllGuilds)
                {
                    if (guild.HasMember(GameState.CurrentUser))
                    {
                        await GameState.MemberLeavesGuild(GameState.CurrentUser, guild);

                        await GameState.MemberJoinsGuild(_selectedUser, guild);
                    }
                    if (await GameState.DatabaseInteraction.HasAppliedToGuild(GameState.CurrentUser, guild))
                    {
                        await GameState.DatabaseInteraction.DenyGuildApplication(GameState.CurrentUser, guild);

                        await GameState.DatabaseInteraction.ApplyToGuild(_selectedUser, guild);
                    }

                    if (guild.Master == GameState.CurrentUser.Name)
                    {
                        guild.Master = _selectedUser.Name;
                    }
                }
            }
            else if (!blnChangeName)
            {
                await GameState.DatabaseInteraction.SaveUser(_selectedUser);
            }

            GameState.AllUsers.Replace(GameState.CurrentUser, _selectedUser);

            if (GameState.CurrentUser.CurrentLocation == SleepLocation.Jail && _selectedUser.CurrentLocation != SleepLocation.Jail)
            {
                CheckJail();
            }

            Clear();
            RefreshItemsSource();
        }