//Leons Petrazickis
//Roman Riots II Events Generator
//Uses St Leo's Civ++ Event Engine V1.0

#include<fstream.h>
#include<string.h>	//Delete this

ofstream fout("events.txt");		//creates a variable of type ofstream

//Triggers
void citytaken(char city[255],
			   char attacker[255],
			   char defender[255]);
void negotiation(char talker[255],
				 char talkertype[255],
				 char listener[255],
				 char listenertype[255]);
void randomturn(int denominator);
void scenarioloaded();
void turn(int turn);
void unitkilled(char unit[255],
				char attacker[255],
				char defender[255]);

//Actions
void createunit(char owner[255],
				char unit[255],
				char veteran[255],
				char homecity[255],
				char loc[255]);
void justonce();
void noschism(char defender[255]);
void playwavefile(char filename[255]);
void text(char text[32000]);

//Keywords
void beginevents();
void endevents();
void IF();
void THEN();
void ENDIF();
void debug();

//Useful Variable
char civs[8][256] = {
		"Roman Legion",
		"Rebels",
		"Invaders",
		"English",
		"Spaniards",
		"French",
		"Independents",
		"Barbarians"};

void main(){
	//Scenario-specific variables
	char answer = ' ';			//Answer to prompts
	int x=0;					//Index for loops
	int number = 5;
	int engfreq = 3;
	int galfreq = 4;
	int generalinterval = 15;
	char assloc[] = "70,106";

	cout << "Welcome to the Setup Program for Roman Riots 2:\n";
	cout << "\t-Answer in lowercase and follow up with an [Enter]\n";
	cout << "\t-Run it again whenever needed\n";
	cout << "\t-If it summons aliens from Alpha Centauri, it is not my fault\n\n";

	beginevents();
	//debug();

	IF();
	noschism("ANYBODY");
	THEN();
	ENDIF();

	IF();
	negotiation("ANYBODY","HUMANORCOMPUTER","ANYBODY","HUMANORCOMPUTER");
	THEN();
	ENDIF();

	IF();
	randomturn(5);
	THEN();
	createunit("Rebels","Pachyderms","Yes","NONE","76,44");
	ENDIF();
	IF();
	randomturn(5);
	THEN();
	createunit("Rebels","Dark Furies","Yes","NONE","76,44");
	ENDIF();
	IF();
	randomturn(5);
	THEN();
	createunit("Rebels","Rebel Skirmisher","Yes","NONE","76,44");
	ENDIF();
	IF();
	randomturn(10);
	THEN();
	createunit("Rebels","Scout","Yes","NONE","76,44");
	ENDIF();
	IF();
	randomturn(5);
	THEN();
	createunit("Rebels","Rebel Skirmisher","Yes","NONE","29,15");
	ENDIF();
	IF();
	randomturn(5);
	THEN();
	createunit("Rebels","Rebel Skirmisher","Yes","NONE","1,47");
	ENDIF();
	IF();
	randomturn(15);
	THEN();
	createunit("Roman Legion","Praefect III","Yes","NONE","36,2");
	text("^An expert defensive unit has arrived.");
	ENDIF();


	endevents();
	fout.close();
}

void createunit(char owner[255],
				char unit[255],
				char veteran[255],
				char homecity[255],
				char loc[255]){
	fout << "CreateUnit\n";
	fout << "owner=" << owner << "\n";
	fout << "unit=" << unit << "\n";
	fout << "veteran=" << veteran << "\n";
	fout << "homecity=" << homecity << "\n";
	fout << "locations\n" << loc << "\nendlocations\n";
}

void unitkilled(char unit[255],
				char attacker[255],
				char defender[255]){
	fout << "UnitKilled\n";
	fout << "unit=" << unit << "\n";
	fout << "attacker=" << attacker << "\n";
	fout << "defender=" << defender << "\n";
}

void randomturn(int denominator){
	fout << "RandomTurn\n";
	fout << "denominator=" << denominator << "\n";
}

void turn(int turn){
	fout << "Turn\n";
	fout << "turn=" << turn << "\n";
}

void negotiation(char talker[255],
				 char talkertype[255],
				 char listener[255],
				 char listenertype[255]){
    fout << "Negotiation\n";
    fout << "talker=" << talker << "\n";
    fout << "talkertype="<< talkertype << "\n";
    fout << "listener="<< listener << "\n";
    fout << "listenertype="<< listenertype << "\n";
}

void text(char text[32000]){
	fout << "Text\n";
	fout << text << "\n";
	fout << "EndText\n";
}


void beginevents(){
	fout << "@BEGINEVENTS\n";
}

void endevents(){
	fout << "@ENDEVENTS\n";
}

void IF(){
	fout << "@IF\n";
}

void THEN(){
	fout << "@THEN\n";
}

void ENDIF(){
	fout << "@ENDIF\n";
}

void justonce(){
	fout << "JustOnce\n";
}

void noschism(char defender[255]){
	fout << "NoSchism\n";
	fout << "defender=" << defender << "\n";
}

void citytaken(char city[255],
			   char attacker[255],
			   char defender[255]){
	fout << "CityTaken\n";
	fout << "city=" << city << "\n";
	fout << "attacker=" << attacker << "\n";
	fout << "defender=" << defender << "\n";
}

void playwavefile(char filename[255]){
	fout << "PlayWaveFile\n";
	fout << filename << "\n";
}

void scenarioloaded(){
	fout << "ScenarioLoaded\n";
}

void debug(){
	fout << "@DEBUG\n";
}