class ProcessCodeCommand extends PlayerCommand {

    @Override
    protected void runCommand(Player player, List<String> arguments) {
        String name = player.getName();
        String code = arguments.get(0);

        if (codeService.hasTriesLeft(name)) {
            if (codeService.isCodeValid(name, code)) {
                commonService.send(player, MessageKey.RECOVERY_CODE_CORRECT);
                recoveryService.addSuccessfulRecovery(player);
                codeService.removeCode(name);
            } else {
                commonService.send(player, MessageKey.INCORRECT_RECOVERY_CODE,
                    Integer.toString(codeService.getTriesLeft(name)));
            }
        } else {
            codeService.removeCode(name);
            commonService.send(player, MessageKey.RECOVERY_TRIES_EXCEEDED);
        }
    }

}