#include "setup_lookuptable.h"
#include <stdio.h>
#include "rlutil.h"

void fill_lookuptable(Lookuptable* lut, int score, float lower_boundary, bool flag_lower_boundary_included, float upper_boundary, bool flag_upper_boundary_included) {
	printf(" > Score %i with Range ", score);
	if(flag_lower_boundary_included)
		printf("[");
	else
		printf("]");
	printf("%6.2f,%6.2f ", lower_boundary, upper_boundary);
	if(flag_upper_boundary_included)
		printf("] ");
	else
		printf("[ ");

	if(lut->add_range_to_lookuptable(score,  lower_boundary, flag_lower_boundary_included,  upper_boundary, flag_upper_boundary_included)) {	
		printf("was ");
		rlutil::setColor(TXTCOLOR_LIGHTGREEN);
		printf("added ");
		rlutil::setColor(TXTCOLOR_GREY);
		printf("to ");
		rlutil::setColor(TXTCOLOR_LIGHTCYAN);
		printf("%s ", lut->get_name());
		rlutil::setColor(TXTCOLOR_GREY);
		printf("(id: %03u)\n", lut->get_id());
	}
	else {
		rlutil::setColor(TXTCOLOR_LIGHTRED);
		printf("couldn't be added to %s (id: %03u)\n", lut->get_name(), lut->get_id());
		rlutil::setColor(TXTCOLOR_GREY);
	}	
}

void check_and_activate_lookuptable(Lookuptable* lut) {
	printf(" > ");
	rlutil::setColor(TXTCOLOR_LIGHTCYAN);
	printf("%s ", lut->get_name());
	rlutil::setColor(TXTCOLOR_GREY);
	printf("(id: %03u) ", lut->get_id());
	
	if(lut->check_sort_and_activate()) {	
		printf("seems to be ");
		rlutil::setColor(TXTCOLOR_LIGHTGREEN);
		printf("correct\n");
	}
	else {
		rlutil::setColor(TXTCOLOR_LIGHTRED);
		printf("is not correct\n", lut->get_name(), lut->get_id());
	}
	rlutil::setColor(TXTCOLOR_GREY);
}