public PasswordComponentSolver(BombCommander bombCommander, PasswordComponent bombComponent) : base(bombCommander, bombComponent) { _spinners = bombComponent.Spinners; _submitButton = bombComponent.SubmitButton; modInfo = ComponentSolverFactory.GetModuleInfo("PasswordComponentSolver", "!{0} cycle 3 [cycle through the letters in column 3] | !{0} cycle 1 3 5 [cycle through the letters in columns 1, 3, and 5] | !{0} world [try to submit a word]", "Password"); }
public PasswordComponentSolver(BombCommander bombCommander, PasswordComponent bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) : base(bombCommander, bombComponent, ircConnection, canceller) { _spinners = bombComponent.Spinners; _submitButton = bombComponent.SubmitButton; modInfo = ComponentSolverFactory.GetModuleInfo("PasswordComponentSolver"); }
/// <summary> /// This method returns the User /// </summary> public bool ValidateUser() { // initial value (default to true) bool isValid = true; // Erase by default ValidationMessage = ""; // if there is a UserNameComponent if (HasUserNameComponent) { // validate this control isValid = UserNameComponent.Validate(); // if the value for isValid is false if (!isValid) { // Set the Validation Message ValidationMessage = UserNameComponent.InvalidReason; } else { // Set the UserName UserName = UserNameComponent.Text; } } // if the value for HasNameComponent is true if (HasNameComponent) { // no validation is required, just capturing the value this.Name = NameComponent.Text; } // if still valid if ((isValid) && (HasEmailAddressComponent)) { // is this valid isValid = EmailAddressComponent.Validate(); // if not valid if (!isValid) { // Set the InvalidReason ValidationMessage = EmailAddressComponent.InvalidReason; } else { // next we must check if this is a valid email isValid = CheckValidEmail(EmailAddressComponent.Text); // if not valid if (!isValid) { // Set the text ValidationMessage = "Please enter a valid email address"; // set to false EmailAddressComponent.IsValid = false; } else { // Set the EmailAddress EmailAddress = EmailAddressComponent.Text; } } // if the Password exists if ((isValid) && (HasPasswordComponent)) { // validate this control isValid = PasswordComponent.Validate(); // if the value for isValid is false if (!isValid) { // Set the Validation Message ValidationMessage = PasswordComponent.InvalidReason; } else { // Set Password Password = PasswordComponent.Text; } } // if the Confirm Password exists if ((isValid) && (HasConfirmPasswordComponent)) { // validate this control isValid = ConfirmPasswordComponent.Validate(); // if the value for isValid is false if (!isValid) { // Set the Validation Message ValidationMessage = ConfirmPasswordComponent.InvalidReason; } else { // Set Password2 Password2 = ConfirmPasswordComponent.Text; } } // if still valid if (isValid) { // next we must check that the two passwords match if (!TextHelper.IsEqual(Password, Password2, true, true)) { // set to false isValid = false; // Set the failed reason ValidationMessage = "The passwords do not match"; // verify both components exist if ((HasPasswordComponent) && (HasConfirmPasswordComponent)) { // set both to not valid PasswordComponent.IsValid = false; ConfirmPasswordComponent.IsValid = false; } } } } // return value return(isValid); }