package ch.fusun.baron.core.command.base;
import ch.fusun.baron.core.command.GameCommand;
import ch.fusun.baron.core.injection.Inject;
import ch.fusun.baron.core.rmi.User;
import ch.fusun.baron.core.service.UserService;
/**
* Tries to log in a user
*/
public class LoginUserCommand extends GameCommand {
private String name;
private String password;
@Inject
private transient UserService userService;
private int id;
/**
* Constructor
*/
public LoginUserCommand() {
// Do nothing
}
/**
* Constructor
*
* @param name
* the user name
* @param password
* the password
* @param id
* The id
*/
public LoginUserCommand(String name, String password, int id) {
this.name = name;
this.password = password;
this.id = id;
}
@Override
public boolean isAllowed() {
return true;
}
@Override
public void execute() {
userService.login(new User(this.name, this.password), this.id);
}
}