/**
* process which sends registrationrequest to server.
*/
public void registrationProcess() {
getCore().getNetwork().makeContact();
RegistrationRequestMessage request = new RegistrationRequestMessage();
Pattern pWord = Pattern.compile("[a-zA-Z_0-9]+");
Pattern pEmail = Pattern.compile("^\\S+@\\S+$");
Matcher mName = pWord.matcher(lName.getText());
Matcher mPassword = pWord.matcher(String.valueOf(lPassword
.getPassword()));
Matcher mEmail = pEmail.matcher(lEmail.getText());
boolean pMatchesName = mName.matches();
boolean pMatchesPwd = mPassword.matches();
boolean pMatchesEmail = mEmail.matches();
if (!this.IsInDictionary())
{
if (lName.getText().equals("")
|| String.valueOf(lPassword.getPassword()).equals("")
|| String.valueOf(lPassword2.getPassword()).equals("")) {
errorDialog("fields marked with * have to be filled out");
lName.requestFocus();
} else if (lName.getText().length() > 12) {
errorDialog("Maximum length of Username is 12");
lName.requestFocus();
}else if (!pMatchesPwd) {
errorDialog("only a-zA-Z and 0-9 is allowed");
lPassword.requestFocus();
} else if (!String.valueOf(lPassword.getPassword()).equals(
String.valueOf(lPassword2.getPassword()))) {
errorDialog("The passwords you entered weren't identical");
lPassword.requestFocus();
} else if (!pMatchesName) {
errorDialog("only a-zA-Z and 0-9 is allowed");
lName.requestFocus();
} else if (!pMatchesEmail && !lEmail.getText().equals("")) {
errorDialog("Not a valid email address!");
lEmail.requestFocus();
} else {
request.setPassword(String.valueOf(lPassword.getPassword()));
request.setEmail(lEmail.getText());
request.setUsername(lName.getText());
this.getCore().setPlayerName(lName.getText());
getCore().getNetwork().sendMessage(request);
register.setEnabled(false);
}
}