#include "Player.h"
#include "Stdlcd.h"
void Player::setPlayerID(int playerID)
{
this->PlayerID=playerID;
}
int Player::getPlayerID()
{
return this->PlayerID;
}
void Player::setPlayerName(char* playerName)
{
strcpy(this->PlayerName,playerName);
}
char* Player::getPlayerName()
{
return this->PlayerName;
}
void Player::setHp(int hp)
{
this->Hp=hp;
}
int Player::gethp()
{
return this->Hp;
}
void Player::setMp(int mp)
{
this->Mp=mp;
}
int Player::getmp()
{
return this->Mp;
}
void Player::setLp(int lp)
{
this->Lp=lp;
}
int Player::getLp()
{
return this->Lp;
}
void Player::setHpMax(int hpMax)
{
this->HpMax=hpMax;
}
int Player::getHpMax()
{
return this->HpMax;
}
void Player::setMpMax(int mpMax)
{
this->MpMax=mpMax;
}
int Player::getMpMax()
{
return this->MpMax;
}
void Player::setLpMax(int lpMax)
{
this->LpMax=lpMax;
}
int Player::getLpMax()
{
return this->LpMax;
}
void Player::setMagicDefend(int value,MAGICFORCE mag)
{
this->MagicDefend[(int)(mag)]=value;
}
int Player::getMagicDefend(MAGICFORCE mag)
{
return this->MagicDefend[(int)(mag)];
}
void Player::setExp(long exp)
{
this->Exp=exp;
}
long Player::getExp()
{
return this->Exp;
}
void Player::setLevel(int level)
{
this->Level=level;
}
int Player::getLevel()
{
return this->Level;
}
void Player::setLuck(int luck)
{
this->Luck=luck;
}
int Player::getLuck()
{
return this->Luck;
}
void Player::setstrength(int strength)
{
this->Strength=strength;
}
int Player::getStrength()
{
return this->Strength;
}
void Player::setAgility(int agility)
{
this->Agility=agility;
}
int Player::getAgility()
{
return this->Agility;
}
void Player::setMagicForce(int magicForce)
{
this->MagicForce=magicForce;
}
int Player::getMagicForce()
{
return this->MagicForce;
}
void Player::setSkill(Skill* sk)
{
this->skill=sk;
}
Skill Player::getSkill()
{
return *(this->skill);
}
Skill_Data Player::getSkillData()
{
return this->skill->getSkillData();
}
void Player::moveSkill(UPORDOWN ud)
{
this->skill->moveSkill(ud);
}
void Player::moveMagic(UPORDOWN ud)
{
this->magic->moveMagic(ud);
}
void Player::setMagic(Magic* mk)
{
this->magic=mk;
}
Magic Player::getMagic()
{
return *(this->magic);
}
Magic_Data Player::getMagicData()
{
return this->magic->getMagicData();
}
void Player::setDHpMax(int dhpMax)
{
this->dHpMax=dhpMax;
}
int Player::getDHpMax()
{
return this->dHpMax;
}
void Player::setDMpMax(int dmpMax)
{
this->dMpMax=dmpMax;
}
int Player::getDMpMax()
{
return this->dMpMax;
}
void Player::setDLpMax(int dlpMax)
{
this->dLpMax=dlpMax;
}
int Player::getDLpMax()
{
return this->dLpMax;
}
void Player::setDLuck(int dluck)
{
this->dLuck=dluck;
}
int Player::getDLuck()
{
return this->dLuck;
}
void Player::setDStrength(int dstrength)
{
this->dStrength=dstrength;
}
int Player::getDStrength()
{
return this->dStrength;
}
void Player::setDAgility(int dagility)
{
this->dAgility=dagility;
}
int Player::getDAgility()
{
return this->Agility;
}
void Player::setDMagicForce(int dmagicForce)
{
this->dMagicForce=dmagicForce;
}
int Player::getDMagicForce()
{
return this->dMagicForce;
}
bool Player::addHp(int addhp)
{
if(this->Hp+addhp>this->HpMax)
{
Hp=HpMax;
return false;
}
if(this->Hp+addhp<=0)
{
Hp=0;
return true;
}
Hp+=addhp;
return false;
}
void Player::addMp(int addmp)
{
if(this->Mp+addmp>this->MpMax)
{
Mp=MpMax;
return;
}
if(this->Mp+addmp<=0)
{
Mp=0;
return;
}
Mp+=addmp;
}
void Player::addLp(int addlp)
{
if(this->Lp+addlp>this->LpMax)
{
Lp=LpMax;
return;
}
if(this->Lp+addlp<=0)
{
Lp=0;
return;
}
Lp+=addlp;
}
void Player::addHpMax(int addhpMax)
{
this->HpMax+=addhpMax;
}
void Player::addMpMax(int addmpMax)
{
this->MpMax+=addmpMax;
}
void Player::addLpMax(int addlpMax)
{
this->LpMax+=addlpMax;
}
void Player::addMagicDefend(int value,MAGICFORCE mag)
{
this->MagicDefend[(int)(mag)]+=value;
}
void Player::addExp(int addexp)
{
this->Exp+=addexp;
if(isUpgrad())
{
this->addLevel(1);
}
}
void Player::addLevel(int addlevel)
{
this->Level+=addlevel;
}
void Player::addLuck(int addluck)
{
this->Luck+=addluck;
}
void Player::addStrength(int addstrength)
{
this->Strength+=addstrength;
}
void Player::addAgility(int addagility)
{
this->Agility+=addagility;
}
void Player::addMagicForce(int addmagicForce)
{
this->MagicForce+=addmagicForce;
}
int Player::getNormalAttackValue()
{
int normalAttack=0;
normalAttack+=this->Strength*20+15;
return normalAttack;
}
int Player::getSkillAttackValue()
{
int skillAttack=0;
skillAttack=this->skill->getParam(this->Level,this->Strength,0);
return skillAttack;
}
bool Player::isHpZero()
{
return (this->Hp==0);
}
bool Player::isMpEnough(int mpcost)
{
return (this->Mp>=mpcost);
}
bool Player::isLpEnough(int lpcost)
{
return (this->Lp>=lpcost);
}
void Player::pickFromFile(int playerID,char* fileName)
{
ifstream fin;
fin.open(fileName,ios::in);
int PlayerNumber;
int tID;
char temp[STRING_LENGTH];
for(int i=0;i<4;i++)
{
fin>>temp;
}
fin>>PlayerNumber;
char large[STRING_LENGTH*8];
fin>>temp>>large;
fin>>tID;
while(PlayerNumber>0 && tID!=playerID)
{
char goby[STRING_LENGTH];
fin>>goby;
int t;
for(int i=0;i<23;i++)
{
fin>>t;
}
PlayerNumber--;
fin>>tID;
}
this->PlayerID=tID;
fin>>this->PlayerName;
fin>>this->Hp>>this->HpMax;
fin>>this->Mp>>this->MpMax;
fin>>this->Lp>>this->LpMax;
for(i=0;i<4;i++)
{
fin>>this->MagicDefend[i];
}
fin>>this->Exp;
fin>>this->Level;
fin>>this->Luck;
fin>>this->Strength;
fin>>this->Agility;
fin>>this->MagicForce;
fin>>dHpMax;
fin>>dMpMax;
fin>>dLpMax;
fin>>this->dLuck;
fin>>this->dStrength;
fin>>this->dAgility;
fin>>this->dMagicForce;
cout<<"Player "<<this->PlayerName<<" Picked!"<<endl;
fin.close();
}
void Player::readFromFile(char* fileName)
{
}
void Player::DisPlayPlayer()
{
cout<<this->PlayerName<<"\t"<<this->Hp<<"\t"<<this->Lp<<"\t"<<this->Mp<<endl;
}
void Player::DisplayPlayer(COH_drawer& cD)
{
//all int values should be included
}
bool Player::IronWork(char control,Item& item,COH_drawer& cD)
{
return(this->weapon.IronWork(control,item,cD));
}
bool Player::EquipWork(char control,Item& item,COH_drawer& cD)
{
return(this->weapon.Equip(control,item,cD));
}
void Player::RefreshWeapon(Item& item,COH_drawer& cD)
{
this->weapon.RefreshIron(item);
this->weapon.RefreshIronMaterial(item);
}
void Player::RefreshEquipment(Item& item,COH_drawer& cD)
{
this->weapon.RefreshWeapon(item);
this->weapon.RefreshWeaponItem(item);
}
void Player::DisplayIronWork(COH_drawer& cD)
{
this->weapon.DisplayIronWork(cD);
}
void Player::DisplayEquipWork(COH_drawer& cD)
{
this->weapon.DisplayEquipWork(cD);
}
bool Player::isUpgrad()
{
if(this->Exp>=(int)(sqrt((this->Level+1)*200)))
{
this->addHpMax(this->getDHpMax());
this->addMpMax(this->getDMpMax());
this->addLpMax(this->getDLpMax());
this->addLuck(this->getDLuck());
this->addStrength(this->getDStrength());
this->addAgility(this->getDAgility());
this->addMagicForce(this->getDMagicForce());
return true;
}
return false;
}
int PlayerList::getActivePlayerNumber()
{
int cnt=0;
while(PlayerActive[cnt].getPlayerID()!=-1)
{
cnt++;
}
return cnt;
}
Player PlayerList::getInactivePlayer(int index)
{
if(index<0 || index>=Total_Player_Number-Active_Player_Max_Number)
{
cout<<"wrong Player Index!Index error"<<endl;
return (*(new Player));