/*
HighRiskVaccination.cpp

*/

#include "HighRiskVaccination.h"

//Constructor
HighRiskVaccination::HighRiskVaccination(){}

//Destructor
HighRiskVaccination::~HighRiskVaccination(){}

//Menu
void HighRiskVaccination::DisplayMenu() {
	cout << endl << "\t High-Risk Vaccination Model parameters" << endl;

	cout << "Please enter the number of days it takes for the vaccination to be effective: ";
	cin >>  daysTillVaccinationEffective;
	cout << endl;
	while(daysTillVaccinationEffective < 0){
		cout << "Invaild Number of Days till vaccination effective." << endl;
		cout << "Number of days it takes for the vaccination to be effective: ";
		cin >>  daysTillVaccinationEffective;
		cout << endl;
	}

	cout << "Please enter the probability that the vaccine may be ineffective (0 to 1): ";
	cin >> probabilityVaccinationIneffective;
	cout << endl;
	while(probabilityVaccinationIneffective < 0 || probabilityVaccinationIneffective > 1){
		cout << "Invaild probability that the vaccine  is ineffective" << endl;
		cout << "Probability that the vaccine may be ineffective (0 to 1): ";
		cin >> probabilityVaccinationIneffective;
		cout << endl;
	}

	cout << "Please enter the original amount of vaccine at the start of the current simulation: ";
	cin >> amountVaccine;
	cout << endl;
	while(amountVaccine < 0){
		cout << "Invaild vaccine amount value." << endl;
		cout << "Original amount of vaccine at the start of the current simulation: ";
		cin >> amountVaccine;
		cout << endl;
	}
}

//Run
void HighRiskVaccination::Run(City * targetCity) {
	int numRows = targetCity->GetRows();
	int numCols = targetCity->GetColumns();

	targetCity->SetVaccineIneffectiveness(probabilityVaccinationIneffective);
	targetCity->SetDaysUntilVaccineEffective(daysTillVaccinationEffective);
	
	if (targetCity->GetDayNumber() == 0) {
		//only run on the first day
		for (int r = 0; r < numRows; r++) {
			for (int c = 0; c < numCols; c++) {
				if (amountVaccine == 0) break;
				if (targetCity->IsUnaffected(r,c) && targetCity->IsHighRisk(r,c)) {
					targetCity->VaccinateLocation(r,c);
					amountVaccine--;
				}
			}
		}
	}
}
