

#include "HeroList.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "PublicFun.h"

extern  PAINTSTRUCT ps;
extern 	HDC hdc;
extern 	HBITMAP hbmp; 
extern 	HBITMAP hbmp2; 
extern 	BITMAP bmp;
extern 	HDC hdcMem;
extern 	HDC hdcTmp;
extern 	RECT rect;
extern 	HWND hwnd;
extern  char texta[TEXTAMAX][20];
extern  int zaoxiangflag;
extern  int quanxiangflag;
extern  int lijianflag;

extern int KeyReturn;
extern int KeyEsc;
extern int KeyHome;
extern int KeySpace;
extern int KeyLeft0;
extern int KeyUp0;
extern int KeyRight0;
extern int KeyDown0;
extern int color;

extern char t_heroName[HEROMAX][HERONAMEMAXLEN]; 
extern char t_goodName[GOODMAX][GOODNAMEMAXLEN];
extern char t_cityName[CITYMAX][CITYNAMEMAXLEN];
extern HPEN t_hpen;
extern HBRUSH t_hbrush;

using namespace std;

/***********************************************************************
* 说明:     HeroList类全局初始化函数
* 输入参数: int choice——所选择历史时期
* 返回值  : 无
* 功能	   : 初始化Hero类全部数据
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20       完成基本功能
***********************************************************************/
void HeroList::PubInit(int choice)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	char name[NORMALSTRLEN];	 
	sprintf_s(name,"Res\\Hero\\hero%d.sdt",choice+1);

	ifstream infile(name,ios::in);
	for(int y=0;y<HEROMAX;y++)
	{
		//hero[y]=new Hero();



		infile>>hero[y].no;
		infile>>hero[y].owner;
		infile>>hero[y].degree;
		if(hero[y].degree>20)hero[y].degree=1;//20170721 0-》1
		infile>>hero[y].wuli;
		if(hero[y].wuli>200)hero[y].wuli=1;
		infile>>hero[y].zili;
		if(hero[y].zili>200)hero[y].zili=1;
		infile>>hero[y].heart;
		if(hero[y].heart>100)hero[y].heart=1;
		infile>>hero[y].charcter;
		infile>>hero[y].experience;
		infile>>hero[y].tili;
		hero[y].tili=100;
		infile>>hero[y].style;
		infile>>hero[y].bingli;
		infile>>hero[y].goods1;
		infile>>hero[y].goods2;
		infile>>hero[y].age;
		infile>>hero[y].hiscity;
		hero[y].inlistflag=1;
		hero[y].speedup=0;
		switch(hero[y].goods1)
		{
		case 23:
			hero[y].speedup=3;
			break;
		case 24:
		case 25:
			hero[y].speedup=2;
			break;
		case 26:
		case 27:
		case 28:
		case 29:
		case 30:
			hero[y].speedup=1;
			break;
		}
		switch(hero[y].goods2)
		{
		case 23:
			hero[y].speedup=3;
			break;
		case 24:
		case 25:
			hero[y].speedup=2;
			break;
		case 26:
		case 27:
		case 28:
		case 29:
		case 30:
			hero[y].speedup=1;
			break;
		}
		infile>>hero[y].hisfinder;
		hero[y].iscaptive = 0;
		if(infile.eof()!=0) break;		

	}
	infile.close();
	//hero[y].InitData(choice,y);



}

/***********************************************************************
* 说明:     HeroList类调用初始化函数
* 输入参数: int unx——城市横坐标，int uny——城市纵坐标，
int uchoice——所选择历史时期
* 返回值  : 无
* 功能	   : 初始化HeroList类
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20       完成基本功能
***********************************************************************/
void HeroList::Init(int unx,int uny,int uchoice,int xuanze,int ownernum)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	this->ownernum=ownernum;
	statf=0;
	statf2=0;
	choice=uchoice;
	GetListStyle(xuanze);
	this->unx=unx;
	this->uny=uny;
	//ChangeOwnerNum(xuan);
	GetCityNum();	
	GetHeroNum();
	flagu=0;
	flagd=0;
	tmpfx=0;
	statbtp=statf;
	count=0;


}

/***********************************************************************
* 说明:     HeroList类显示函数
* 输入参数: 无
* 返回值  : 无
* 功能	   : 显示武将队列及属性
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20      完成基本功能
***********************************************************************/
void HeroList::Show(WPARAM KeyCode)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	if ((heronum==0&&listno==HEROOFTHISCITY)||(heronum==0&&listno==HEROOFOTHEREMPEROR)||(heronum==0&&listno==HEROANDEMPEROROFOTHER))
	{
		return;
	}
	if ((heronum==0||fulunum==0)&&listno==CAPTIVEOFTHISCITYADD)
	{
		return;
	}
	if (heronum==0&&fulunum==0&&listno==HEROANDCAPTIVEOFMYCITY)
	{
		return;
	}

	if (fulunum==0&&listno==CAPTIVEOFTHISCITY)
	{
		return;
	}

	if (ownedheronum==0&&listno==HEROOFMYALLCITY)
	{
		return;
	}

	//int heronu;
	heronu=heronum;
	if(listno==CAPTIVEOFTHISCITYADD&&zaoxiangflag==1||listno==CAPTIVEOFTHISCITY)
	{
		heronu=fulunum;
	}
	else if(listno==HEROANDCAPTIVEOFMYCITY)
	{
		heronu=heronum+fulunum;
	}
	else if(listno==HEROOFOTHEREMPEROR&&lijianflag==1)
	{
		heronu=otherwjnum;
	}
	else if(listno==HEROANDEMPEROROFOTHER&&quanxiangflag==1)
	{
		heronu=otherjznum;
	}
	else if(listno==HEROOFMYALLCITY)
	{
		heronu=ownedheronum;
	}

	int ux=3;
	int uy=(heronu>5?6:heronu);
	if(flagd==1&&KeyCode==KeyDown0)
	{
		statbtp++;
		tmpfx=uy-1;
		if(statbtp==(heronu-uy+2))statbtp=heronu-uy+1;

	}
	else if(flagu==1&&KeyCode==KeyUp0)
	{
		statbtp--;
		tmpfx=0;
		if(statbtp==-1)statbtp=0;

	}
	else if(flagd==1&&KeyCode==34)//20171006
	{
		statbtp+=6;
		tmpfx=uy-1;
		if(statbtp>=(heronu-uy+2))statbtp=heronu-uy+1;

	}
	else if(flagu==1&&KeyCode==33)//20171006
	{
		statbtp-=6;
		tmpfx=0;
		if(statbtp<=-1)statbtp=0;
	}
	else if(flagd==1&&KeyCode==KeyUp0)
	{
		flagd=0;
		tmpfx--;
	}
	else if(flagu==1&&KeyCode==KeyDown0)
	{
		flagu=0;
		tmpfx++;
	}
	else if(flagd==1&&KeyCode==33)//20171006
	{
		flagd=0;
	}
	else if(flagu==1&&KeyCode==34)//20171006
	{
		flagu=0;
	}
	else if(KeyCode==KeyUp0)
	{
		tmpfx--;
	}
	else if(KeyCode==KeyDown0)
	{
		tmpfx++;
	}
	if(tmpfx==(uy-1))flagd=1;
	if(tmpfx==0)flagu=1;

	InvalidateRect(hwnd,&rect,false);

	char str[20];

	MySetShowStyle();
	HPEN hpen=t_hpen;
	HPEN oldhpen=(HPEN)SelectObject(hdcTmp,hpen);

	HBRUSH hbrush = t_hbrush;
	HBRUSH hbrold = (HBRUSH)SelectObject(hdcTmp, hbrush); 

	Rectangle(hdcTmp,10,55,785,heronu>5?475:(heronu+1)*60+55); 	
	SelectObject(hdcTmp, hbrold); 
	DeleteObject(hbrush);
	SelectObject(hdcTmp,oldhpen);
	DeleteObject(hpen);
	
	int gb=statf; 

	if(listno==CAPTIVEOFTHISCITYADD&&zaoxiangflag==1||listno==CAPTIVEOFTHISCITY)
	{
		gb=gb+heronum;
	}
	else if(listno==HEROOFOTHEREMPEROR&&lijianflag==1)
	{
		gb=gb+heronum+fulunum+athomenum;
	}
	else if(listno==HEROANDEMPEROROFOTHER&&quanxiangflag==1)
	{
		gb=gb+heronum+fulunum+athomenum+otherwjnum;
	}
	else if(listno==HEROOFMYALLCITY)
	{
		gb=gb+heronum+fulunum+athomenum+otherwjnum+otherjznum;
	}
	int ga=gb;

	OverflowCheck(__FILE__,__LINE__,HEROMAX,ga);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,heroowned[ga]);

	if(statf2==0)
	{
		ShowText(GetStrText("ATRR_STR17"),40,60);
		ShowText(GetStrText("ATRR_STR18"),260,60);
		int tmp=(heronu>5?6:heronu);
		int h=0;

		for(int g=statf;g<tmp+statf;g++)
		{
			if(hero[heroowned[ga]].owner ==0)
			{
				break;
			}
			OverflowCheck(__FILE__,__LINE__,HEROMAX,heroowned[ga]);
			GetHeroName(ga);
			GetHeroBelongTo(hero[heroowned[ga]].owner);
			ShowText(heroname,15+(100-strlen(heroname)*25/2),120+60*h);
			ShowText(heroowner,245+(100-strlen(heroowner)*25/2),120+60*h);
			h++;
			ga++;
		}
	}
	else if(statf2==1)
	{
		ShowText(GetStrText("ATRR_STR17"),40,60);
		ShowText(GetStrText("ATRR_STR19"),260,60);
		ShowText(GetStrText("ATRR_STR20"),520,60);
		int tmp=(heronu>5?6:heronu);
		int h=0;
		for(int g=statf;g<statf+tmp;g++)
		{
			GetHeroCity(ga);
			ShowText(heroofcity,280,120+60*h);
			GetHeroName(ga);
			ShowText(heroname,15+(100-strlen(heroname)*25/2),120+60*h);
			sprintf_s(str,"%d",hero[heroowned[ga]].degree);
			ShowText(str,530,120+60*h);
			h++;
			ga++;
		}
	}
	else if(statf2==2)
	{
		ShowText(GetStrText("ATRR_STR17"),40,60);
		ShowText(GetStrText("ATRR_STR21"),240,60);
		ShowText(GetStrText("ATRR_STR22"),380,60);
		ShowText(GetStrText("ATRR_STR23"),520,60);
		ShowText(GetStrText("ATRR_STR24"),660,60);
		int tmp=(heronu>5?6:heronu);
		int h=0;
		for(int g=statf;g<statf+tmp;g++)
		{
			GetHeroName(ga);
			ShowText(heroname,15+(100-strlen(heroname)*25/2),120+60*h);
			sprintf_s(str,"%d",hero[heroowned[ga]].wuli);
			ShowText(str,260,120+60*h);
			sprintf_s(str,"%d",hero[heroowned[ga]].zili );
			ShowText(str,400,120+60*h);

			sprintf_s(str,"%d",hero[heroowned[ga]].heart );

			int w=0;
			for (int r=0;r<10;r++)
			{
				if((hero[heroowned[ga]].owner-1) !=hero[heroowned[ga]].no)goto start;
			}
			sprintf_s(str,"%s",GetStrText("ATRR_STR71"));
start:

			ShowText(str,540,120+60*h);
			sprintf_s(str,"%d",hero[heroowned[ga]].experience);
			ShowText(str,680,120+60*h);
			/*sprintf_s(str,"%d",hero[g+2].wuli);
			ShowText(str,260,120+60*h);
			sprintf_s(str,"%d",hero[g+2].zili );
			ShowText(str,400,120+60*g);
			sprintf_s(str,"%d",hero[g+2].heart );
			ShowText(str,540,120+60*g);
			sprintf_s(str,"%d",hero[g+2].experience);
			ShowText(str,680,120+60*g);*/
			h++;
			ga++;
		}
	}
	else if(statf2==3)
	{
		ShowText(GetStrText("ATRR_STR17"),40,60);
		ShowText(GetStrText("ATRR_STR25"),240,60);
		ShowText(GetStrText("ATRR_STR26"),400,60);
		ShowText(GetStrText("ATRR_STR27"),560,60);
		int tmp=(heronu>5?6:heronu);
		int h=0;
		for(int g=statf;g<statf+tmp;g++)
		{
			GetHeroName(ga);
			ShowText(heroname,15+(100-strlen(heroname)*25/2),120+60*h);
			sprintf_s(str,"%d",hero[heroowned[ga]].tili );
			ShowText(str,260,120+60*h);
			GetStyle(hero[heroowned[ga]].style);
			ShowText(style,400,120+60*h);
			sprintf_s(str,"%d",hero[heroowned[ga]].bingli );
			ShowText(str,580,120+60*h);
			h++;
			ga++;
		}
	}
	else if(statf2==4)
	{
		ShowText(GetStrText("ATRR_STR17"),40,60);
		ShowText(GetStrText("ATRR_STR28"),260,60);
		ShowText(GetStrText("ATRR_GOODS1"),480,60);
		int tmp=(heronu>5?6:heronu);
		int h=0;
		for(int g=statf;g<tmp+statf;g++)
		{
			GetHeroName(ga);
			ShowText(heroname,15+(100-strlen(heroname)*25/2),120+60*h);
			sprintf_s(str,"%d",hero[heroowned[ga]].age);
			ShowText(str,280,120+60*h);
			if(hero[heroowned[ga]].goods1!=0)
			{
				
				GetGoods(hero[heroowned[ga]].goods1,1);
				ShowText(goods1,480,120+60*h);
			}
			h++;
			ga++;
		}
	}
	else if(statf2==5)
	{
		ShowText(GetStrText("ATRR_STR17"),40,60);
		ShowText(GetStrText("ATRR_GOODS2"),300,60);
		int tmp=(heronu>5?6:heronu);
		int h=0;
		for(int g=statf;g<tmp+statf;g++)
		{
			GetHeroName(ga);
			ShowText(heroname,15+(100-strlen(heroname)*25/2),120+60*h);
			
			if(hero[heroowned[ga]].goods2!=0)
			{
				GetGoods(hero[heroowned[ga]].goods2,2);
				ShowText(goods2,300,120+60*h);
			}
			h++;
			ga++;
		}
	}
	BitBlt(hdcTmp,15,tmpfx*60+120,60*ux+20,50,hdcTmp,15,tmpfx*60+120,DSTINVERT);
	ShowCG(0,"Res\\cross.sbp",730,10);//20170206
}

/***********************************************************************
* 说明:     HeroList类按键处理函数
* 输入参数: 无
* 返回值  : 无
* 功能	   : 处理按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20      完成基本功能
***********************************************************************/
int HeroList::KeyDown(WPARAM KeyCode)//count statf内部值 tmpfx 
{
	wlogfile(1,__FUNCTION__,"开始",KeyCode);
	int heronu;
	heronu=heronum;

	if(listno==CAPTIVEOFTHISCITYADD&&zaoxiangflag==1||listno==CAPTIVEOFTHISCITY)
	{
		heronu=fulunum;
	}
	else if(listno==HEROANDCAPTIVEOFMYCITY)
	{
		heronu=heronum+fulunum;
	}
	else if(listno==HEROOFOTHEREMPEROR&&lijianflag==1)
	{
		heronu=otherwjnum;
	}
	else if(listno==HEROANDEMPEROROFOTHER&&quanxiangflag==1)
	{
		heronu=otherjznum;
	}
	else if(listno==HEROOFMYALLCITY)
	{
		heronu=ownedheronum;
	}

	if (heronu==0)
	{
		return 1;
	}
	int tmp=heronu-6;
	if (tmp<=0)statf=0;
	if(KeyCode==KeyDown0)
	{
		count++;
		if(count>5||count>heronu-1)
		{
			statf++;
			count--;
		}
		if(statf==tmp+1)statf=tmp;
		if (tmp<=0)statf=0;
		Show(KeyCode);
		return 0;
	}
	else if(KeyCode==KeyUp0)
	{
		count--;
		if(count<0)
		{
			statf--;
			count++;
		}
		if(statf==-1)statf=0;
		if (tmp<=0)statf=0;
		Show(KeyCode);
		return 0;
	}
	if(KeyCode==34)//20171006
	{
		statf+=6;
		if(statf>=tmp+1)
		{
			statf=tmp;
			//count = ((heronu-1)>5?5:(heronu-1));
		}
		if (tmp<=0)statf=0;
		Show(KeyCode);
		return 0;
	}
	else if(KeyCode==33)//20171006
	{
		statf-=6;
		if(statf<0)
		{
			statf=0;
			//count = 0;
		}
		if (tmp<=0)statf=0;
		Show(KeyCode);
		return 0;
	}
	else if(KeyCode==KeyReturn)
	{

		return 1;
	}
	else if(KeyCode==KeyEsc)
	{
		return -1;
	}
	else if(KeyCode==KeyRight0)
	{
		statf2++;
		if(statf2==6)statf2=5;
		Show(KeyCode);
		return 0;
	}
	else if(KeyCode==KeyLeft0)
	{
		statf2--;
		if(statf2==-1)statf2=0;
		Show(KeyCode);
		return 0;
	}
	else
	{
		return 0;
	}

}

/***********************************************************************
* 说明:     HeroList类获取武将函数
* 输入参数: char *name——历史时期文件名
* 返回值  : 无
* 功能	   : 获取武将
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20      完成基本功能
***********************************************************************/
/*void HeroList::GetOwner(char *name)
{
int j=0;
//ChangeRes(name);
ifstream infile(name,ios::in);
while(infile>>heronum)
{
int tmp,tmp2;
infile>>tmp;
int i=0;
while(i<heronum)
{

infile>>heroowned[i];
if(hero[heroowned[i]].inlistflag==false)
{
i--;
heronum--;
}
i++;
}
i=0;
while(i<tmp)
{

infile>>tmp2;
i++;
}
j++;
if((j-1)==number)break;

}
infile.close();
//ChangeRes(name);

}*/

/***********************************************************************
* 说明:     HeroList类获取武将函数
* 输入参数: 无
* 返回值  : 无
* 功能	   : 获取武将
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20      完成基本功能
***********************************************************************/
void HeroList::GetHeroNum()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	for(int gg=0;gg<HEROMAX;gg++)heroowned[gg]=0;
	int ii=0;
	heronum=0;
	fulunum=0;
	athomenum=0;
	otherwjnum=0;
	otherjznum=0;
	ownedheronum=0;
	for(int g=0;g<HEROMAX;g++)
	{
		if(hero[g].no < 0)continue;//20171210
		if((hero[g].hiscity-1)==number&&hero[g].owner!=0&&hero[g].owner<HEROMAX&&hero[g].inlistflag==1)//自己城市武将
		{
			heroowned[ii]=hero[g].no;
			heronum++;
			ii++;
		}
	}
	for(int g=0;g<HEROMAX;g++)
	{
		if(hero[g].no < 0)continue;//20171210
		if((hero[g].hiscity-1)==number&&hero[g].iscaptive == 1/*.owner>HEROMAX*/&&hero[g].inlistflag==1)//自己城市俘虏
		{
			heroowned[ii]=hero[g].no;
			fulunum++;
			ii++;
		}
	}
	for(int g=0;g<HEROMAX;g++)
	{
		if(hero[g].no < 0)continue;//20171210
		if((hero[g].hiscity-1)==number&&hero[g].owner==0)//自己城市在家武将
		{
			heroowned[ii]=hero[g].no;
			athomenum++;
			ii++;
		}
	}
	for(int g=0;g<HEROMAX;g++)
	{
		if(hero[g].no < 0)continue;//20171210
		if(hero[g].owner!=0&&hero[g].inlistflag==1)//其他非我方其他城市武将
		{
			if(hero[g].owner!=(hero[g].no+1)&&hero[g].owner!=ownernum&&hero[g].owner<HEROMAX)
			{
				heroowned[ii]=hero[g].no;
				otherwjnum++;
				ii++;
			}
		}
	}
	for(int g=0;g<HEROMAX;g++)
	{
		if(hero[g].no < 0)continue;//20171210
		if(hero[g].owner!=0&&hero[g].inlistflag==1)//其他君主
		{
			if(hero[g].owner==(hero[g].no+1)&&hero[g].owner!=ownernum)
			{
				heroowned[ii]=hero[g].no;
				otherjznum++;
				ii++;
			}
		}
	}
	for(int g=0;g<HEROMAX;g++)
	{
		if(hero[g].no < 0)continue;//20171210
		if(hero[g].owner==ownernum&&hero[g].inlistflag==1)//自己所有城市武将
		{
			heroowned[ii]=hero[g].no;
			ownedheronum++;
			ii++;
		}
	}
	/*if((hero[g].hiscity-1)==number&&hero[g].owner!=0&&hero[g].owner<100&&hero[g].inlistflag==true&&listno==0)//自己城市武将队列
	{
	heroowned[ii]=hero[g].no;
	heronum++;
	ii++;
	}
	else if((hero[g].hiscity-1)==number&&hero[g].owner>100&&hero[g].inlistflag==true&&listno==1)//自己城市俘虏队列
	{
	heroowned[ii]=hero[g].no;
	heronum++;
	ii++;
	}
	else if((hero[g].hiscity-1)==number&&hero[g].owner!=0&&&&hero[g].owner!=100hero[g].inlistflag==true&&listno==2)//自己城市武将+俘虏队列
	{
	heroowned[ii]=hero[g].no;
	heronum++;
	ii++;
	}
	else if(hero[g].owner!=0&&hero[g].inlistflag==true&&listno==3)//其他城市武将队列
	{
	if(hero[g].owner!=(hero[g].no+1)&&hero[g].owner!=ownernum)
	{
	heroowned[ii]=hero[g].no;
	heronum++;
	ii++;
	}
	}
	else if(hero[g].owner!=0&&hero[g].inlistflag==true&&listno==4)//其他城市君主队列
	{
	if(hero[g].owner==(hero[g].no+1)&&hero[g].owner!=ownernum)
	{
	heroowned[ii]=hero[g].no;
	heronum++;
	ii++;
	}
	}
	}*/



	/*for(int g=0;g<300;g++)heroowned[g]=0;
	switch(choice)
	{
	case DZNQ:
	GetOwner("Res\\Hero\\heroofcity1.sdt");
	break;
	case CCJQ:
	GetOwner("Res\\Hero\\heroofcity2.sdt");
	break;
	case CBZZ:
	GetOwner("Res\\Hero\\heroofcity3.sdt");			
	break;
	case SGDL:
	GetOwner("Res\\Hero\\heroofcity4.sdt");
	break;
	default:
	return;
	}
	return;*/
}

/***********************************************************************
* 说明:     HeroList类获取城市编号函数
* 输入参数: 无
* 返回值  : 无
* 功能	   : 获取城市编号
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20      完成基本功能
***********************************************************************/
void HeroList::GetCityNum()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	//ChangeRes(name);
	ifstream infile("Res\\City\\postion.sdt",ios::in);;
	int tmpx;
	int tmpy;
	int o=0;
	while(infile>>tmpx)
	{
		infile>>tmpy;
		o++;
		if(tmpx==unx&&tmpy==uny)
		{
			number=o-1;
			break;
		}

	}
	infile.close();	
	//ChangeRes(name);
}

/***********************************************************************
* 说明:     HeroList类获取武将姓名函数
* 输入参数: int g——武将序号
* 返回值  : 无
* 功能	   : 获取武将姓名
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20      完成基本功能
***********************************************************************/
void HeroList::GetHeroName(int g)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,g);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,heroowned[g]);
	sprintf_s(heroname,"%s",t_heroName[heroowned[g]]);

}

/***********************************************************************
* 说明:     HeroList类获取武将归属函数
* 输入参数: int g——武将序号
* 返回值  : 无
* 功能	   : 获取武将归属
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20      完成基本功能
***********************************************************************/
void HeroList::GetHeroBelongTo(int g)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	

	if(listno==CAPTIVEOFTHISCITYADD&&g>HEROMAX)
	{
		sprintf_s(heroowner,"%s",GetStrText("ATRR_STR69"));
	}
	else if(listno==HEROANDCAPTIVEOFMYCITY&&g>HEROMAX)
	{
		sprintf_s(heroowner,"%s",GetStrText("ATRR_STR69"));
	}
	else if(listno==CAPTIVEOFTHISCITY&&g>HEROMAX)
	{
		sprintf_s(heroowner,"%s",GetStrText("ATRR_STR69"));
	}
	else
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,g-1);
		sprintf_s(heroowner,"%s",t_heroName[g-1]);
	}

	for (int r=0;r<10;r++)
	{
		if(heroowner[r]!=heroname[r])return;
	}
	sprintf_s(heroowner,"%s",GetStrText("ATRR_STR68"));

}

/***********************************************************************
* 说明:     HeroList类获取武将城市函数
* 输入参数: 无
* 返回值  : 无
* 功能	   : 获取武将所在城市
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20      完成基本功能
***********************************************************************/
void HeroList::GetHeroCity(int g)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	
	//int k=uny*12+unx;
	OverflowCheck(__FILE__,__LINE__,HEROMAX,g);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,heroowned[g]);

	int k=hero[heroowned[g]].hiscity-1;
	OverflowCheck(__FILE__,__LINE__,CITYMAX,k);
	if(k >= 0)
	{
	
		sprintf_s(heroofcity,"%s",t_cityName[k]);
	}
	else
	{
		sprintf_s(heroofcity,"");
	}
	
}

/***********************************************************************
* 说明:     HeroList类获取武将兵种函数
* 输入参数: 无
* 返回值  : 无
* 功能	   : 获取武将兵种
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20      完成基本功能
***********************************************************************/
void HeroList::GetStyle(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);

	if (x==0)sprintf_s(style,"%s",GetStrText("ATRR_STR11"));
	else if (x==1)sprintf_s(style,"%s",GetStrText("ATRR_STR12"));
	else if (x==2)sprintf_s(style,"%s",GetStrText("ATRR_STR13"));
	else if (x==3)sprintf_s(style,"%s",GetStrText("ATRR_STR14"));
	else if (x==4)sprintf_s(style,"%s",GetStrText("ATRR_STR15"));
	else if (x==5)sprintf_s(style,"%s",GetStrText("ATRR_STR16"));

}

/***********************************************************************
* 说明:     HeroList类获取武将道具函数
* 输入参数: 无
* 返回值  : 无
* 功能	   : 获取武将道具
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20      完成基本功能
***********************************************************************/
void HeroList::GetGoods(int x,int id)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,GOODMAX,x-1);
	if(id== 1)sprintf_s(goods1,"%s",t_goodName[x-1]);
	if(id== 2)sprintf_s(goods2,"%s",t_goodName[x-1]);

}

/***********************************************************************
* 说明:     HeroList类删除英雄函数
* 输入参数: int g——编号,int y——用于区分不需要删除武将的指令
* 返回值  : 无
* 功能	   : 获取城市数量
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-28      完成基本功能
***********************************************************************/
void HeroList::DeleteHero(int g,int y)
{
	//y用于区分不需要删除武将的指令
	wlogfile(1,__FUNCTION__,"开始",0);
	if(listno==HEROOFTHISCITY)
	{
		heronum--;
		//if(g==heronum)
		for(int r=g;r<(HEROMAX-1);r++)
		{
			heroowned[r]=heroowned[r+1];
		}
	}
	if(listno==HEROOFMYALLCITY)
	{
		//ownedheronum--;
		heronum--;
		//if(g==heronum)
		for(int r=g;r<(HEROMAX-1);r++)
		{
			heroowned[r]=heroowned[r+1];
		}
	}
}

void HeroList::GetListStyle(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	switch(x)
	{
	case 0:
	case RECLAIM:
	case INVESTMENT:
	case SEARCH:
	case GOVERN:
	case TOUR:
	case AWARD:
	case CONFISCATE:
	case TRADE:
	case BANQUET:
	case TRANSPORT:
	case MOVE:
	case SCOUT:
	case CONSCRIPTION:
	case ALLOCATION:
	case PLUNDER:
	case EXPEDITION:
	case DEFENSE:
		listno=HEROOFTHISCITY;//自己城市武将队列
		break;
	case SURRENDER:
		listno=CAPTIVEOFTHISCITYADD;//（自己城市武将队列后显示）自己城市俘虏队列
		break;
	case BEHEAD:
		listno=CAPTIVEOFTHISCITY;//自己城市俘虏队列
		break;
	case EXILE:
		listno=HEROANDCAPTIVEOFMYCITY;//自己城市武将+俘虏队列
		break;
	case ALIENATE:
	case SOLICIT:
	case INSTIGATION:
		listno=HEROOFOTHEREMPEROR;//（自己城市武将队列后显示）其他城市武将队列（不含君主）
		break;
	case ANTI:
		//反间;
		break;
	case CAPITULATE:
		listno=HEROANDEMPEROROFOTHER;//（自己城市武将队列后显示）其他君主队列
		break;
	case NEWEMPEROR:
		listno=HEROOFMYALLCITY;//自己所有武将队列
		break;
	}
	listno=listno;
}

/*void HeroList::ChangeOwnerNum(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	if(choice==0)
	{

		switch (x)
		{
		case 0:
			ownernum=6;
			break;
		case 1:
			ownernum=17;
			break;
		case 2:
			ownernum=18;
			break;
		case 3:
			ownernum=10;
			break;
		case 4:
			ownernum=14;
			break;
		case 5:
			ownernum=3;
			break;
		case 6:
			ownernum=8;
			break;
		case 7:
			ownernum=12;
			break;
		case 8:
			ownernum=1;
			break;
		case 9:
			ownernum=11;
			break;
		case 10:
			ownernum=2;
			break;
		case 11:
			ownernum=7;
			break;
		case 12:
			ownernum=19;
			break;
		case 13:
			ownernum=9;
			break;
		case 14:
			ownernum=4;
			break;
		case 15:
			ownernum=16;
			break;
		case 16:
			ownernum=15;
			break;
		case 17:
			ownernum=5;
			break;
		}
	}
}*/

void HeroList::ClearInListFlag()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	for(int y=0;y<HEROMAX;y++)
	{
		hero[y].inlistflag=1;
	}

}

