//FlagStats
// by Mine GO BOOM
//  for CEBot

#include <stdio.h>
#include <string.h>
#include <windows.h>
#include "..\CEBot.h"


//Defines
#define BOT_NAME_FILE	"nameflagstats.txt"			//Used for LoadBotNames
#define BOT_SAVE_DATA	"flagdata.txt"				//Used to save game data
#define SHIP_STATS		0							//If defined to a non-0 value, will print end of game ship stats

//Structs
typedef struct {
	char				BotName[32];
	char				Password[32];
	char				IP[32];
	int					Port;
	char				Arena[MAX_ARENALENGTH];
	char				ArenaType;
} BOT_NAMES;

typedef struct {
	char				Name[20];					//Last person to pick up this flag
} FLAG_FLAG_EXTRA;

typedef struct {
	short				FlagKills;					//# of flaggers killed
	short				FlagDeath;					//# of deaths with a flag
	short				Pickups;					//# of times they picked up a flag
	short				FreqChanges;				//# of times they changed freqs
	unsigned int		FreqTick;					//GetTickCount() when they joined this freq
	unsigned int		ShipTick;					//GetTickCount() when they entered as this ship
	double				ShipTime[9];				//Time they were in these ships (ships are ShipType-1)

	short				Kills;						//Their initial kills
	short				Deaths;						//Their initial deaths
	unsigned int		KillPoints;					//Their initial kills points when we last flaggame was started..
													//To get their current stats for flaggame, get current - their starting one
} FLAG_PLAYER_EXTRA;

typedef struct {
	FLAG_FLAG_EXTRA		Flags[MAX_FLAGS];			//Extra info for each flag
	FLAG_PLAYER_EXTRA	Players[MAX_PLAYERS];		//Extra info for each player

	unsigned int		FlagTick;					//GetTickCount() when flag game started (when last one ended)
	double				ShipTime[9];				//Time any person was in a ship
	int					ShipKills[9];				//# of kills this ship got
	int					ShipDeaths[9];				//# of deaths this ship got
	int					ShipChange[9];				//# of times someone changed to this ship
} FLAGSTAT_EXTRA;


//Functions
int LoadBotName(BOT_NAMES *bn);
int ChangeArenas(BOT_CMD *bc,BOT_MSG *bm,char *ArenaName);
void HandleCommands(BOT_CMD *bc,BOT_MSG *bm);
void AppendStr(char *str,char *Add,int Length);
void ReturnTimeStr(char *TimeStr,int Ticks);
void HandleFlagReset(BOT_CMD *bc,BOT_MSG *bm);
int strcatf(char *str,const char *Line,...);
void SaveData(BOT_CMD *bc,BOT_MSG *bm);








