#include "Stats.h"

void Statss::fromString()
{
	
if(statholder != "none")
{
//textout(screen,font,statholder.c_str(),1,400,makecol(0,255,255));
//Sleep(3770);
	int j= 0;
	int i = 0;
//maybey i acn make the conver for sring to char* right in here
	string temps[41]; //arry to hold data
	
	while (statholder[i]!= '`') //stay in untl you fing the ` at the end
	{
		if (statholder[i] != ',')//if found , dont add it to the data and move on to next char
		{
			temps[j] += statholder[i]; //add char to temp spot
			i++;
		}
		else
		{
//textout(screen,font,temps[1].c_str(),1,200,makecol(0,0,255));
			i++;
			j++;

		}

	}

	magic_power = StringToNumber(temps[0]);

	attack_power = StringToNumber(temps[1]);
	strength = StringToNumber(temps[2]);
	//npcs.insert("ghgh,dfhg,hjh,2060,1594,32,32,3,32,32,0,1,6,4,1,5`");
	magic = StringToNumber(temps[3]);  //move data from temp holder 

	magic_defense_max = StringToNumber(temps[4]);
	
	magic_defense = StringToNumber(temps[5]);
	
	immun_system = StringToNumber(temps[6]);
	
	immun_system_max = StringToNumber(temps[7]);
	
	ki = StringToNumber(temps[8]);

	ki_max = StringToNumber(temps[9]);
	ki_bar = StringToNumber(temps[10]);
	
	hp = StringToNumber(temps[11]);
	hp_max = StringToNumber(temps[12]);
	
	hp_bar = StringToNumber(temps[13]);
	
	mp_max = StringToNumber(temps[14]);
	mp = StringToNumber(temps[15]);
	
//	textprintf_centre(screen, font, 40, 200, makecol(255, 255, 255),"test source:%d", id);
	mp_bar = StringToNumber(temps[16]);

	psi_attack = StringToNumber(temps[17]);
	
	psi_points_max = StringToNumber(temps[18]);
	
	psi_defense = StringToNumber(temps[19]);
	
	psi_defense_max = StringToNumber(temps[20]);
	
	wisdom = StringToNumber(temps[21]);

	luck = StringToNumber(temps[22]);
	defense = StringToNumber(temps[23]);
	
	defense_max = StringToNumber(temps[24]);
	gold = StringToNumber(temps[25]);
	
	ap = StringToNumber(temps[26]);
	
	exp = StringToNumber(temps[27]);
	level = StringToNumber(temps[28]);
	level_max = StringToNumber(temps[29]);

	agility = StringToNumber(temps[30]);
	
	speed = StringToNumber(temps[31]);
	
	accuracy = StringToNumber(temps[32]);
	
	evasion = StringToNumber(temps[33]);
	
	lbs = StringToNumber(temps[34]);

	normal_lbs = StringToNumber(temps[35]);
	timer_max = StringToNumber(temps[36]);
	
	attack_type = StringToNumber(temps[38]);

	range = StringToNumber(temps[39]);

}
//Sleep(5000);
//socketid = StringToNumber(temps[17]);// scoketId
}

/*
string statholder;

int magic_power;
int attack_power;
int strength;
int magic;
int magic_defense_max;
int magic_defense;

int immun_system;
int immun_system_max;
int ki;
int ki_max;
int ki_bar;
int hp;

int hp_max;
int hp_bar;
int mp_max;
int mp;
int mp_bar;
int psi_attack;


int psi_attack_max;
int psi_points_max;
int psi_defense;
int psi_defense_max;
int wisdom;
int luck;

int defense;
int defense_max;
long gold;
long ap;
long exp;
int level;

int level_max;
int agility;
int speed;
int accuracy;
int evasion;
int lbs;

int normal_lbs;
int timer_max;
*/
string Statss::toString()
{
	
		
	 statholder = NumberToString(magic_power) + 
	"," + NumberToString(attack_power) + "," + NumberToString(strength) +"," +NumberToString(magic) +
	"," + NumberToString(magic_defense_max) + "," + NumberToString(magic_defense) + 
	"," + NumberToString(immun_system) + "," + NumberToString(immun_system_max) + 
	"," + NumberToString(ki) + "," + NumberToString(ki_max) +
	"," + NumberToString(ki_bar) + "," + NumberToString(hp) + 
	"," + NumberToString(hp_max) + ","+ NumberToString(hp_bar) + "," + NumberToString(mp_max) + "," + NumberToString(mp) +"," +NumberToString(mp_bar) +
	"," + NumberToString(psi_attack) + "," + NumberToString(psi_attack_max) + 
	"," + NumberToString(psi_points_max) + "," + NumberToString(psi_defense) + 
	"," + NumberToString(psi_defense_max) + "," + NumberToString(wisdom)+ "," + NumberToString(luck) + 
	"," + NumberToString(defense) + "," + NumberToString(defense_max) + 
	"," + NumberToString(gold) + "," + NumberToString(ap) +
	"," + NumberToString(exp) + "," + NumberToString(level) + 
	"," + NumberToString(level_max) + ","+ NumberToString(agility) + "," + NumberToString(speed) + "," + NumberToString(accuracy) +"," +NumberToString(evasion) +
	"," + NumberToString(lbs) + "," + NumberToString(normal_lbs) + 
	"," + NumberToString(timer_max) +"," + NumberToString(attack_type) +"," + NumberToString(range) +"`";
//textout(screen,font,statholder.c_str(),100,50*id,makecol(255,255,255));
//Sleep(10000);
return statholder;
}




string Statss::Get_statholder()
{
return toString();
}

void Statss::Setmagic_power(int Newmagic_power)
{
	if (Newmagic_power >= 0) 
	{
magic_power =Newmagic_power;
	}
}
void Statss::Setminattack_powerrato(int Newattack_power)
{
	
attack_powerminrato = Newattack_power;
	
}
void Statss::Setbonceattack_power(int Newattack_power)
{
	if (Newattack_power >=0) 
	{
bonceattack_power = Newattack_power;
	}
}
void Statss::Setattack_power(int Newattack_power)
{
	if (Newattack_power >= 0) 
	{
attack_power = Newattack_power;
	}
}
void Statss::Setstrength(int Newstrength)
{
	if (Newstrength >= 0) 
	{
strength = Newstrength;
	}
}
void Statss::Setmagic(int Newmagic)
{
	if (Newmagic >= 0) 
	{
magic = Newmagic;
	}
}
void Statss::Setmagic_defense_max(int Newmagic_defense_max)
{
	if (Newmagic_defense_max >= 0) 
	{
magic_defense_max = Newmagic_defense_max;
	}
}
void Statss::Setmagic_defense(int Newmagic_defense)
{
	if (Newmagic_defense >= 0) 
	{
magic_defense = Newmagic_defense;
	}
}




void Statss::Setimmun_system(int Newimmun_system)
{
	if (Newimmun_system >= 0) 
	{
immun_system = Newimmun_system;
	}
}
void Statss::Setimmun_system_max(int Newimmun_system_max)
{
	if (Newimmun_system_max >= 0) 
	{
immun_system_max = Newimmun_system_max;
	}
}
void Statss::Setki(int Newki)
{
	if (Newki >= 0) 
	{
ki =Newki;
	}
}
void Statss::Setki_max(int Newki_max)
{
	if (Newki_max >= 0) 
	{
ki_max = Newki_max;
	}
}
void Statss::Setki_bar(int Newki_bar)
{
	if (Newki_bar >= 0) 
	{
		ki_bar = Newki_bar;
	}
	else
	{
		ki_bar=0;
	}
}
void Statss::Sethp(int Newhp)
{
	if (Newhp >= 0) 
	{
		hp = Newhp;
	}
	else
	{
		hp = 0;
	}

if (hp > hp_max) 
	{
		hp = hp_max;
	}
}



void Statss::Sethp_max(int Newhp_max)
{
	if (Newhp_max >= 0) 
	{
hp_max = Newhp_max;
	}
else
	{
		hp_max=0;
	}
}
void Statss::Sethp_bar(int Newhp_bar)
{
	if (Newhp_bar >= 0) 
	{
hp_bar = Newhp_bar;
	}
else
	{
		hp_bar=0;
	}
}
void Statss::Setmp_max(int Newmp_max)
{
	if (Newmp_max >= 0) 
	{
mp_max = Newmp_max;
	}
}
void Statss::Setmp(int Newmp)
{
	if (Newmp > 0) 
	{
mp = Newmp;
	}
if (mp > mp_max) 
	{
		mp = mp_max;
	}


}
void Statss::Setmp_bar(int Newmp_bar)
{
	if (Newmp_bar >= 0) 
	{
mp_bar = Newmp_bar;
	}
}
void Statss::Setpsi_attack(int Newpsi_attack)
{
	if (Newpsi_attack >= 0) 
	{
psi_attack = Newpsi_attack;
	}
}




void Statss::Setpsi_attack_max(int Newpsi_attack_max)
{
	if (Newpsi_attack_max >= 0) 
	{
psi_attack_max = Newpsi_attack_max;
	}
}
void Statss::Setpsi_points_max(int Newpsi_points_max)
{
	if (Newpsi_points_max >= 0) 
	{
psi_points_max = Newpsi_points_max;
	}
}
void Statss::Setpsi_defense(int Newpsi_defense)
{
	if (Newpsi_defense >= 0) 
	{
psi_defense = Newpsi_defense;
	}
}
void Statss::Setpsi_defense_max(int Newpsi_defense_max)
{
	if (Newpsi_defense_max >= 0) 
	{
psi_defense_max = Newpsi_defense_max;
	}
}
void Statss::Setwisdom(int Newwisdom)
{
	if (Newwisdom >= 0) 
	{
wisdom = Newwisdom;
	}
}
void Statss::Setluck(int Newluck)
{
	if (Newluck >= 0) 
	{
luck = Newluck;
	}
}




void Statss::Setdefense(int Newdefense)
{
	if (Newdefense >= 0) 
	{
defense = Newdefense;
	}
}
void Statss::Setdefense_max(int Newdefense_max)
{
	if (Newdefense_max >= 0) 
	{
defense_max = Newdefense_max;
	}
}


void Statss::Setgoldpercent(double Newgoldpercent)
{
	
goldpercent = Newgoldpercent;
	
}
void Statss::Setgold(long Newgold)
{
	if (Newgold >= 0) 
	{
gold = Newgold;
	}
}
void Statss::Setap(long Newap)
{
	if (Newap >= 0) 
	{
ap = Newap;
	}
}
void Statss::Setexp(long Newexp)
{
	if (Newexp >= 0) 
	{
exp = Newexp;
	}
}
void Statss::Setlevel(int Newlevel)
{
	if (Newlevel >= 0) 
	{
level = Newlevel;
	}
}




void Statss::Setlevel_max(int Newlevel_max)
{
	if (Newlevel_max >= 0) 
	{
level_max = Newlevel_max;
	}
}
void Statss::Setagility(int Newagility)
{
	if (Newagility >= 0) 
	{
agility = Newagility;
	}
}
void Statss::Setspeed(int Newspeed)
{
	if (Newspeed >= 0) 
	{
speed = Newspeed;
	}
}
void Statss::Setaccuracy(int Newaccuracy)
{
	if (Newaccuracy >= 0) 
	{
accuracy = Newaccuracy;
	}
}
void Statss::Setevasion(int Newevasion)
{
	if (Newevasion >= 0) 
	{
evasion = Newevasion;
	}
}
void Statss::Setlbs(int Newlbs)
{
	if (Newlbs >= 0) 
	{
lbs = Newlbs;
	}
}
void Statss::Setnormal_lbs(int Newnormal_lbs)
{
	if (Newnormal_lbs >= 0) 
	{
normal_lbs = Newnormal_lbs;
	}
}

void Statss::Settimer_max(int Newtimer_max)
{
	if (Newtimer_max >= 0) 
	{
timer_max = Newtimer_max;
	}
}
void Statss::Set_statholder(string s)
{
statholder = s;
//fromString();

}
void Statss::Setattack_type(int Newattack_type)
{
attack_type = Newattack_type; //1=milee 2= ranged


}
int Statss::Getattackstamana_bar()
{
attackstamana_bar =  ((double)attackstamana/attackstamana_max * 100);
	return attackstamana_bar;
}

int Statss::Getmagic_power()
{
magic_power=((magic*level));
return magic_power;
}
int Statss::Getminattack_power()
{

	return (Getattack_power()* attack_powerminrato) ;
}
int Statss::Getbonceattack_power()
{
	return bonceattack_power ;
}
int Statss::Getattack_power()
{
attack_power=((strength*level));
	return attack_power ;
}
int Statss::Getstrength()
{
	return strength ;
}
int Statss::Getmagic()
{
return magic;
}
int Statss::Getmagic_defense_max()
{
	return magic_defense_max;
}
int Statss::Getmagic_defense()
{
	return magic_defense;
}
int Statss::Getimmun_system()
{
	return immun_system;
}
int Statss::Getimmun_system_max()
{
	return immun_system_max;
}
int Statss::Getki()
{
	return ki;
}
int Statss::Getki_max()
{
	return ki_max;
}
int Statss::Getki_bar()
{
	ki_bar = ((double)ki/ki_max) * 100;
	return ki_bar;
}
int Statss::Gethp()
{
	return hp;
}
int Statss::Gethp_max()
{
	return hp_max;
}
int Statss::Gethp_bar()
{
	hp_bar =  ((double)hp/hp_max * 100);
	return hp_bar;
}
int Statss::Getmp_max()
{
	return mp_max;
}
int Statss::Getmp()
{
	return mp;
}
int Statss::Getmp_bar()
{
	mp_bar = ((double)mp/mp_max) * 100;
	return mp_bar;
}
int Statss::Getpsi_attack()
{
	return psi_attack;
}
int Statss::Getpsi_attack_max()
{
	return psi_attack_max;
}
int Statss::Getpsi_points_max()
{
	return psi_points_max;
}
int Statss::Getpsi_defense()
{
	return psi_defense;
}
int Statss::Getpsi_defense_max()
{
	return psi_defense_max;
}
int Statss::Getwisdom()
{
	return wisdom;
}
int Statss::Getluck()
{
	return luck;
}
int Statss::Getdefense()
{
	return defense;
}
int Statss::Getdefense_max()
{
	return defense_max;
}

double Statss::Getgoldpercent()
{
	return goldpercent;
}

long Statss::Getgold()
{
	return gold;
}
long Statss::Getap()
{
	return ap;
}
long Statss::Getexp()
{
	return exp;
}
int Statss::Getlevel()
{
	return level;
}
int Statss::Getlevel_max()
{
	return level_max;
}
int Statss::Getagility()
{
	return agility;
}
int Statss::Getspeed()
{
	return speed;
}
int Statss::Getaccuracy()
{
	return accuracy;
}
int Statss::Getevasion()
{
evasion = agility*(((double)normal_lbs/lbs)*(speed+luck));
	return evasion;
}
int Statss::Getlbs()
{
	return lbs;
}
int Statss::Getnormal_lbs()
{
	return normal_lbs;
}
int Statss::Gettimer_max()
{
	return timer_max;
}
int Statss::Getattack_type()
{
	return attack_type;
}
Statss::Statss()
{
	attack_type=1; // =milee = 1 ranged  = 2
	goldpercent=.10;
	attackstamana=100;
	attackstamana_max=150;
	attackstamana_regen=45;
	bonce_attackstamana_regen=0;
	movmentRate=1;
	attackstamana_bar=((double)attackstamana/attackstamana_max) * 100;
	site=75;
	range=50;
//range=100;
	regentime=true;
	crt=1.5;
	 crtprocent=10.;
	bonceattack_power=0;
	attack_powerminrato=.6;
	statholder = "none";
	strength=3;
	magic=13;
	magic_defense_max=2;
	magic_defense=2;
	immun_system=5;
	immun_system_max=5;
	ki=999;
	ki_max=999;
	mp_regen=1;
	hp_regen=4;
	bonce_mp_regen=0;
	bonce_hp_regen=0;

	ki_bar = ((double)ki/ki_max) * 100;
 

	hp = 500;
	hp_max =500;


	hp_bar =  (double)hp/hp_max * 100;
 

	mp_max=999;
	mp=999;


	mp_bar = ((double)mp/mp_max) * 100;


	psi_attack=2;
	psi_attack_max=2;
	psi_points_max=2;
	psi_defense=3;
	psi_defense_max=3;
	wisdom=5;
	luck=5;
	defense=60;
	defense_max=10;
	gold=999;
	goldtotrade=0;
	ap=0;
	exp=0;
	level=100;
	level_max=100;
	agility=5;
	speed=4;
	accuracy=5;
	normal_lbs=160;
	lbs=160;
	timer_max=10;
	evasion = agility*(((double)normal_lbs/lbs)*(speed+luck));

	attack_power=(strength*level);

	magic_power=((magic*level));

  }


void Statss::levelup()
{

 level++;

 level_max++;
hp_max = hp_max + ((hp_max * level_max)*.02);


/*
	attackstamana=100;
	attackstamana_max=100;
	attackstamana_regen=50;
	bonce_attackstamana_regen=0;
	movmentRate=1;
	attackstamana_bar=((double)attackstamana/attackstamana_max) * 100;
site=50;
range=50;
regentime=true;
 crt=2.5;
 crtprocent=10.;

attack_powerminrato=4;
statholder = "none";
 strength=55;
 magic=13;
 magic_defense_max=2;
 magic_defense=2;
 immun_system=5;
 immun_system_max=5;
 
 ki_max=999;
 mp_regen=1;
 hp_regen=1;
 bonce_mp_regen=0;
 bonce_hp_regen=0;

 
 

 
 


 
 

 mp_max=999;
 mp=999;


 


 psi_attack=2;
 psi_attack_max=2;
 psi_points_max=2;
 psi_defense=3;
 psi_defense_max=3;
 wisdom=5;
 luck=5;
 defense=10;
 defense_max=10;
 gold=999;
 ap=0;
 exp=0;
 */

 /*
 agility=5;
 speed=4;
 accuracy=5;
 normal_lbs=160;
 lbs=160;
timer_max=10;
 evasion = agility*(((double)normal_lbs/lbs)*(speed+luck));

 attack_power=((strength*level));

 magic_power=((magic*level));
*/

}

