#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include "Globals.h"


extern int No_Exit;
extern struct Attr heroes[HEROES];

int main(int argc, char **argv){
	//19 1.9 15 1.4 22 2.5

	//int num1;
	uint8_t level;
	uint8_t hero = atoi(argv[1]);
	if(hero > 110)
		exit(1);

/*
	float strength;
	float agility;
	float intelligence;

 	//float rate_s;
	//float rate_a;
	//float rate_i;

	float armor;
	//float speed;
	float bat;
	float damage_min;
	float damage_max;
	float damage_avg;
	float damage_ps;
	float attacks_ps;
	float health;
	float hp_ps;
	float effective_hp;
	float threesec;
	int level;

	float base_attr;
*/


	struct Level_Attr level_attr;

//	printf("%s\n", heroes[hero].name);

//	if(heroes[hero].pri_attr = STR)
//		base_attr = 
//	if(heroes[hero].pri_attr = INT)
//
//	if(heroes[hero].pri_attr = AGI)

	printf("level   strength  agility   intell    at_speed  dam_min   dam_max   dam_avg   persec    3sec      health    regen     armor     effective_hp\n");


level=24;
//	for(level=0; level<25; level++){
for(hero=0; hero<HEROES; hero++){

		Calc_Level_Attr(&level_attr, hero, level);

/*
		strength = heroes[hero].base_s + (heroes[hero].rate_s*level);
		agility = heroes[hero].base_a + (heroes[hero].rate_a*level);
		intelligence = heroes[hero].base_i + (heroes[hero].rate_i*level);
//Attack time = BAT / (1 + IAS)
		bat = heroes[hero].bat / (1 + agility/100);
//main attack damage = base damage + main attribute points
		if(heroes[hero].pri_attr == STR)
			base_attr = strength;
		if(heroes[hero].pri_attr == AGI)
			base_attr = agility;
		if(heroes[hero].pri_attr == INT)
			base_attr = intelligence;
		damage_min = heroes[hero].dam_min + base_attr;
		damage_max = heroes[hero].dam_max + base_attr;
		damage_avg = (heroes[hero].dam_min+heroes[hero].dam_max)/2 + base_attr;
		health = 150+strength*19;
		attacks_ps = (1 + agility/100) / heroes[hero].bat;
		damage_ps = damage_avg*attacks_ps;
		hp_ps = 0.25 + 0.03*strength;
		threesec = 3.0;
		threesec -= heroes[hero].attack_point;
		threesec /= bat;
		threesec = floor(threesec);
		threesec = (threesec+1)*damage_avg;
		//threesec = damage_ps*(3.0 - attack_point);


		armor = heroes[hero].armor+0.14*agility;
//Effective HP = Total HP × (1 + Armor points × 0.06) 
//Effective HP = Total HP × (1 - 0.06 × Armor points) / (1 - 0.12 × Armor points)
		if(armor<0)
			effective_hp = health*(1 - armor*0.06) / (1 - 0.12*armor);
		else
			effective_hp = health*(1 + armor*0.06);

//	printf("%d\t%.03f\t %.03f\t %.03f\t %.03fsec\t %.03f\t %.03f\t %.03f\t %.03f\t %.03f\t %.03f\t %.03f\t %.03f\n",
//level+1, strength, agility, intelligence, bat, damage_min, damage_max, damage_avg, damage_ps, health, hp_ps, armor, effective_hp);
*/

printf("%s\n", heroes[hero].name);
		printf("%d\t", level+1);
		printf("%.03f", level_attr.strength);
		Print_space(level_attr.strength);
		printf("%.03f", level_attr.agility);
		Print_space(level_attr.agility);
		printf("%.03f", level_attr.intelligence);
		Print_space(level_attr.intelligence);
		printf("%.03f", level_attr.at_speed);
		Print_space(level_attr.at_speed);
		printf("%.03f", level_attr.damage_min);
		Print_space(level_attr.damage_min);
		printf("%.03f", level_attr.damage_max);
		Print_space(level_attr.damage_max);
		printf("%.03f", level_attr.damage_avg);
		Print_space(level_attr.damage_avg);
		printf("%.03f", level_attr.damage_ps);
		Print_space(level_attr.damage_ps);
		printf("%.03f", level_attr.threesec);
		Print_space(level_attr.threesec);
		printf("%.03f", level_attr.health);
		Print_space(level_attr.health);
		printf("%.03f", level_attr.hp_ps);
		Print_space(level_attr.hp_ps);
		printf("%.03f", level_attr.armor);
		Print_space(level_attr.armor);
		printf("%.03f", level_attr.effective_hp);
		printf("\n");
	}

	return 0;
}
