/***********************************************************************
*Copyright (c)2012 , 天际边工作室
*All rights reserved.
**
文件名称：	GameMap.cpp
*摘要：		游戏主地图类
**
*修改历史：
*	版本    日期     作者     改动内容和原因
*   ----------------------------------------------------
*	1.0    2012-10-5  wstjb     基本的功能完成
***********************************************************************/

#include "GameMap.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "Dialog.h" 
using namespace std;

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 HINSTANCE hInst;
extern  int color;
extern  int flag;
extern  char texta[TEXTAMAX][20];

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 char t_heroName[HEROMAX][HERONAMEMAXLEN]; 
extern char t_skillName[SKILLMAX][SKILLNAMEMAXLEN];
extern char t_goodName[GOODMAX][GOODNAMEMAXLEN];
extern char t_cityName[CITYMAX][CITYNAMEMAXLEN];
extern HFONT t_h;
extern HPEN t_hpen;
extern HBRUSH t_hbrush;

int swFlag=0;//君主死亡标志
int zaoxiangflag=0;
int quanxiangflag=0;
int lijianflag=0;
int daojuflag=0;
int citychooseflag=0;
int operateflag=0;
int outflag=0;
int zujiang=0;
int my_zujiang=0;
int tasknum=0;
int tmp0[4];
int fgttmpzj=0;
int fg=0;
int warherono[10];
int warherononum=0;
int asdsad[10];
int adasdsadd=0;
int warinflag=0;//进入战争的flag,用于确认有几次war
int reqcitynum=0,reqcityto=0,reqresult=0;
int captiveflag=0;
int fighttodeathflag=0;
int endthisflag=0;//君主遭劫
int newownerflag=0;
int warlistflag=0;//防守时选择武将标志
int tmpflag=0;//防守战已触发。
int my_unx;
int my_uny;
int new_flag=0;
int warcomedonothingflag = 0;
int tasklistinuse = 0;
int highAtk = 0;//150509
int alwaysSave = 0;//170512
int network = 0;//170512

int tempFlagForCap=0;//用于测试武将俘虏问题
int tempFlagForWar=0;//用于测试战斗错误问题

int saveTemp = 0;

/***********************************************************************
* 说明:     GameMap类初始化函数
* 输入参数: int num——用于设定君主等信息，由君主选择传值过来
* 返回值  : 无
* 功能	   : 初始化
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void GameMap::InitMap(int num,int uchoice)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	choice=uchoice;
	statc=0;
	//unx=0;//小矩阵x
	//uny=0;//小矩阵y
	unum=num;
	ArrowSet();
	//arrowx=12;//箭头x
	//arrowy=35;//箭头y
	//zbx=0;//地图显示左上角坐标x
	//zby=0;//地图显示左上角坐标y
	flagl=0;
	flagr=0;
	flagu=0;
	flagd=0;
	flagmap1=0;
	flagmap2=0;
	flagmap11=0;
	flagmap12=0;
	flagmap13=0;
	ngsecond1=0;
	ngsecond2=0;
	ngthird1=0;
	ngthird2=0;
	ngthird3=0;
	ngthird4=0;
	flagwar=0;
	ngsave=0;
	//escmenu=new Menu();
	//citymenu=new Menu();
	//secondmenu1=new Menu();
	//secondmenu2=new Menu();
	//secondmenu3=new Menu();
	//head=new Head();
	//date=new Date();
	date.Init(choice);
	//country=new Country();
	//citylist=new CityList();
	citylist.PubInit(choice);
	//herolist=new HeroList();
	herolist.PubInit(choice);
	//goodlist=new GoodList();
	goodlist.PubInit(choice);
	//operate=new Operate();
	citynumber=country.GetCityNum(unum,choice);
	heronumber=country.GetHeroNum(unum,choice);
	for(int y=0;y<TASKLISTMAX;y++)
	{
		//tasklist[y]=new TaskList();
		tasklist[y].Init();
	}
	ChangeOwnerNum();
	//hero.GetHero(unum);
	//save=new Save();
	save.choice = choice;
	save.Init(ownernum,date.year);
	//fight=new Fight();
	fight.PubInit(choice);
	SetForce();
	my_warherononum=0;
	
	InitSSS(choice);
	InitTileInfo();
	//InitMoveCal();

}

/***********************************************************************
* 说明:     GameMap类显示函数
* 输入参数: WPARAM KeyCode——按键信息，用于控制地图移动与对应的显示
* 返回值  : 无
* 功能	   : 显示地图及相关界面
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void GameMap::Show(WPARAM KeyCode)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	if(KeyCode==-100)
	{
		ShowCG(0,"Res\\black.sbp",0,480);
		ShowCG(0,"Res\\black.sbp",0,-480);
		ShowCG(0,"Res\\kuang.sbp",0,0);
		LoadPic("Res\\way.sbp",hbmp);	//封装完成		
		HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);			
		BitBlt(hdcTmp,200,120,800,600,hdcMem,0,0,SRCCOPY);
		SelectObject(hdcMem, oldhbmp);
		DeleteObject(hbmp);
		InvalidateRect(hwnd,NULL,false);	
		return;
	}
	LoadPic("Res//map.sbp",hbmp);	//封装完成			
	HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);			
	BitBlt(hdcTmp,0,0,800,600,hdcMem,0,0,SRCCOPY);
	SelectObject(hdcMem, oldhbmp);
	DeleteObject(hbmp);

	if(flagr==1&&KeyCode==KeyRight0)
	{
		zbx=zbx+90;
		arrowx=720-78;
		if(zbx>360)zbx=360;
	}
	else if(flagl==1&&KeyCode==KeyLeft0)
	{
		zbx=zbx-90;
		arrowx=12;
		if(zbx<0)zbx=0;
	}

	else if(flagr==1&&KeyCode==KeyLeft0)
	{
		flagr=0;
		arrowx=arrowx-90;
	}
	else if(flagl==1&&KeyCode==KeyRight0)
	{
		flagl=0;
		arrowx=arrowx+90;
	}
	else if(KeyCode==KeyLeft0)
	{
		arrowx=arrowx-90;
	}
	else if(KeyCode==KeyRight0)
	{
		arrowx=arrowx+90;
	}
	if(arrowx==720-78)flagr=1;
	if(arrowx==12)flagl=1;


	if(flagd==1&&KeyCode==KeyDown0)
	{
		zby=zby+80;
		arrowy=480-45;
		if(zby>240)zby=240;
	}
	else if(flagu==1&&KeyCode==KeyUp0)
	{
		zby=zby-80;
		arrowy=35;
		if(zby<0)zby=0;
	}

	else if(flagd==1&&KeyCode==KeyUp0)
	{
		flagd=0;
		arrowy=arrowy-80;
	}
	else if(flagu==1&&KeyCode==KeyDown0)
	{
		flagu=0;
		arrowy=arrowy+80;
	}
	else if(KeyCode==KeyUp0)
	{
		arrowy=arrowy-80;
	}
	else if(KeyCode==KeyDown0)
	{
		arrowy=arrowy+80;
	}
	if(arrowy==480-45)flagd=1;
	if(arrowy==35)flagu=1;

	LoadPic("Res//map.sbp",hbmp2);	//封装完成			
	HBITMAP oldhbmp2=(HBITMAP)SelectObject(hdcMem, hbmp2);			

	if(KeyCode==-200)
	{
		BitBlt(hdc, 295, 95, 250, 190, hdcMem, zbx+295, zby+45, SRCCOPY);
		ShowCityIcon(1);
	}
	else
	{
		BitBlt(hdcTmp, 0, 50, 1120, 750, hdcMem, zbx, zby, SRCCOPY);
		ShowCityIcon(0);
	}

	SelectObject(hdcMem, oldhbmp2);
	DeleteObject(hbmp2);

	//hbmp=(HBITMAP)SelectObject(hdcMem, oldhbmp);
	//DeleteObject(hbmp);

	ShowCGAdd(0,"Res\\arrow.sbp","Res\\arrowmask.sbp",arrowx,arrowy);
	ShowCG(0,"Res\\black.sbp",0,480);
	ShowCG(0,"Res\\black.sbp",0,-480);
	ShowCG(0,"Res\\right.sbp",680,0);
	ShowCG(0,"Res\\menu.sbp",MAINMENUX,MAINMENUY);
	ShowCGAdd(0,"Res\\leftarrow.sbp","Res\\leftarrowmask.sbp",MAINLEFTARROWX,MAINLEFTARROWY);
	ShowCGAdd(0,"Res\\rightarrow.sbp","Res\\rightarrowmask.sbp",MAINRIGHTARROWX,MAINRIGHTARROWY);
	ShowCGAdd(0,"Res\\uparrow.sbp","Res\\uparrowmask.sbp",MAINUPARROWX,MAINUPARROWY);
	ShowCGAdd(0,"Res\\downarrow.sbp","Res\\downarrowmask.sbp",MAINDOWNARROWX,MAINDOWNARROWY);
	date.ShowYear(690,300);
	date.ShowMonth(690,350);
	switch(choice)
	{
	case DZNQ:
		head.Init("Res\\Head\\1dznq.sbp",ownernum-1);
		break;
	case CCJQ:
		head.Init("Res\\Head\\2ccjq.sbp",ownernum-1);
		break;
	case CBZZ:
		head.Init("Res\\Head\\3cbzz.sbp",ownernum-1);
		break;
	case SGDL:
		head.Init("Res\\Head\\4sgdl.sbp",ownernum-1);
		break;
	default:
		{
			char name[NORMALSTRLEN];
			sprintf_s(name,"Res\\Head\\period%d.sbp",choice+1);
			head.Init(name,ownernum-1);
		}
		break;
	}
	head.Show();
	GetCityName();
	if(IsCity()==1)
	{
		//herolist.Init(unx,uny,choice,0,unum);
		GetCityPrefect();
	}
	char tmp[20];
	sprintf_s(tmp,"%d",citynumber);
	MyCreateFont(0.9);
	HFONT	h = t_h;
	HFONT oldh=(HFONT)SelectObject(hdcTmp,h);
	MySetTextColor(FONTA,USEHDCTMP);

	TextOut(hdcTmp,735,185,tmp,strlen(tmp));
	sprintf_s(tmp,"%d",heronumber);
	TextOut(hdcTmp,733,235,tmp,strlen(tmp));

	HBITMAP oldhbmp1=(HBITMAP)SelectObject(hdcTmp,oldh);
	SetTextColor(hdcTmp,RGB(0, 0, 0));
	DeleteObject(h);

	citylist.Init(unx,uny,choice);
	InvalidateRect(hwnd,&rect,false);
	SelectObject(hdcTmp, oldhbmp1);
	DeleteObject(hbmp);
	//ChangeOwnerNum();
	//Show(0);
	//Delay(100);

}

/***********************************************************************
* 说明:     GameMap类按键处理-被攻击时选择武将功能
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::SelectHeroForDefense(WPARAM KeyCode)
{
	//herolist.Init(3,2,choice,26,ownernum);
	Show(0);
	herolist.Show(0);
	int flagmap26=herolist.KeyDown(KeyCode);
	if(flagmap26==-1&&outflag>0)
	{
		warlistflag=2;
		Show(0);			
		tmp0[1]=outflag;
		outflag=0;
		DoEndEvent();
	}
	else if(flagmap26==-1)
	{
		//战斗失败
		warcomedonothingflag = 1 ;//防守战未抵抗
		reqresult=-1;
		warinflag--;
		if(warinflag==0)warinflag=-1;
		warlistflag=0;
		fight.GameEnd(0);
		//20150502增加对战败处理
		OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,tasklistinuse);
		int ai_heronum=tasklist[tasklistinuse].heronum-1;
		int ai_heroamount=tasklist[tasklistinuse].data[2];
		int ai_citynum=tasklist[tasklistinuse].citynum-1;
		int my_cityto=tasklist[tasklistinuse].data[0]-1;
		OverflowCheck(__FILE__,__LINE__,CITYMAX,my_cityto);
		int ai_zujiangnum=tasklist[tasklistinuse].data[3];
		int ai_foodamount=tasklist[tasklistinuse].data[1];
		int my_heronumto=citylist.city[my_cityto].owner-1;
		int my_foodamount=citylist.city[my_cityto].foods;

		fight.citynumfrom=ai_citynum+1;
		fight.InitData(my_warherononum+1,my_zujiang,my_cityto,my_foodamount);//+1为增加主将
		//武将数目、主将编号、所攻打城市编号、粮食(我方)
		fight.heronumberto=ai_heroamount;
		


		fight.fighthero[0].num=my_zujiang;
		//fight.heronumberto++;
		for(int yu=1;yu<my_warherononum+1;yu++)
		{
			OverflowCheck(__FILE__,__LINE__,10,yu-1);
			fight.fighthero[yu].num=my_warherono[yu-1];
		}
		
		for(int uu=my_warherononum+1;uu<10;uu++)
		{
			OverflowCheck(__FILE__,__LINE__,10,uu);
			fight.fighthero[uu].num=-1;
		}
		//fight.heronumberto;//敌方武将数目
		fight.zujiangto=ai_zujiangnum;//敌方主将
		fight.owner=my_heronumto;
		fight.ownerto=ai_heronum+1;
		fight.foodsto=ai_foodamount;
		fight.allbingli=0;
		fight.allbinglito=0;

		SetFightHeroData2(tasklistinuse);
		tasklistinuse = 0;



		fight.warstyle =1;
		AfterWar(reqresult,reqcitynum,reqcityto);
		reqresult=0;
		captiveflag=0;
		endthisflag=0;

		DoEndEvent();
	}
	else if(flagmap26==1)
	{
		int xuan26=herolist.count+herolist.statf;//xuana城市武将队列中武将编号	
		OverflowCheck(__FILE__,__LINE__,HEROMAX,xuan26);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[xuan26]);
		int select=herolist.hero[herolist.heroowned[xuan26]].no;
		OverflowCheck(__FILE__,__LINE__,HEROMAX,select);
		if (herolist.hero[select].tili<8)
		{
			/*金钱不足*/
			Message("该将体力不足",0,300,15,1);
			Show(0);
			herolist.Show(0);
			return 0;
		}
		if(outflag==0)
		{
			my_warherononum = 0;
			my_zujiang=select;
			for(int i=0;i<10;i++)my_warherono[i]=-1;
			if(fight.warstyle==0)//进攻战 20161216
			{
				herolist.hero[my_zujiang].inlistflag=2;
			}
			else
			{
				herolist.hero[my_zujiang].inlistflag=11;
			}
		}
		else if(outflag<10)//20161216增加条件
		{
			OverflowCheck(__FILE__,__LINE__,10,my_warherononum);
			my_warherono[my_warherononum]=select;
			my_warherononum++;
			if(fight.warstyle==0)//20161216
			{
				herolist.hero[select].inlistflag=2;
			}
			else
			{
				herolist.hero[select].inlistflag=11;
			}
		}
		//SendMessage(hwnd,WM_KEYDOWN,0,VK_RETURN);
		herolist.Init(my_unx,my_uny,choice,26,ownernum);		
		//herolist.DeleteHero(xuan26,0);
		Show(0);
		herolist.Show(0);

		outflag++;

		if(outflag==11||herolist.heronum==0)
		{
			if(fight.warstyle==1)//防守 20161216
			{
				for(int iq=0;iq<HEROMAX;iq++)
				{
					if(herolist.hero[iq].inlistflag==11)herolist.hero[iq].inlistflag=1;
				}
			}
			warlistflag=2;
			Show(0);
			tmp0[1]=outflag;
			outflag=0;
			DoEndEvent();
			return 0;
		}	
		//Show(0);
		return 0;
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-战败更换主公
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::ChangeOwner(WPARAM KeyCode)
{
	int flagmap25=herolist.KeyDown(KeyCode);
	if(flagmap25==-1)
	{
		Show(0);
		herolist.Show(0);
		return 0;
	}
	else if(flagmap25==1)
	{

		int xuan25=herolist.count+herolist.statf;//xuana城市武将队列中武将编号	
		xuan25=xuan25+herolist.heronum+herolist.fulunum+herolist.athomenum+herolist.otherwjnum+herolist.otherjznum	;
		OverflowCheck(__FILE__,__LINE__,HEROMAX,xuan25);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[xuan25]);
		
		int select=herolist.hero[herolist.heroowned[xuan25]].no+1;
		
		//select

		//处理城池变更主公
		for(int ko=0;ko<CITYMAX;ko++)
		{
			if(citylist.city[ko].owner==ownernum)
				citylist.city[ko].owner=select;
		}
		//处理武将变更主公
		for(int ko=0;ko<HEROMAX;ko++)
		{
			if(herolist.hero[ko].owner==ownernum)
				herolist.hero[ko].owner=select;
		}
		char str[NORMALSTRLEN];
		OverflowCheck(__FILE__,__LINE__,HEROMAX,select-1);
		sprintf_s(str,"%s",t_heroName[select-1]);
		TimerMessage(str,GetStrText("STR_BEKING"),50,280,12,1,1000);
		Show(0);
		if(swFlag==0)
		{
			newownerflag=2;
			ownernum=select;
			DoEndEvent();
			return 0;
		}
		else
		{
			newownerflag=0;
			ownernum=select;
			swFlag=0;
			return 0;
		}
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-菜单第三层-数目选择框按键功能
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::DelOperateList(WPARAM KeyCode)
{
	int flagmap04=operate.KeyDown(KeyCode);
	if(flagmap04==-1)
	{
		if(operateflag==1)
		{
			operateflag=0;
			ngthird4=0;
			ngthird1=21;
			daojuflag=0;
			Show(0);
			herolist.Show(0);
			return 0;
		}
		else if(operateflag==9)
		{
			operateflag=0;
			ngthird4=0;
			ngthird1=22;
			daojuflag=0;
			Show(0);
			herolist.Show(0);
			return 0;
		}
		else if(operateflag==2)
		{
			operateflag=0;
			ngthird4=0;
			ngthird1=11;
			daojuflag=0;
			Show(0);
			herolist.Show(0);
			return 0;
		}
		else if(operateflag==3)
		{
			operateflag=0;
			ngthird4=0;
			ngthird1=13;
			daojuflag=0;
			Show(0);
			herolist.Show(0);
			return 0;
		}
		else if(operateflag==4)
		{
			operateflag=3;
			Show(0);
			herolist.Show(0);
			OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
			operate.Init(2,citylist.city[citylist.number].money);
			operate.Show();
			return 0;
		}
		else if(operateflag==5)
		{
			operateflag=4;
			Show(0);
			herolist.Show(0);
			OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
			operate.Init(3,citylist.city[citylist.number].foods);
			operate.Show();
			return 0;
		}
		else if(operateflag==6)
		{
			operateflag=2;
			Show(0);
			herolist.Show(0);
			operate.Init(-1,0);
			operate.Show();
			return 0;
		}
		else if(operateflag==8)
		{
			operateflag=2;
			Show(0);
			herolist.Show(0);
			operate.Init(-1,0);
			operate.Show();
			return 0;
		}
		else if(operateflag==7)
		{
			operateflag=0;
			Show(0);
			ngthird4=0;
			ngthird1=0;
			ngc=0;
			flag=4;
			ngsecond1=0;
			/*herolist.hero[zujiang].inlistflag=1;

			for(int i=0;i<9;i++)
			{
			if(warherono[i]==-1)continue;
			herolist.hero[warherono[i]].inlistflag=1;
			warherono[i]=-1;
			}*/
			for(int i=0;i<HEROMAX;i++)
			{
				if(herolist.hero[i].inlistflag==2)
					herolist.hero[i].inlistflag=1;
			}
			warherononum=0;
			return 0;
		}

	}
	else if(flagmap04>9)
	{
		flagmap04=flagmap04-10;
		OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
		if(operateflag==1)//征兵
		{
			operateflag=0;
			ngthird4=0;

			int consume=(int)(flagmap04/10);//消耗的金钱；
			int receive=flagmap04;//获得的士兵
			int tp=herolist.count+herolist.statf;
			OverflowCheck(__FILE__,__LINE__,HEROMAX,tp);
			OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[tp]);
			herolist.hero[herolist.heroowned[tp]].tili=herolist.hero[herolist.heroowned[tp]].tili-12;
			citylist.city[citylist.number].money =citylist.city[citylist.number].money-consume;
			citylist.city[citylist.number].soldierspace =citylist.city[citylist.number].soldierspace+receive;
			citylist.city[citylist.number].people =citylist.city[citylist.number].people-receive;
			herolist.hero[herolist.heroowned[tp]].inlistflag=0;
			herolist.Init(unx,uny,choice,ngthird1,ownernum);		
			Show(0);
			herolist.Show(0);
			return 0;
		}
		else if(operateflag==9)//分配
		{
			operateflag=0;
			ngthird4=0;

			int receive=flagmap04;//获得的士兵
			int tp=herolist.count+herolist.statf;
			OverflowCheck(__FILE__,__LINE__,HEROMAX,tp);
			OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[tp]);
			int oldbl=herolist.hero[herolist.heroowned[tp]].bingli;
			citylist.city[citylist.number].soldierspace  =citylist.city[citylist.number].soldierspace-receive+oldbl;
			herolist.hero[herolist.heroowned[tp]].bingli=receive;
			Show(0);
			herolist.Show(0);
			return 0;
		}
		else if(operateflag==2)//买入卖出选项
		{
			herolist.Show(0);
			if(flagmap04==0)//进入选项：买入
			{					
				operate.Init(-1,0);
				operate.Show();
				operate.Init(3,(int)(citylist.city[citylist.number].money/5));
				operateflag=6;
			}
			else//进入选项：卖出
			{
				operate.Init(-1,1);
				operate.Show();
				operate.Init(3,citylist.city[citylist.number].foods);
				operateflag=8;
			}
			operate.Show();
			return 0;
		}
		else if(operateflag==3)//剩余3次
		{
			operateflag=4;//剩余2次
			herolist.Show(0);
			operate.Init(3,citylist.city[citylist.number].foods);
			operate.Show();
			tmp0[0]=flagmap04;
			return 0;
		}
		else if(operateflag==4)
		{
			operateflag=5;//剩余1次
			herolist.Show(0);
			operate.Init(1,citylist.city[citylist.number].soldierspace);
			operate.Show();
			tmp0[1]=flagmap04;
			return 0;
		}
		else if(operateflag==5)
		{
			int xuanc=herolist.count+herolist.statf;//xuanc城市武将队列中武将编号	
			int kc=GetOrder(xuanc);
			ngthird4=0;
			ngthird1=0;
			ngc=0;
			flag=4;
			ngsecond1=0;
			daojuflag=0;
			tmp0[2]=flagmap04;
			if(kc==0)return 0;
			else if(kc==-2)
			{
				ngc=0;
				flag=4;
				ngthird1=0;
				ngsecond1=0;
				ngthird3=0;
				flagx=0;
				SendMessage(hwnd,WM_KEYDOWN,0,KeyEsc);
				//Show(0);
			}

			return 0;
		}
		else if(operateflag==6)//买入处理
		{
			ngthird4=0;
			ngthird1=0;
			ngc=0;
			flag=4;
			ngsecond1=0;
			daojuflag=0;
			Show(0);

			int consume=flagmap04*5;//消耗的金钱；
			int receive=flagmap04;//获得的粮食
			int tp=herolist.count+herolist.statf;
			OverflowCheck(__FILE__,__LINE__,HEROMAX,tp);
			OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[tp]);
			herolist.hero[herolist.heroowned[tp]].tili=herolist.hero[herolist.heroowned[tp]].tili-12;
			citylist.city[citylist.number].money =citylist.city[citylist.number].money-consume;
			citylist.city[citylist.number].foods =citylist.city[citylist.number].foods+receive;
			herolist.hero[herolist.heroowned[tp]].inlistflag=0;
			return 0;
		}
		else if(operateflag==8)//卖出处理
		{
			ngthird4=0;
			ngthird1=0;
			ngc=0;
			flag=4;
			ngsecond1=0;
			daojuflag=0;
			Show(0);

			int consume=flagmap04;//消耗的粮食；
			int receive=flagmap04*2;//获得的金钱
			int tp=herolist.count+herolist.statf;
			OverflowCheck(__FILE__,__LINE__,HEROMAX,tp);
			OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[tp]);
			herolist.hero[herolist.heroowned[tp]].tili=herolist.hero[herolist.heroowned[tp]].tili-12;
			citylist.city[citylist.number].money =citylist.city[citylist.number].money+receive;
			citylist.city[citylist.number].foods =citylist.city[citylist.number].foods-consume;
			herolist.hero[herolist.heroowned[tp]].inlistflag=0;
			return 0;
		}
		else if(operateflag==7)//出征选择粮食
		{
			int consume=flagmap04;//消耗的粮食；
			ngthird4=0;
			ngthird1=0;
			ngc=0;
			flag=4;
			ngsecond1=0;
			daojuflag=0;
			Show(0);
			citychooseflag=4;
			ngthird1=24;
			ShowIt(0,0,zujiang);
			ngthird1=0;
			operateflag=0;
			tmp0[0]=flagmap04;
			citylist.city[citylist.number].foods-=consume;
			return 0;
		}
		/*else if(kc==-2)
		{
		ngc=0;
		flag=4;
		ngsecond1=0;
		ngthird4=0;
		flagx=0;
		SendMessage(hwnd,WM_KEYDOWN,0,VK_ESCAPE);
		//Show(0);
		}
		return;*/
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-菜单第三层-道具列表操作
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::DelGoodList(WPARAM KeyCode)
{
	int flagmap03=goodlist.KeyDown(KeyCode);
	if(flagmap03==-1)
	{
		ngc=0;
		flag=4;
		ngthird3=0;
		ngthird1=0;
		ngsecond1=0;
		daojuflag=0;
		Show(0);
		return 0;
	}
	else if(flagmap03==1)
	{

		int xuanb=goodlist.count+goodlist.statf;//xuanb城市道具队列中道具编号		
		int kb=GetOrder(xuanb);
		//flagx=1;
		if(kb==-2)
		{
			ngc=0;
			flag=4;
			ngthird1=0;
			ngsecond1=0;
			ngthird3=0;
			flagx=0;
			SendMessage(hwnd,WM_KEYDOWN,0,KeyEsc);
			//Show(0);
		}
		return 0;
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-菜单第三层-武将列表操作-第二次
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::ExecHeroList_Twice(WPARAM KeyCode)
{
	int flagmap02=herolist.KeyDown(KeyCode);
	if(flagmap02==-1)
	{
		ngc=0;
		flag=4;
		ngthird2=0;
		ngthird1=0;
		ngsecond1=0;
		zaoxiangflag=0;
		quanxiangflag=0;
		lijianflag=0;
		Show(0);
		return 0;
	}
	else if(flagmap02==1)
	{

		int xuana=herolist.count+herolist.statf;//xuana城市武将队列中武将编号		
		int ka=GetOrder(xuana);
		//flagx=1;

		if(ka==0)herolist.DeleteHero(xuana,0);
		else if(ka==-2)
		{
			ngc=0;
			flag=4;
			ngthird1=0;
			ngsecond1=0;
			ngthird2=0;
			flagx=0;
			SendMessage(hwnd,WM_KEYDOWN,0,KeyEsc);
			//Show(0);
		}
		return 0;
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-菜单第三层-武将列表操作-第1次
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::ExecHeroList_Once(WPARAM KeyCode)
{


	int flagmap01=herolist.KeyDown(KeyCode);

	if(flagmap01==-1&&ngthird1==24&&outflag>0)
	{
		ngthird4=1;
		ngthird1=0;
		Show(0);
		herolist.Show(0);
		OverflowCheck(__FILE__,__LINE__,CITYMAX,currentcitynum-1);
		operate.Init(3,citylist.city[currentcitynum-1].foods);
		operate.current=1;
		operate.Show();
		flagx=0;
		operateflag=7;

		tmp0[1]=outflag;
		outflag=0;
	}
	else if(flagmap01==-1)
	{
		ngc=0;
		flag=4;
		ngthird1=0;
		ngsecond1=0;
		Show(0);
		return 0;
	}
	else if(flagmap01==1)
	{

		int xuan=herolist.count+herolist.statf;//xuan城市武将队列中武将编号		
		OverflowCheck(__FILE__,__LINE__,HEROMAX,xuan);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[xuan]);
		int k=GetOrder(xuan);
		flagx=1;
		//Show(0);
		if(k==0){;}//herolist.DeleteHero(xuan,0);
		else if(k==-2)
		{
			ngc=0;
			flag=4;
			ngthird1=0;
			ngsecond1=0;
			flagx=0;
			SendMessage(hwnd,WM_KEYDOWN,0,KeyEsc);
			//new_flag=0;
			//Show(0);

		}
		else if(k==1)//显示第二次列表的情况
		{
			ngthird2=1;
			herolist.Init(unx,uny,choice,ngthird1,ownernum);
			SendMessage(hwnd,WM_KEYDOWN,0,0);
			//flagx=0;
		}
		else if(k==2)//显示道具列表的情况
		{
			ngthird3=1;
			flagx=0;
		}
		else if(k==3)//显示操作框情况
		{
			ngthird4=1;
			flagx=0;
		}
		else if(k==4)//出征 显示10次
		{
			ngthird1=24;
			OverflowCheck(__FILE__,__LINE__,CITYMAX,currentcitynum-1);
			tmp0[3]=citylist.city[currentcitynum-1].foods;
			
			herolist.hero[herolist.heroowned[xuan]].inlistflag=2;
			if(outflag>1)
			{
				warherono[warherononum]=herolist.heroowned[xuan];
				warherononum++;
			}
			herolist.Init(unx,uny,choice,ngthird1,ownernum);		
			herolist.Show(0);

			SendMessage(hwnd,WM_KEYDOWN,0,KeyReturn);

		}
		else if(k==5)//出征选定后
		{
			herolist.hero[herolist.heroowned[xuan]].inlistflag=2;
			OverflowCheck(__FILE__,__LINE__,10,warherononum);
			warherono[warherononum]=herolist.heroowned[xuan];
			warherononum++;
			ngthird4=1;
			ngthird1=0;
			Show(0);
			//herolist.DeleteHero(xuan,0);
			//herolist.Show(0);	

			//herolist.hero[herolist.heroowned[xuan]].inlistflag=2;
			OverflowCheck(__FILE__,__LINE__,CITYMAX,currentcitynum-1);
			operate.Init(3,citylist.city[currentcitynum-1].foods);
			operate.current=1;
			operate.Show();
			flagx=0;
			operateflag=7;


		}
		//Show(0);
		//herolist.Show(0);
		return 0;
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-菜单=武将列表操作 内政调用
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::DelHeroList_Interior(WPARAM KeyCode)
{
	flagmap11=secondmenu1.KeyDown(KeyCode);
	if (flagmap11==-1)
	{
		flag=6;
		ngsecond1=0;
		Show(0);
		citymenu.Show(0);
		return 0;
	}
	else if(flagmap11==1)
	{
		ngthird1=(secondmenu1.statb)+1;
		//switch(ngthird1)
		{
			//case 1:
			herolist.Init(unx,uny,choice,ngthird1,ownernum);

			if(herolist.heronum==0)
			{
				ngc=0;
				ngthird1=0;
				flag=4;
				ngsecond1=0;
				Show(0);
				if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
				return 0;
			}
			herolist.Show(0);

			//break;
		}
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-菜单=武将列表操作 外交调用
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::DelHeroList_Diplomatism(WPARAM KeyCode)
{
	flagmap12=secondmenu2.KeyDown(KeyCode);
	if (flagmap12==-1)
	{
		flag=6;
		ngsecond1=0;
		Show(0);
		citymenu.Show(0);
		return 0;
	}
	else if(flagmap12==1)
	{
		ngthird1=(secondmenu2.statb)+15;
		//switch(ngthird1)
		{
			//case 1:
			herolist.Init(unx,uny,choice,ngthird1,ownernum);
			//herolist.InitData();
			herolist.Show(0);
			//break;
		}
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-菜单=武将列表操作 军备调用
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::DelHeroList_Armament(WPARAM KeyCode)
{
	flagmap13=secondmenu3.KeyDown(KeyCode);
	if (flagmap13==-1)
	{
		flag=6;
		ngsecond1=0;
		Show(0);
		citymenu.Show(0);
		return 0;
	}
	else if(flagmap13==1)
	{
		ngthird1=(secondmenu3.statb)+20;
		//switch(ngthird1)
		{
			//case 1:
			herolist.Init(unx,uny,choice,ngthird1,ownernum);
			//herolist.InitData();
			herolist.Show(0);
			//break;
		}
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-esc菜单
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::DelEscMenu(WPARAM KeyCode)
{
	flagmap1=escmenu.KeyDown(KeyCode);
	if(flagmap1==-1)
	{
		ngc=0;
		flag=4;
		Show(0);
		return 0;
	}
	else if(flagmap1==1)
	{
		ngsecond2=(escmenu.statb)+1;
		switch(ngsecond2)
		{
		case 1:
			{//策略结束

				Show(0);

				ShowEnd();
				ngc=0;
				flag=4;
				ngthird1=0;
				ngsecond1=0;
				flagx=0;
				DoEndEvent();
				if(flagwar==0&&warlistflag==0)Show(0);

				break;
			}
		case 2:
			//存储进度
			save.choice = choice;
			save.Init(-1,-1);//-1 -1表示读取数据
			save.Read(-1);//-1表示读取君主 年份信息
			save.Show();
			ngsave=1;
			break;
		case 3:
			ngc = 0;
			flag=4;
			return -1;

			return 0;
		}
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-城市主菜单
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::DelCityMenu(WPARAM KeyCode)
{
	flagmap2=citymenu.KeyDown(KeyCode);
	if(flagmap2==-1)
	{
		ngc=0;
		flag=4;
		Show(0);
		return 0;
	}
	else if(flagmap2==1)
	{
		ngsecond1=(citymenu.statb)+1;
		switch( ngsecond1)
		{
		case 1:
			//flag=7;
			secondmenu1.InitMenu(2,6,410,120,13,"Res//neizhen.sss",1,1);
			secondmenu1.Show (0);
			break;
		case 2:
			//flag=8;
			secondmenu2.InitMenu(2,5,410,120,4,"Res//waijiao.sss",1);
			secondmenu2.Show (0);
			break;
		case 3:
			//flag=9;
			secondmenu3.InitMenu(2,5,410,120,4,"Res//junbei.sss",1);
			secondmenu3.Show (0);
			break;
		case 4:
			//显示状况;
			//flag=10;
			ngc=3;
			citylist.Init(unx,uny,choice);
			//city[2].InitData();
			citylist.Show();
			break;
			return 0;
		}
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-城市信息
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::GetCityInfo(WPARAM KeyCode)
{
	int flagmap0=citylist.KeyDown(KeyCode);
	if(flagmap0==-1)
	{
		ngc=0;
		ngsecond1 = 0;//20170205
		flag=4;
		Show(0);
		return 0;
	}
	return 0;
}
/***********************************************************************
* 说明:     GameMap类按键处理-判断是否为城市
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::CheckIfCity(WPARAM KeyCode)
{
	if(GetCityPostion(unx,uny,choice,unum)==1&&citychooseflag==0)
	{
		Show(0);
		citymenu.InitMenu(2,4,300,100,3,"Res//citymu.sss",1);
		citymenu.Show(0);
		ngc=2;
		flag=6;
		currentcitynum=GetCityNum()+1;
		//Delay(500);
	}
	else if(GetCityPostion(unx,uny,choice,unum)==1&&citychooseflag==1)//移动
	{
		Show(0);
		int ww=GetCityNum()+1;
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.count+herolist.statf);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[herolist.count+herolist.statf]);

		if(herolist.hero[herolist.heroowned[herolist.count+herolist.statf]].hiscity!=ww)
		{
			herolist.hero[herolist.heroowned[herolist.count+herolist.statf]].hiscity=ww;
			herolist.hero[herolist.heroowned[herolist.count+herolist.statf]].inlistflag=3;
			ShowIt(-1,0,herolist.heroowned[herolist.count+herolist.statf]);
			citychooseflag=0;
		}
		else
		{
			ngthird1=14;
			ShowIt(0,0,herolist.heroowned[herolist.count+herolist.statf]);
			ngthird1=0;
		}
	}
	else if(GetCityPostion(unx,uny,choice,unum)==1&&citychooseflag==2)//侦察
	{			
		ngthird1=20;
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.count+herolist.statf);
		ShowIt(0,0,herolist.heroowned[herolist.count+herolist.statf]);
		ngthird1=0;

	}
	else if(GetCityPostion(unx,uny,choice,unum)==1&&citychooseflag==4)
	{			
		ngthird1=24;
		ShowIt(0,0,zujiang);
		ngthird1=0;

	}
	else if(GetCityPostion(unx,uny,choice,unum)==1&&citychooseflag==3)//输送
	{
		Show(0);
		int ww=GetCityNum()+1;
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.count+herolist.statf);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[herolist.count+herolist.statf]);
		if(herolist.hero[herolist.heroowned[herolist.count+herolist.statf]].hiscity!=ww)
		{
			herolist.hero[herolist.heroowned[herolist.count+herolist.statf]].inlistflag=0;
			ShowIt(-1,0,herolist.heroowned[herolist.count+herolist.statf]);
			citychooseflag=0;
			tasknum++;
			OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,tasknum);
			tasklist[tasknum].isend=0;
			tasklist[tasknum].event=TRANSPORTTASK;

			tasklist[tasknum].heronum=herolist.heroowned[herolist.count+herolist.statf];
			tasklist[tasknum].citynum=citylist.number;
			herolist.hero[herolist.heroowned[herolist.count+herolist.statf]].tili=herolist.hero[herolist.heroowned[herolist.count+herolist.statf]].tili-8;
			tasklist[tasknum].data[0]=tmp0[0];//输送金钱数
			tasklist[tasknum].data[1]=tmp0[1];//输送粮食数
			tasklist[tasknum].data[2]=tmp0[2];//输送士兵数

			//tasklist[tasknum].data[4]=ww;//目标城市
			int df=herolist.hero[herolist.heroowned[herolist.count+herolist.statf]].hiscity-1;
			OverflowCheck(__FILE__,__LINE__,CITYMAX,df);
			citylist.city[df].money -=tmp0[0];
			citylist.city[df].foods -=tmp0[1];
			citylist.city[df].soldierspace -=tmp0[2];

			int temp=rand()%100;
			if(temp<20)
			{
				tasklist[tasknum].data[3]=0;//被劫
			}
			else
			{
				tasklist[tasknum].data[3]=1;//不被劫
			}

		}
		else
		{
			ngthird1=13;
			ShowIt(0,0,herolist.heroowned[herolist.count+herolist.statf]);
			ngthird1=0;
		}
	}
	else if(GetCityPostion(unx,uny,choice,unum)==3&&citychooseflag==0)
	{
		Message(GetStrText("NOTE_STR5"),0,300,15,1);
		InvalidateRect(hwnd,&rect,false);
		//Delay(1000);
	}
	else if(GetCityPostion(unx,uny,choice,unum)==3&&citychooseflag==2)//侦察
	{
		citychooseflag=0;
		ngc=3;
		citylist.Init(unx,uny,choice);
		//city[2].InitData();
		citylist.Show();
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.count+herolist.statf);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[herolist.count+herolist.statf]);
		herolist.hero[herolist.heroowned[herolist.count+herolist.statf]].inlistflag=0;

	}
	else if(GetCityPostion(unx,uny,choice,unum)==2&&citychooseflag==2)//侦察
	{
		citychooseflag=0;
		ngc=3;
		citylist.Init(unx,uny,choice);
		//city[2].InitData();
		citylist.Show();
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.count+herolist.statf);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[herolist.count+herolist.statf]);
		herolist.hero[herolist.heroowned[herolist.count+herolist.statf]].inlistflag=0;

	}
	else if(GetCityPostion(unx,uny,choice,unum)==2&&citychooseflag==0)
	{
		Message(GetStrText("NOTE_STR3"),0,300,15,1);
		InvalidateRect(hwnd,&rect,false);
		//Delay(1000);
	}
	else if(GetCityPostion(unx,uny,choice,unum)==3&&citychooseflag==4)//出征
	{
		if(ArriveEnable()==1)
		{
			citychooseflag=0;
			Message(GetStrText("STR_ARMOUT"),0,300,15,1);
			tasknum++;
			OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,tasknum);
			tasklist[tasknum].isend=0;				
			tasklist[tasknum].event=EXPEDITIONTASK;
			tasklist[tasknum].heronum=ownernum-1;
			tasklist[tasknum].citynum=herolist.hero[zujiang].hiscity;
			int ww=GetCityNum()+1;
			tasklist[tasknum].data[0]=ww;//选择的进攻城市
			tasklist[tasknum].data[1]=tmp0[0];//粮食数目
			tasklist[tasknum].data[2]=tmp0[1];//武将数目
			tasklist[tasknum].data[3]=zujiang;//主将编号
			tasklist[tasknum].data[4]=-2;//无人城池，直接胜利

			tasklist[tasknum+1].data[0]=warherono[0];
			tasklist[tasknum+1].data[1]=warherono[1];
			tasklist[tasknum+1].data[2]=warherono[2];
			tasklist[tasknum+1].data[3]=warherono[3];
			tasklist[tasknum+1].data[4]=warherono[4];
			tasklist[tasknum+2].data[0]=warherono[5];
			tasklist[tasknum+2].data[1]=warherono[6];
			tasklist[tasknum+2].data[2]=warherono[7];
			tasklist[tasknum+2].data[3]=warherono[8];
			tasklist[tasknum+2].data[4]=0;//攻击战
			tasknum++;
			tasklist[tasknum].isend=0;	
			tasknum++;
			tasklist[tasknum].isend=0;	
			OverflowCheck(__FILE__,__LINE__,HEROMAX,zujiang);
			herolist.hero[zujiang].inlistflag=0;

			for(int i=0;i<9;i++)
			{
				
				if(warherono[i]==-1)
					break;
				OverflowCheck(__FILE__,__LINE__,HEROMAX,warherono[i]);
				herolist.hero[warherono[i]].inlistflag=0;
			}
			warherononum=0;
			zujiang=-1;
			for(int i=0;i<9;i++)warherono[i]=-1;

		}
		else
		{
			Message(GetStrText("NOTE_STR4"),0,300,15,1);
		}

	}
	else if(GetCityPostion(unx,uny,choice,unum)==2&&citychooseflag==4)//出征
	{
		if(ArriveEnable()==1)
		{
			citychooseflag=0;
			Message(GetStrText("STR_ARMOUT"),0,300,15,1);
			tasknum++;
			OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,tasknum);
			tasklist[tasknum].isend=0;				
			tasklist[tasknum].event=EXPEDITIONTASK;
			tasklist[tasknum].heronum=ownernum-1;
			OverflowCheck(__FILE__,__LINE__,HEROMAX,zujiang);
			tasklist[tasknum].citynum=herolist.hero[zujiang].hiscity;
			int ww=GetCityNum()+1;
			tasklist[tasknum].data[0]=ww;//选择的进攻城市
			tasklist[tasknum].data[1]=tmp0[0];//粮食数目
			tasklist[tasknum].data[2]=tmp0[1];//武将数目
			tasklist[tasknum].data[3]=zujiang;//主将编号
			tasklist[tasknum].data[4]=-1;//敌方城池
			/*
			citynum;所在城市编号
			heronum;君主编号
			date[0]所攻打城市编号
			date[1]粮食
			date[2]武将数目
			date[3]主将编号
			date[4]结果
			*/
			tasklist[tasknum+1].data[0]=warherono[0];
			tasklist[tasknum+1].data[1]=warherono[1];
			tasklist[tasknum+1].data[2]=warherono[2];
			tasklist[tasknum+1].data[3]=warherono[3];
			tasklist[tasknum+1].data[4]=warherono[4];
			tasklist[tasknum+2].data[0]=warherono[5];
			tasklist[tasknum+2].data[1]=warherono[6];
			tasklist[tasknum+2].data[2]=warherono[7];
			tasklist[tasknum+2].data[3]=warherono[8];
			tasklist[tasknum+2].data[4]=0;//攻击战
			tasknum++;
			tasklist[tasknum].isend=0;	
			tasknum++;
			tasklist[tasknum].isend=0;	
			herolist.hero[zujiang].inlistflag=0;

			for(int i=0;i<9;i++)
			{
				if(warherono[i]==-1)
					break;
				OverflowCheck(__FILE__,__LINE__,HEROMAX,warherono[i]);
				herolist.hero[warherono[i]].inlistflag=0;
			}
			warherononum=0;
			zujiang=-1;
			for(int i=0;i<9;i++)warherono[i]=-1;
		}
		else
		{
			Message(GetStrText("NOTE_STR4"),0,300,15,1);
		}
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-判断是否继续显示武将列表
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::CheckIfHeroListCanShow()
{
	if (flagx==1&&ngthird1!=24&&warlistflag!=1)//继续选择武将（非战斗状态）
	{
		Show(0);
		herolist.Init(unx,uny,choice,ngthird1,ownernum);
		herolist.Show(0);
		flagx=0;
		return 1;
	}
	if (flagx==1&&(ngthird1==24||warlistflag==1))//继续选择武将（战斗状态）
	{
		Show(0);
		herolist.Show(0);
		flagx=0;
		return 1;
	}
	return 0;
}

/***********************************************************************
* 说明:     GameMap类按键处理-主界面ESC
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-21      完成基本功能
***********************************************************************/
int GameMap::DelMainScenceEsc(WPARAM KeyCode)
{
	if(citychooseflag==1)
	{
		citychooseflag=0;
		ngthird1=14;
		herolist.Show(0);
	}
	else if(citychooseflag==2)
	{
		citychooseflag=0;
		ngthird1=20;
		herolist.Show(0);
	}
	else if(citychooseflag==3)
	{
		citychooseflag=0;
		ngthird1=13;
		ngthird4=1;
		operateflag=5;
		Show(0);
		herolist.Show(0);
		OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
		operate.Init(1,citylist.city[citylist.number].soldierspace);
		operate.Show();
	}
	else if(citychooseflag==4)
	{
		citychooseflag=0;
		ngthird1=24;
		ngthird4=1;
		operateflag=7;
		OverflowCheck(__FILE__,__LINE__,CITYMAX,currentcitynum-1);
		citylist.city[currentcitynum-1].foods=tmp0[3];
		tmp0[0]=0;
		Show(0);
		operate.Init(3,citylist.city[currentcitynum-1].foods);
		operate.current=1;
		operate.Show();
	}
	else
	{
		escmenu.InitMenu(4,3,300,100,2,"Res//escape.sss",1);
		escmenu.Show(0);
		ngc=1;
		flag=5;
		//Delay(500);
	}
	return 0;
}
/***********************************************************************
* 说明:     GameMap类按键函数
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-5       完成基本功能
*			   wstjb			2012-10-20		增加功能
***********************************************************************/
int GameMap::KeyDown(WPARAM KeyCode)
{
	wlogfile(1,__FUNCTION__,"开始",KeyCode);

	if(CheckIfHeroListCanShow())return 0;

	if(warlistflag==1)
	{
		return SelectHeroForDefense(KeyCode);
	}
	else if(newownerflag==1)
	{
		return ChangeOwner(KeyCode);

	}
	else if(flagwar==1)//显示战斗
	{
		int ret=fight.KeyDown(KeyCode);
		if(ret==-1||ret==-2)
		{
			reqresult=ret;
			flagwar=0;
			warinflag--;
			if(warinflag==0)warinflag=-1;
			DoEndEvent();		
			if(warinflag==-1&&warlistflag==0)Show(0);

		}
		else
		{
			fight.Show(0);
		}
	}
	else if(ngsave==1)
	{
		int retval=save.KeyDown(KeyCode);
		if(retval==-1)
		{
			ngsave=0;
			Show(0);
			ngsecond2=0;
			ngc=0;
		}
		else if(retval!=3)
		{
			ChangeDataToSave();	
			save.Write(retval);
			TimerMessage(GetStrText("dWriting"),"",50,280,12,1,1000);
			Show(0);
			ngsave=0;
			ngsecond2=0;
			ngc=0;

		}
	}
	else if(ngthird4)
	{
		return DelOperateList(KeyCode);//显示操作框情况

	}
	else if(ngthird3)
	{
		return DelGoodList(KeyCode);//显示道具列表的情况

	}

	else if(ngthird2)
	{
		return ExecHeroList_Twice(KeyCode);//显示第二次列表的情况

	}

	else if(ngthird1)
	{
		return ExecHeroList_Once(KeyCode);//显示第1次列表的情况

	}
	else if (ngsecond1==1)
	{	
		return DelHeroList_Interior(KeyCode);//武将列表 内政

	}
	else if (ngsecond1==2)
	{	
		return DelHeroList_Diplomatism(KeyCode);//武将列表 外交

	}
	else if (ngsecond1==3)
	{	
		return DelHeroList_Armament(KeyCode);//武将列表 军备

	}

	else if (ngc==1)
	{
		return DelEscMenu(KeyCode);//esc菜单

	}
	else if(ngc==2)
	{
		new_flag=0;
		return DelCityMenu(KeyCode);//城市主菜单


	}
	else if(ngc==3)
	{
		return GetCityInfo(KeyCode);//城市信息


	}
	else
	{
		if(KeyCode==KeyHome)
		{
			Show(-100);
		}
		else if(KeyCode== 9 )//20150509增加高攻击概率设置
		{
			if(highAtk == 0)
			{
				highAtk = 1;
				TimerMessage("设置","高攻击概率成功！",100,450,10,1,1000);
			}
			else
			{
				highAtk = 0;
				TimerMessage("取消","高攻击概率成功！",100,450,10,1,1000);
			}
		}
		else if(KeyCode== 35 )//20161204增加调用窗口程序end
		{
			DialogBox(hInst,LPCTSTR(IDD_WINDOW),hwnd,(DLGPROC)WindowCfgProc);
			//ShellExecute(hwnd,"open","天际边三国霸业窗口配置程序.exe","","",SW_SHOW );
		}
		else if(KeyCode==KeyDown0)
		{
			uny++;
			if(uny==9)uny=8;
			Show(KeyCode);
			return 0;
		}
		else if(KeyCode==KeyUp0)
		{
			uny--;
			if(uny==-1)uny=0;
			Show(KeyCode);
			return 0;
		}
		else if(KeyCode==KeyLeft0)
		{
			unx--;
			if(unx==-1)unx=0;
			Show(KeyCode);
			return 0;
		}
		else if(KeyCode==KeyRight0)
		{
			unx++;
			if(unx==12)unx=11;
			Show(KeyCode);
			return 0;
		}
		else if(KeyCode==KeyReturn)
		{
			CheckIfCity(KeyCode);
		}
		else if(KeyCode==KeyEsc)
		{
			DelMainScenceEsc(KeyCode);

		}
	}
	return 0;
}


/***********************************************************************
* 说明:     GameMap类初始化显示的相关函数
* 输入参数: 无
* 返回值  : 无
* 功能	   : 对不同的君主，设置不同的坐标以及初始化时的位置等等
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void GameMap::ArrowSet()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	//ChangeRes(name);
	char nameme[NORMALSTRLEN];

	sprintf_s(nameme,"Res\\arrowset%d.sdt",choice+1);
	
	ifstream infile(nameme,ios::in);
	for(int i=0;i<=unum;i++)
	{
		infile>>arrowx;
		infile>>arrowy;
		infile>>zbx;
		infile>>zby;
		infile>>unx;
		infile>>uny;
		flagu=0;
		flagd=0;
		flagl=0;
		flagr=0;

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

/***********************************************************************
* 说明:     GameMap类获取城市名称的相关函数
* 输入参数: 无
* 返回值  : 无
* 功能	   : 对不同的坐标位置，查找并显示城市名称
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void GameMap::GetCityName()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	GetFileText("Res\\cityname.sss");

	int k=uny*12+unx;
	MyCreateFont(0.9);
	HFONT	h = t_h;
	HFONT oldh=(HFONT)SelectObject(hdcTmp,h);
	MySetTextColor(FONTA,USEHDCTMP);
	if (texta[k][0]!='0'&&k<97)
		TextOut(hdcTmp,695,400,texta[k],strlen(texta[k]));
	SelectObject(hdcTmp,oldh);
	SetTextColor(hdcTmp,RGB(0, 0, 0));
	DeleteObject(h);

}

/***********************************************************************
* 说明:     GameMap类显示城市图标相关函数
* 输入参数: 无
* 返回值  : 无
* 功能	   : 显示城市图标
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-13       完成基本功能
***********************************************************************/
void GameMap::ShowCityIcon(int tmp)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int posx[CITYMAX];
	int posy[CITYMAX];
	char name[NORMALSTRLEN];
	//ChangeRes(name);
	sprintf_s(name,"%s","Res\\City\\postion.sdt");
	
	ifstream infile(name,ios::in);
	for(int g=0;g<CITYMAX;g++)
	{

		infile>>posx[g];
		infile>>posy[g];
		int x=posx[g]*90+10-zbx;
		int y=posy[g]*80+25-zby;

		if(citylist.city[g].owner==ownernum)
		{
			//ShowCG(0,"Res\\City\\mycity.sbp",x,y);
			LoadPic("Res\\City\\mycity.sbp",hbmp);	//封装完成
			HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
			if(tmp==1&&x>250&&y>20&&x<550&&y<300)
			{
				BitBlt(hdc,x,y+50,40,40,hdcMem,0,0,SRCCOPY);
			}
			else
			{
				BitBlt(hdcTmp,x,y+50,40,40,hdcMem,0,0,SRCCOPY);
			}
			InvalidateRect(hwnd,NULL,false);
			SelectObject(hdcMem, oldhbmp);
			DeleteObject(hbmp);
		}
		else if(citylist.city[g].owner==0)
		{
			//ShowCG(0,"Res\\City\\emcity.sbp",x,y);
			LoadPic("Res\\City\\emcity.sbp",hbmp);	//封装完成
			HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
			if(tmp==1&&x>250&&y>20&&x<550&&y<300)
			{
				BitBlt(hdc,x,y+50,40,40,hdcMem,0,0,SRCCOPY);
			}
			else
			{
				BitBlt(hdcTmp,x,y+50,40,40,hdcMem,0,0,SRCCOPY);
			}
			InvalidateRect(hwnd,NULL,false);
			SelectObject(hdcMem, oldhbmp);
			DeleteObject(hbmp);
		}
		else
		{
			//ShowCG(0,"Res\\City\\emcity.sbp",x,y);
			LoadPic("Res\\City\\hiscity.sbp",hbmp);	//封装完成
			HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
			if(tmp==1&&x>250&&y>20&&x<550&&y<300)
			{
				BitBlt(hdc,x,y+50,40,40,hdcMem,0,0,SRCCOPY);
			}
			else
			{
				BitBlt(hdcTmp,x,y+50,40,40,hdcMem,0,0,SRCCOPY);
			}
			InvalidateRect(hwnd,NULL,false);
			SelectObject(hdcMem, oldhbmp);
			DeleteObject(hbmp);
		}

	}
	infile.close();

	//ChangeRes(name);
}

/***********************************************************************
* 说明:     开垦指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Reclaim(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	int zili=herolist.hero[herolist.heroowned[x]].zili  ;
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	int agriculturemax=citylist.city[citylist.number].agriculturemax;
	int agriculture=citylist.city[citylist.number].agriculture;
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}

	if (agriculture >= agriculturemax)
	{
		/*提示已达上限*/
		Message(GetStrText("NOTE_STR1"),0,300,15,1);
		return -1;
	}
	if (citylist.city[citylist.number].money<50)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}
	if (herolist.hero[herolist.heroowned[x]].tili<8)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}

	int fa = zili / 10 * (rand() % 4 + 2) + (zili >> 1);
	agriculture=agriculture+fa;
	if(agriculture>agriculturemax)agriculture=agriculturemax;
	citylist.city[citylist.number].agriculture=agriculture;
	citylist.city[citylist.number].money =citylist.city[citylist.number].money-50;
	herolist.hero[herolist.heroowned[x]].tili=herolist.hero[herolist.heroowned[x]].tili-8;
	herolist.hero[herolist.heroowned[x]].inlistflag=0;
	ShowIt(fa,agriculture,herolist.heroowned[x]);
	new_flag=1;
	return 0;
}

/***********************************************************************
* 说明:     招商指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Investment(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	int zili=herolist.hero[herolist.heroowned[x]].zili  ;
	int businessmax=citylist.city[citylist.number].businessmax ;
	int business=citylist.city[citylist.number].business;
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}
	if (business >= businessmax)
	{
		/*提示已达上限*/
		Message(GetStrText("NOTE_STR2"),0,300,15,1);
		return -1;
	}

	if (citylist.city[citylist.number].money<50)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}
	if (herolist.hero[herolist.heroowned[x]].tili<8)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}

	int ca = zili / 10 * (rand() % 4 + 2) + (zili >> 1);
	business=business+ca;
	if(business>businessmax)business=businessmax;
	citylist.city[citylist.number].business=business;
	citylist.city[citylist.number].money =citylist.city[citylist.number].money-50;
	herolist.hero[herolist.heroowned[x]].tili=herolist.hero[herolist.heroowned[x]].tili-8;
	herolist.hero[herolist.heroowned[x]].inlistflag=0;
	ShowIt(ca,business,herolist.heroowned[x]);
	new_flag=1;
	return 0;
}

/***********************************************************************
* 说明:     搜索指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Search(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}

	if (citylist.city[citylist.number].money<0)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}
	if (herolist.hero[herolist.heroowned[x]].tili<8)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}
	//searchflag=true;策略结束后响应
	tasknum++;
	OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,tasknum);
	tasklist[tasknum].isend=0;	
	tasklist[tasknum].event=SEARCHTASK;

	tasklist[tasknum].heronum=herolist.heroowned[x];
	tasklist[tasknum].citynum=citylist.number;
	herolist.hero[herolist.heroowned[x]].tili=herolist.hero[herolist.heroowned[x]].tili-8;
	herolist.hero[herolist.heroowned[x]].inlistflag=0;
	ShowIt(0,0,herolist.heroowned[x]);
	new_flag=1;
	return 0;
}

/***********************************************************************
* 说明:     治理指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Govern(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	int disease=citylist.city[citylist.number].disease;
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}
	if (disease >= 100)
	{
		/*提示已达上限*/
		Message(GetStrText("NOTE_STR10"),0,300,15,1);
		return -1;
	}

	if (citylist.city[citylist.number].money<50)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}
	if (herolist.hero[herolist.heroowned[x]].tili<8)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}

	int ca = 1+rand() % 4;
	disease=disease+ca;
	if(disease>100)disease=100;
	citylist.city[citylist.number].statue=0;
	citylist.city[citylist.number].disease=disease;
	citylist.city[citylist.number].money =citylist.city[citylist.number].money-50;
	herolist.hero[herolist.heroowned[x]].tili=herolist.hero[herolist.heroowned[x]].tili-8;
	herolist.hero[herolist.heroowned[x]].inlistflag=0;
	ShowIt(ca,disease,herolist.heroowned[x]);
	new_flag=1;
	return 0;
}

/***********************************************************************
* 说明:     出巡指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Tour(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	int heart=citylist.city[citylist.number].heart;
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}

	if (citylist.city[citylist.number].money<50)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}
	if (herolist.hero[herolist.heroowned[x]].tili<8)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}

	int ca = 1+rand() % 4;
	heart=heart+ca;
	if(heart>100)heart=100;
	citylist.city[citylist.number].heart=heart;
	citylist.city[citylist.number].money =citylist.city[citylist.number].money-50;
	citylist.city[citylist.number].people =citylist.city[citylist.number].people+100;
	if(citylist.city[citylist.number].people>citylist.city[citylist.number].peoplemax)
	{
		citylist.city[citylist.number].people =citylist.city[citylist.number].peoplemax;
	}
	herolist.hero[herolist.heroowned[x]].tili=herolist.hero[herolist.heroowned[x]].tili-8;
	herolist.hero[herolist.heroowned[x]].inlistflag=0;
	ShowIt(ca,heart,herolist.heroowned[x]);
	new_flag=1;
	return 0;
}

/***********************************************************************
* 说明:     招降指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Surrender(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	static int sd;
	if(zaoxiangflag==0)//显示武将队列
	{
		if(herolist.heronum==0)
		{
			if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
			return -2;
		}
		if(herolist.fulunum==0)
		{
			Message(GetStrText("STR_NOCAPTIVES"),0,300,15,1);
			return -2;
		}


		if (citylist.city[citylist.number].money<100)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR8"),0,300,15,1);
			return -1;
		}
		if (herolist.hero[herolist.heroowned[x]].tili<15)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR9"),0,300,15,1);
			return -1;
		}		

		zaoxiangflag=1;
		Show(0);
		herolist.Show(0);
		sd=x;
		new_flag=1;
		return 1;
	}
	else
	{
		zaoxiangflag=0;
		if(herolist.fulunum==0)
		{
			Message(GetStrText("STR_NOCAPTIVES"),0,300,15,1);
			return -2;
		}

		if (citylist.city[citylist.number].money<100)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR8"),0,300,15,1);
			return -1;
		}
		OverflowCheck(__FILE__,__LINE__,HEROMAX,sd);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[sd]);

		herolist.hero[herolist.heroowned[sd]].tili=herolist.hero[herolist.heroowned[sd]].tili-15;

		tasknum++;
		OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,tasknum);
		tasklist[tasknum].isend=0;	
		tasklist[tasknum].event=SURRENDERTASK;

		tasklist[tasknum].citynum=citylist.number;

		//招降 data[0]作为招降结果 0-失败 1-成功
		int temp=herolist.hero[herolist.heroowned[sd]].zili-herolist.hero[herolist.heroowned[x]].zili+50;
		int temp1=rand()%100;
		if(temp1>temp)
		{
			tasklist[tasknum].data[0]=0;
			tasklist[tasknum].heronum=herolist.heroowned[x+herolist.heronum];
		}
		else
		{
			OverflowCheck(__FILE__,__LINE__,HEROMAX,x+herolist.heronum);
			OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x+herolist.heronum ]);
			switch (herolist.hero[herolist.heroowned[x+herolist.heronum ]].charcter )
			{
			case 4:
				temp= 1;
				break;
			case 3:
				temp= 3;
				break;
			case 2:
				temp= 4;
				break;
			case 1:
				temp= 5;
				break;
			case 0:
				temp= 2;
				break;
			}
			int dev=herolist.hero[herolist.heroowned[x+herolist.heronum ]].heart;
			herolist.hero[herolist.heroowned[x+herolist.heronum ]].heart=(int)(dev-dev/10);
			if(dev>60)
			{
				tasklist[tasknum].data[0]=0;
				tasklist[tasknum].heronum=herolist.heroowned[x+herolist.heronum];
			}
			else
			{
				temp = dev / temp;
				temp1 = rand() % 100;
				if (temp1 < temp)
				{
					tasklist[tasknum].data[0]=0;
					tasklist[tasknum].heronum=herolist.heroowned[x+herolist.heronum];
				}
				else
				{
					tasklist[tasknum].data[0]=1;
					tasklist[tasknum].heronum=herolist.heroowned[x+herolist.heronum];
				}
			}
		}
		herolist.hero[herolist.heroowned[sd]].inlistflag=0;
		ShowIt(0,0,herolist.heroowned[sd]);
		return -2;
	}
}

/***********************************************************************
* 说明:     处斩指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Behead(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	if(herolist.fulunum==0)
	{
		Message(GetStrText("STR_NOCAPTIVES"),0,300,15,1);
		return -2;
	}
	int tu=herolist.heronum;
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x+tu);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x+tu]);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	herolist.hero[herolist.heroowned[x+tu]].owner =HEROMAX;
	herolist.hero[herolist.heroowned[x]].iscaptive = 0;
	ShowIt(0,0,herolist.heroowned[x+tu]);
	new_flag=1;
	return -2;
}

/***********************************************************************
* 说明:     流放指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Exile(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	if(herolist.heronum==0&&herolist.fulunum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}
	if(herolist.hero[herolist.heroowned[x]].owner<HEROMAX)
	{
		//改变右边显示武将数.
		herolist.heronum--;
		heronumber--;
	}
	
	herolist.hero[herolist.heroowned[x]].owner =0;
	herolist.hero[herolist.heroowned[x]].iscaptive = 0;
	Show(0);
	new_flag=1;
	return -2;
}

/***********************************************************************
* 说明:     赏赐指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Award(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	
	static int wj;
	if(daojuflag==0)//显示武将队列
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
		wj=x;
		goodlist.Init(unx,uny,choice,-1,unum);
		int goodnum=goodlist.goodnum ;		
		if(herolist.heronum==0)
		{
			if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
			return -2;
		}
		if (goodnum==0)
		{
			Message(GetStrText("STR_CNOGOODS"),0,300,15,1);
			return -1;
		}
		if (herolist.hero[herolist.heroowned[x]].goods1!=0&&herolist.hero[herolist.heroowned[x]].goods2!=0)
		{
			Message(GetStrText("STR_FULLGOODS"),0,300,15,1);
			return -1;
		}

		//citylist.city[citylist.number].goodnum--;

		daojuflag=1;
		Show(0);
		goodlist.Show(0);
		new_flag=1;
		return 2;
	}
	else
	{
		daojuflag=0;
		Show(0);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,wj);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[wj]);
		herolist.hero[herolist.heroowned[wj]].heart =herolist.hero[herolist.heroowned[wj]].heart+8;
		if(herolist.hero[herolist.heroowned[wj]].heart>100)herolist.hero[herolist.heroowned[wj]].heart=100;
		OverflowCheck(__FILE__,__LINE__,GOODMAX,goodlist.goodowned[x]-1);
		if(goodlist.good[goodlist.goodowned[x]-1].no==31)
		{
			if(herolist.hero[herolist.heroowned[wj]].wuli>105)
			{
				goodlist.good[goodlist.goodowned[x]-1].owner=herolist.heroowned[wj];
				goodlist.goodnum--;
				herolist.hero[herolist.heroowned[wj]].style=4;
				return -2;
			}
			Message(GetStrText("STR_CANNOTUSE"),0,300,15,1);
			return -2;
		}
		if(goodlist.good[goodlist.goodowned[x]-1].no==32)
		{
			if(herolist.hero[herolist.heroowned[wj]].zili >105)
			{
				goodlist.good[goodlist.goodowned[x]-1].owner=(herolist.heroowned[wj]+1);
				goodlist.goodnum--;
				herolist.hero[herolist.heroowned[wj]].style=5;
				return -2;
			}
			Message(GetStrText("STR_CANNOTUSE"),0,300,15,1);
			return -2;
		}
		if(goodlist.good[goodlist.goodowned[x]-1].no==33)
		{	
			goodlist.good[goodlist.goodowned[x]-1].owner=(herolist.heroowned[wj]+1);
			goodlist.goodnum--;
			herolist.hero[herolist.heroowned[wj]].style=3;
			return -2;
		}
		if(herolist.hero[herolist.heroowned[wj]].goods1 ==0) 
		{
			herolist.hero[herolist.heroowned[wj]].goods1=goodlist.goodowned[x];
			herolist.hero[herolist.heroowned[wj]].wuli=herolist.hero[herolist.heroowned[wj]].wuli+goodlist.good[goodlist.goodowned[x]-1].wuliup ;
			herolist.hero[herolist.heroowned[wj]].zili=herolist.hero[herolist.heroowned[wj]].zili+goodlist.good[goodlist.goodowned[x]-1].ziliup ;
			herolist.hero[herolist.heroowned[wj]].speedup=herolist.hero[herolist.heroowned[wj]].speedup+goodlist.good[goodlist.goodowned[x]-1].speedup;
		}
		else if(herolist.hero[herolist.heroowned[wj]].goods2 ==0) 
		{
			herolist.hero[herolist.heroowned[wj]].goods2=goodlist.goodowned[x];
			herolist.hero[herolist.heroowned[wj]].wuli=herolist.hero[herolist.heroowned[wj]].wuli+goodlist.good[goodlist.goodowned[x]-1].wuliup ;
			herolist.hero[herolist.heroowned[wj]].zili=herolist.hero[herolist.heroowned[wj]].zili+goodlist.good[goodlist.goodowned[x]-1].ziliup ;
			herolist.hero[herolist.heroowned[wj]].speedup=herolist.hero[herolist.heroowned[wj]].speedup+goodlist.good[goodlist.goodowned[x]-1].speedup;
		}
		goodlist.good[goodlist.goodowned[x]-1].owner=(herolist.heroowned[wj])+1;
		goodlist.goodnum--;
		//citylist.city[citylist.number].goodnum--;
		ShowIt(0,0,herolist.heroowned[wj]);

		return -2;
	}
}

/***********************************************************************
* 说明:     没收指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Confiscate(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	static int wja;
	if(daojuflag==0)//显示武将队列
	{
		wja=x;
		OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
		goodlist.Init(unx,uny,choice,herolist.heroowned[x]+1/*+1区分是武将（从0开始），还是道具拥有着编号（从1开始）*/,unum);
		int goodnum=goodlist.goodnum ;
		//int goodnum=goodlist.goodnum ;
		if(herolist.heronum==0)
		{
			if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
			return -2;
		}
		if (herolist.hero[herolist.heroowned[x]].goods1==0&&herolist.hero[herolist.heroowned[x]].goods2==0)
		{
			Message(GetStrText("STR_NOGOODS"),0,300,15,1);
			return -1;
		}

		daojuflag=2;//表示为武将拥有的道具队列，非城市的
		Show(0);
		goodlist.Show(0);
		new_flag=1;
		return 2;
	}
	else
	{
		daojuflag=0;
		Show(0);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,wja);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[wja]);
		herolist.hero[herolist.heroowned[wja]].heart =herolist.hero[herolist.heroowned[wja]].heart-20;
		if(herolist.hero[herolist.heroowned[wja]].heart<0)herolist.hero[herolist.heroowned[wja]].heart=0;
		if(herolist.hero[herolist.heroowned[wja]].goods1<herolist.hero[herolist.heroowned[wja]].goods2)
		{
			if(herolist.hero[herolist.heroowned[wja]].goods1 !=0&&x==0) 
			{
				herolist.hero[herolist.heroowned[wja]].goods1=0;
				herolist.hero[herolist.heroowned[wja]].wuli=herolist.hero[herolist.heroowned[wja]].wuli-goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].wuliup;
				herolist.hero[herolist.heroowned[wja]].zili=herolist.hero[herolist.heroowned[wja]].zili-goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].ziliup;
				herolist.hero[herolist.heroowned[wja]].speedup=herolist.hero[herolist.heroowned[wja]].speedup -goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].speedup;
				goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].owner=0;
				goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].hiscity=herolist.hero[herolist.heroowned[wja]].hiscity;
			}
			else if(herolist.hero[herolist.heroowned[wja]].goods2 !=0) 
			{
				herolist.hero[herolist.heroowned[wja]].goods2=0;
				herolist.hero[herolist.heroowned[wja]].wuli=herolist.hero[herolist.heroowned[wja]].wuli-goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].wuliup;
				herolist.hero[herolist.heroowned[wja]].zili=herolist.hero[herolist.heroowned[wja]].zili-goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].ziliup;
				herolist.hero[herolist.heroowned[wja]].speedup=herolist.hero[herolist.heroowned[wja]].speedup -goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].speedup;
				goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].owner=0;
				goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].hiscity=herolist.hero[herolist.heroowned[wja]].hiscity;
			}
		}
		else
		{
			if(herolist.hero[herolist.heroowned[wja]].goods2 !=0&&x==0) 
			{
				herolist.hero[herolist.heroowned[wja]].goods2=0;
				herolist.hero[herolist.heroowned[wja]].wuli=herolist.hero[herolist.heroowned[wja]].wuli-goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].wuliup;
				herolist.hero[herolist.heroowned[wja]].zili=herolist.hero[herolist.heroowned[wja]].zili-goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].ziliup;
				herolist.hero[herolist.heroowned[wja]].speedup=herolist.hero[herolist.heroowned[wja]].speedup -goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].speedup;
				goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].owner=0;
				goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].hiscity=herolist.hero[herolist.heroowned[wja]].hiscity;
			}
			else if(herolist.hero[herolist.heroowned[wja]].goods1 !=0) 
			{
				herolist.hero[herolist.heroowned[wja]].goods1=0;
				herolist.hero[herolist.heroowned[wja]].wuli=herolist.hero[herolist.heroowned[wja]].wuli-goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].wuliup;
				herolist.hero[herolist.heroowned[wja]].zili=herolist.hero[herolist.heroowned[wja]].zili-goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].ziliup;
				herolist.hero[herolist.heroowned[wja]].speedup=herolist.hero[herolist.heroowned[wja]].speedup -goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].speedup;
				goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].owner=0;
				goodlist.good[goodlist.goodowned[goodlist.goodnum+x]-1].hiscity=herolist.hero[herolist.heroowned[wja]].hiscity;
			}
		}
		//goodlist.AddGood(x)
		goodlist.goodnum++;
		goodlist.herogoodnum--;
		//citylist.city[citylist.number].goodnum++;
		ShowIt(0,0,herolist.heroowned[wja]);

		return -2;
	}
}

/***********************************************************************
* 说明:     交易指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Trade(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	int tili=herolist.hero[herolist.heroowned[x]].tili;
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}
	if (citylist.city[citylist.number].money<0)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}
	if (herolist.hero[herolist.heroowned[x]].tili<12)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}
	operateflag=2;//有买入卖出
	operate.Init(-1,0);

	operate.Show();
	new_flag=1;
	//ShowIt(0,0,herolist.heroowned[x]);
	return 3;
}

/***********************************************************************
* 说明:     宴请指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Banquet(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	int tili=herolist.hero[herolist.heroowned[x]].tili;
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}
	if (citylist.city[citylist.number].money<100)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}


	tili=tili+50;
	if(tili>100)tili=100;
	herolist.hero[herolist.heroowned[x]].tili=tili;
	herolist.hero[herolist.heroowned[x]].heart++;
	if(herolist.hero[herolist.heroowned[x]].heart>100)herolist.hero[herolist.heroowned[x]].heart=100;
	citylist.city[citylist.number].money =citylist.city[citylist.number].money-100;
	//herolist.hero[herolist.heroowned[x]].tili=herolist.hero[herolist.heroowned[x]].tili-4;
	if(herolist.heroowned[x]!=ownernum-1)ShowIt(0,0,herolist.heroowned[x]);
	new_flag=1;
	return 0;
}

/***********************************************************************
* 说明:     输送指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Transport(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	if(operateflag==5)
	{
		operateflag=0;
		ShowIt(0,0,herolist.heroowned[x]);
		citychooseflag=3;//输送选择城池

		return 0;
	}
	else
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
		OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
		int tili=herolist.hero[herolist.heroowned[x]].tili;
		if(herolist.heronum==0)
		{
			if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
			return -2;
		}
		if (citylist.city[citylist.number].money<0)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR8"),0,300,15,1);
			return -1;
		}
		if (herolist.hero[herolist.heroowned[x]].tili<12)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR9"),0,300,15,1);
			return -1;
		}
		operate.Init(2,citylist.city[citylist.number].money);

		operate.Show();
		operateflag=3;//三次
		new_flag=1;
		return 3;
	}
}

/***********************************************************************
* 说明:     移动指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Move(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}

	if (citylist.city[citylist.number].money<0)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}
	if (herolist.hero[herolist.heroowned[x]].tili<0)
	{
		/*体力不足*/
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}
	citychooseflag=1;//移动选择城池
	//herolist.hero[herolist.heroowned[x]].hiscity=
	//herolist.hero[herolist.heroowned[x]].inlistflag=0;
	ShowIt(0,0,herolist.heroowned[x]);
	new_flag=1;
	return -2;
}

/***********************************************************************
* 说明:     离间指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Alienate(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	static int wjlj;
	if(lijianflag==0)//显示武将队列
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	
		wjlj=x;
		if(herolist.heronum==0)
		{
			if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
			return -2;
		}

		if (citylist.city[citylist.number].money<50)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR8"),0,300,15,1);
			return -1;
		}
		if (herolist.hero[herolist.heroowned[x]].tili<20)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR9"),0,300,15,1);
			return -1;
		}

		lijianflag=1;
		Show(0);
		herolist.Show(0);
		new_flag=1;
		return 1;
	}
	else
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,wjlj);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[wjlj]);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);

		lijianflag=0;
		Show(0);
		herolist.hero[herolist.heroowned[wjlj]].inlistflag=0;
		herolist.hero[herolist.heroowned[wjlj]].tili=herolist.hero[herolist.heroowned[wjlj]].tili-20;

		/*tasknum++;
		tasklist[tasknum].isend=0;

		tasklist[tasknum].event=4;
		tasklist[tasknum].heronum=herolist.heroowned[wjlj];
		tasklist[tasknum].citynum=citylist.number;*///离间不用显示，故不添加队列

		//离间 data[0]作为离间结果 0-失败 1-成功
		int temp=herolist.hero[herolist.heroowned[wjlj]].zili-herolist.hero[herolist.heroowned[x]].zili+50;
		int temp1=rand()%100;
		if(temp1>temp)
		{
			//tasklist[tasknum].data[0]=0;
			return -2;
		}
		temp1=rand()%100;
		if(temp1<herolist.hero[herolist.heroowned[wjlj]].heart )
		{
			//tasklist[tasknum].data[0]=0;
		}
		else
		{
			switch (herolist.hero[herolist.heroowned[x]].charcter )
			{
			case 4:
				temp= 5;
				break;
			case 3:
				temp= 30;
				break;
			case 2:
				temp= 40;
				break;
			case 1:
				temp= 30;
				break;
			case 0:
				temp= 50;
				break;
			}

			temp1 = rand() % 100;
			if (temp1 < temp)
			{
				//tasklist[tasknum].data[0]=0;
			}
			else
			{
				herolist.hero[herolist.heroowned[x]].heart -=4;
				if(herolist.hero[herolist.heroowned[x]].heart <0)herolist.hero[herolist.heroowned[x]].heart=0;
			}

		}

		return -2;
	}
}

/***********************************************************************
* 说明:     招揽指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Solicit(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	static int wjzl;
	if(lijianflag==0)//显示武将队列
	{
		wjzl=x;
		OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
		OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
		if(herolist.heronum==0)
		{
			if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
			return -2;
		}

		if (citylist.city[citylist.number].money<50)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR8"),0,300,15,1);
			return -1;
		}
		if (herolist.hero[herolist.heroowned[x]].tili<15)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR9"),0,300,15,1);
			return -1;
		}
		/*herolist.hero[herolist.heroowned[x]].tili=herolist.hero[herolist.heroowned[x]].tili-15;
		herolist.hero[herolist.heroowned[x]].inlistflag=0;*/
		lijianflag=1;
		Show(0);
		herolist.Show(0);
		new_flag=1;
		return 1;
	}
	else
	{
		lijianflag=0;
		Show(0);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,wjzl);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[wjzl]);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);

		herolist.hero[herolist.heroowned[wjzl]].inlistflag=0;
		herolist.hero[herolist.heroowned[wjzl]].tili=herolist.hero[herolist.heroowned[wjzl]].tili-15;

		tasknum++;
		OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,tasknum);
		tasklist[tasknum].isend=0;

		tasklist[tasknum].event=SOLICITTASK;
		int gb=herolist.heronum+herolist.fulunum+herolist.athomenum+x;
		tasklist[tasknum].heronum=herolist.heroowned[gb];
		tasklist[tasknum].citynum=citylist.number;

		//招揽 data[0]作为招揽结果 0-失败 1-成功
		int temp=herolist.hero[herolist.heroowned[wjzl]].zili-herolist.hero[herolist.heroowned[x]].zili+50;
		int temp1=rand()%100;
		if(temp1>temp)
		{
			tasklist[tasknum].data[0]=0;
			return -2;
		}
		temp1=rand()%100;
		if(temp1<herolist.hero[herolist.heroowned[wjzl]].heart )
		{
			tasklist[tasknum].data[0]=0;
		}
		else
		{
			switch (herolist.hero[herolist.heroowned[x]].charcter)
			{
			case 4:
				temp= 5;
				break;
			case 3:
				temp= 20;
				break;
			case 2:
				temp= 30;
				break;
			case 1:
				temp= 40;
				break;
			case 0:
				temp= 15;
				break;
			}

			temp1 = rand() % 100;
			if (temp1 < temp)
			{
				tasklist[tasknum].data[0]=0;
			}
			else
			{
				if(rand()%100>30)
				{
					tasklist[tasknum].data[0]=0;
				}
				tasklist[tasknum].data[0]=1;
			}

		}
		return -2;
	}
}

/***********************************************************************
* 说明:     策反指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Instigation(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	
	static int wjcf;
	if(lijianflag==0)//显示武将队列
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
		OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
		wjcf=x;
		if(herolist.heronum==0)
		{
			if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
			return -2;
		}

		if (citylist.city[citylist.number].money<50)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR8"),0,300,15,1);
			return -1;
		}
		if (herolist.hero[herolist.heroowned[x]].tili<20)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR9"),0,300,15,1);
			return -1;
		}
		/*herolist.hero[herolist.heroowned[x]].tili=herolist.hero[herolist.heroowned[x]].tili-20;
		herolist.hero[herolist.heroowned[x]].inlistflag=0;*/
		lijianflag=1;
		Show(0);
		herolist.Show(0);
		new_flag=1;
		return 1;
	}
	else
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,wjcf);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[wjcf]);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);

		lijianflag=0;
		Show(0);

		herolist.hero[herolist.heroowned[wjcf]].inlistflag=0;
		herolist.hero[herolist.heroowned[wjcf]].tili=herolist.hero[herolist.heroowned[wjcf]].tili-15;

		tasknum++;
		OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,tasknum);
		tasklist[tasknum].isend=0;

		tasklist[tasknum].event=INSTIGATIONTASK;
		int gb=herolist.heronum+herolist.fulunum+herolist.athomenum+x;
		int gbb=herolist.heroowned[gb];
		OverflowCheck(__FILE__,__LINE__,HEROMAX,gb);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[gb]);
		tasklist[tasknum].heronum=herolist.heroowned[gb];
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[gb]);
		tasklist[tasknum].citynum=herolist.hero[herolist.heroowned[gb]].hiscity;

		//策反 data[0]作为策反结果 0-失败 1-成功
		int temp=herolist.hero[herolist.heroowned[wjcf]].zili-herolist.hero[herolist.heroowned[gb]].zili+50;
		int temp1=rand()%100;
		if(temp1>temp)
		{
			tasklist[tasknum].data[0]=0;

			return -2;
		}
		temp1=rand()%100;
		if(temp1<herolist.hero[herolist.heroowned[wjcf]].heart )
		{
			tasklist[tasknum].data[0]=0;

		}
		else
		{
			switch (herolist.hero[herolist.heroowned[x]].charcter)
			{
			case 4:
				temp= 5;
				break;
			case 3:
				temp= 60;
				break;
			case 2:
				temp= 20;
				break;
			case 1:
				temp= 10;
				break;
			case 0:
				temp= 30;
				break;
			}

			temp1 = rand() % 100;
			if (temp1 < temp)
			{
				tasklist[tasknum].data[0]=0;

			}
			else
			{
				if(rand()%100>30)
				{
					tasklist[tasknum].data[0]=0;
				}
				tasklist[tasknum].data[0]=1;
				int fg=herolist.hero[gbb].hiscity-1;
				if(citylist.city[fg].owner==citylist.city[fg].ownto)tasklist[tasknum].data[0]=0;
			}

		}

		return -2;
	}
}

/***********************************************************************
* 说明:     反间指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Anti(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	Show(0);
	return -2;
}

/***********************************************************************
* 说明:     劝降指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Capitulate(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	static int wjqx;
	if(quanxiangflag==0)//显示武将队列
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
		OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
		wjqx=x;
		if(herolist.heronum==0)
		{
			if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
			return -2;
		}

		if (citylist.city[citylist.number].money<50)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR8"),0,300,15,1);
			return -1;
		}
		if (herolist.hero[herolist.heroowned[x]].tili<10)
		{
			/*金钱不足*/
			Message(GetStrText("NOTE_STR9"),0,300,15,1);
			return -1;
		}

		quanxiangflag=1;
		Show(0);
		herolist.Show(0);
		new_flag=1;
		return 1;
	}
	else
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,wjqx);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[wjqx]);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
		quanxiangflag=0;
		Show(0);
		herolist.hero[herolist.heroowned[wjqx]].tili=herolist.hero[herolist.heroowned[wjqx]].tili-10;
		herolist.hero[herolist.heroowned[wjqx]].inlistflag=0;

		tasknum++;
		OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,tasknum);
		tasklist[tasknum].isend=0;

		tasklist[tasknum].event=CAPITULATETASK;
		int gb=herolist.heronum+herolist.fulunum+herolist.athomenum+herolist.otherwjnum+x;
		OverflowCheck(__FILE__,__LINE__,HEROMAX,gb);
		tasklist[tasknum].heronum=herolist.heroowned[gb];
		tasklist[tasknum].citynum=citylist.number;


		//劝降 data[0]作为劝降结果 0-失败 1-成功
		int temp=herolist.hero[herolist.heroowned[wjqx]].zili-herolist.hero[herolist.heroowned[x]].zili+50;
		int temp1=rand()%100;
		if(temp1>temp)
		{
			tasklist[tasknum].data[0]=0;
		}
		else
		{
			switch (herolist.hero[herolist.heroowned[wjqx]].charcter)
			{
			case 4:
				temp1 = 15;
				break;
			case 3:
				temp1 = 5;
				break;
			case 2:
				temp1 = 20;
				break;
			case 1:
				temp1 = 1;
				break;
			case 0:
				temp1 = 10;
				break;
			}
			temp=rand()%100;
			if(temp>temp1)
			{
				tasklist[tasknum].data[0]=0;
			}
			else
			{
				if(rand()%100>10)
				{
					tasklist[tasknum].data[0]=0;
				}
				tasklist[tasknum].data[0]=1;
			}

		}


		return -2;
	}
}

/***********************************************************************
* 说明:     侦察指令
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Scout(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}

	if (citylist.city[citylist.number].money<0)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}
	if (herolist.hero[herolist.heroowned[x]].tili<10)
	{
		/*体力不足*/
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}
	citychooseflag=2;//移动选择城池
	ShowIt(0,0,herolist.heroowned[x]);
	new_flag=1;
	return -2;
}

/***********************************************************************
* 说明:     指令征兵
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Conscription(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	int tili=herolist.hero[herolist.heroowned[x]].tili;
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}
	if (citylist.city[citylist.number].money<1)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}
	if (herolist.hero[herolist.heroowned[x]].tili<12)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}
	int armmax;
	armmax=citylist.city[citylist.number].heart*20;
	if(armmax>(citylist.city[citylist.number].money*10))
	{
		armmax=citylist.city[citylist.number].money*10;
	}
	operate.Init(1,armmax);
	//herolist.hero[herolist.heroowned[x]].tili=herolist.hero[herolist.heroowned[x]].tili-12;
	operate.Show();
	operateflag=1;
	new_flag=1;
	return 3;
}

/***********************************************************************
* 说明:     指令分配
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Allocation(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	int tili=herolist.hero[herolist.heroowned[x]].tili;
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}
	if (citylist.city[citylist.number].money<0)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}
	if (herolist.hero[herolist.heroowned[x]].tili<0)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}
	int armmax;
	armmax=(herolist.hero[herolist.heroowned[x]].degree*10+herolist.hero[herolist.heroowned[x]].wuli+herolist.hero[herolist.heroowned[x]].zili)*10;
	if(armmax>herolist.hero[herolist.heroowned[x]].bingli+citylist.city[citylist.number].soldierspace)
	{
		armmax=herolist.hero[herolist.heroowned[x]].bingli+citylist.city[citylist.number].soldierspace;
	}

	if (armmax == 0)
	{
		Message(GetStrText("NOTE_STR6"),0,300,15,1);
		return -1;
	}

	operate.Init(1,armmax);
	//herolist.hero[herolist.heroowned[x]].tili=herolist.hero[herolist.heroowned[x]].tili-12;
	operate.Show();
	operateflag=9;
	new_flag=1;
	return 3;
}

/***********************************************************************
* 说明:     指令掠夺
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Plunder(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOPERSON"),0,300,15,1);
		return -2;
	}

	if (citylist.city[citylist.number].money<0)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR8"),0,300,15,1);
		return -1;
	}
	if (herolist.hero[herolist.heroowned[x]].tili<20)
	{
		/*金钱不足*/
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}
	//searchflag=true;策略结束后响应
	tasknum++;
	OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,tasknum);
	tasklist[tasknum].isend=0;

	tasklist[tasknum].event=PLUNDERTASK;

	tasklist[tasknum].heronum=herolist.heroowned[x];
	tasklist[tasknum].citynum=citylist.number;

	herolist.hero[herolist.heroowned[x]].tili=herolist.hero[herolist.heroowned[x]].tili-20;
	herolist.hero[herolist.heroowned[x]].inlistflag=0;
	ShowIt(0,0,herolist.heroowned[x]);
	new_flag=1;
	return 0;
}

/***********************************************************************
* 说明:     指令出征
* 输入参数: 无
* 返回值  : 
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2017-4-22       完成基本功能
***********************************************************************/
int GameMap::Order_Expedition(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	OverflowCheck(__FILE__,__LINE__,HEROMAX,herolist.heroowned[x]);
	OverflowCheck(__FILE__,__LINE__,CITYMAX,citylist.number);
	int heart=citylist.city[citylist.number].heart;
	if(herolist.heronum==0)
	{
		if(new_flag==0)Message(GetStrText("STR_NOFIGHTER"),0,300,15,1);
		return -2;
	}

	if (herolist.hero[herolist.heroowned[x]].tili<8)
	{
		Message(GetStrText("NOTE_STR9"),0,300,15,1);
		return -1;
	}
	new_flag=1;
	if(outflag==0)
	{
		zujiang=herolist.heroowned[x];
		for(int i=0;i<10;i++)warherono[i]=-1;
		OverflowCheck(__FILE__,__LINE__,HEROMAX,zujiang);
		herolist.hero[zujiang].inlistflag=2;
	}

	outflag++;		
	if(outflag==10||herolist.heronum==1)
	{
		tmp0[1]=outflag;
		outflag=0;
		return 5;
	}
	return 4;
}

/***********************************************************************
* 说明:     GameMap类城市指令函数
* 输入参数: int x——英雄在城市队列中序号
* 返回值  : 0——正常返回 ，-1——返回，不做操作，-2——返回，需发送escape消息
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20       完成基本功能
***********************************************************************/
int GameMap::GetOrder(int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	switch(ngthird1)
	{
	case RECLAIM:
		{//开垦;完成
			return Order_Reclaim(x);
		}
	case INVESTMENT:
		{//招商;完成
			return Order_Investment(x);
		}
	case SEARCH:
		//搜寻;完成
		{
			return Order_Search(x);
		}
	case GOVERN:	
		{//治理;完成
			return Order_Govern(x);
		}
	case TOUR:
		{//出巡;完成
			return Order_Tour(x);
		}
	case SURRENDER:
		{//招降;完成
			return Order_Surrender(x);
		}
	case BEHEAD:
		{//处斩;完成
			return Order_Behead(x);
		}
	case EXILE:
		{//流放;完成
			return Order_Exile(x);
		}
	case AWARD:		
		{//赏赐;完成
			return Order_Award(x);
		}
	case CONFISCATE:		
		{//没收;完成
			return Order_Confiscate(x);
		}
	case TRADE:
		{//交易;完成
			return Order_Trade(x);
		}
	case BANQUET:		
		{//宴请;完成
			return Order_Banquet(x);

		}
	case TRANSPORT:
		{//输送;完成
			return Order_Transport(x);
		}
	case MOVE:
		{//移动;完成
			return Order_Move(x);
		}
	case ALIENATE:
		{//离间;完成
			return Order_Alienate(x);
		}
	case SOLICIT:		
		{//招揽;完成
			return Order_Solicit(x);
		}
	case INSTIGATION:
		{//策反;完成
			return Order_Instigation(x);
		}
	case ANTI:
		{//反间;
			return Order_Anti(x);
		}
	case CAPITULATE:
		{//劝降;完成
			return Order_Capitulate(x);
		}
	case SCOUT:		
		{//侦察;完成
			return Order_Scout(x);
		}
	case CONSCRIPTION:
		{//征兵;完成
			return Order_Conscription(x);
		}
	case ALLOCATION:
		{//分配;完成
			return Order_Allocation(x);
		}
	case PLUNDER:
		{//掠夺;完成
			return Order_Plunder(x);
		}
	case EXPEDITION:	
		{//出征;未完成
			return Order_Expedition(x);
		}
	}
	return 0;

}

/***********************************************************************
* 说明:     GameMap类城市指令结果函数
* 输入参数: int fa——显示参数,int in——显示参数,int x——英雄序号
* 返回值  : 无
* 功能	   : 城市指令
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-20       完成基本功能
***********************************************************************/
void GameMap::ShowIt(int fa,int in,int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	char text[30];
	char text1[30];
	char name[NORMALSTRLEN];
	char name1[NORMALSTRLEN];
	char name2[NORMALSTRLEN];
	if(fa==-1)
	{
		sprintf_s(name,"%s",GetStrText("P_SAY_STR31"));
	}

	switch(ngthird1)
	{
	case RECLAIM:
		sprintf_s(name,"%s",GetStrTextSpilted("STR_RP3",0,7));
		sprintf_s(text,"%d(+%d) 。",in,fa);
		break;
	case INVESTMENT:
		sprintf_s(name,"%s",GetStrTextSpilted("STR_RP6",0,7));
		sprintf_s(text,"%d(+%d) 。",in,fa);
		break;
	case SEARCH:
		{
			int rr=rand()%3;
			if(rr==0)
			{
				//sprintf_s(name,"%s","此事便交给我，");
				//sprintf_s(name1,"%s","有利的消息我都");
				//sprintf_s(name2,"%s","会带回来。    ");
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR21",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR21",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR21",2,7));
			}
			else if(rr==1)
			{
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR22",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR22",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR22",2,7));

			}
			else
			{
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR23",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR23",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR23",2,7));

			}
			if(herolist.hero[x].owner==(herolist.hero[x].no+1))
			{
				if(rr==0)
				{
					sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR24",0,7));
					sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR24",1,7));
					sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR24",2,7));
				}
				else if(rr==1)
				{
					sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR25",0,7));
					sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR25",1,7));
					sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR25",2,7));
				}
				else
				{
					sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR26",0,7));
					sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR26",1,7));
					sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR26",2,7));
				}
			}
			break;
		}
	case GOVERN:
		sprintf_s(name,"%s",GetStrTextSpilted("STR_RP8",0,7));
		sprintf_s(name1,"%s",GetStrTextSpilted("STR_RP8",1,7));
		sprintf_s(text,"%d(+%d",in,fa);
		sprintf_s(name2,"%s",") 。          ");
		break;
	case TOUR:
		sprintf_s(name,"%s",GetStrTextSpilted("STR_RP7",0,7));
		sprintf_s(text,"%d",in);
		sprintf_s(text1,"%d)。",fa);
		break;
	case SURRENDER:
		sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR41",0,7));
		sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR41",1,7));
		sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR41",2,7));
		break;
	case BEHEAD:
		{
			int rr=rand()%3;
			if(rr==0)
			{
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR4",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR4",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR4",2,7));
			}
			else if(rr==1)
			{
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR5",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR5",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR5",2,7));

			}
			else
			{
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR6",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR6",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR6",2,7));

			}
			break;
		}
	case AWARD:
		{
			if(herolist.hero[x].owner==(herolist.hero[x].no+1))return;
			int rr=rand()%3;
			if(rr==0)
			{
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR10",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR10",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR10",2,7));
			}
			else if(rr==1)
			{
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR11",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR11",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR11",2,7));

			}
			else
			{
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR12",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR12",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR12",2,7));

			}
			break;
		}
	case CONFISCATE:
		{
			if(herolist.hero[x].owner==(herolist.hero[x].no+1))return;
			int rr=rand()%3;
			if(rr==0)
			{
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR7",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR7",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR7",2,7));
			}
			else if(rr==1)
			{
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR8",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR8",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR8",2,7));

			}
			else
			{
				sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR9",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR9",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR9",2,7));

			}
			break;
		}
	case BANQUET:
		sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR40",0,7));
		sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR40",1,7));
		break;
	case TRANSPORT:
	case MOVE:
	case SCOUT:
	case EXPEDITION:
		sprintf_s(name,"%s",GetStrText("STR_OBJ"));
		break;

	case PLUNDER:
		sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR27",0,7));
		sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR27",1,7));
		break;


	}
	Show(0);

	MyCreateFont(0.8);
	HFONT	h = t_h;
	HFONT oldh=(HFONT)SelectObject(hdcTmp,h);
	MySetTextColor(FONTB,USEHDCTMP);

	if(color==0)
	{
		MySetShowStyle();
		HPEN hpen=t_hpen;
		HPEN oldhpen=(HPEN)SelectObject(hdcTmp,hpen);


		Rectangle(hdcTmp,20,250,780,500); 	
		SelectObject(hdcTmp,oldhpen);
		DeleteObject(hpen);


	}	

	else
	{
		ShowCG(0,"Res\\Fight\\fight_imformation.sbp",20,200);


	}





	if(fa==-1)
	{
		TextOut(hdcTmp,300,300,name,strlen(name));
	}

	switch(ngthird1)
	{
	case RECLAIM:
	case INVESTMENT:
		TextOut(hdcTmp,300,300,name,strlen(name));
		TextOut(hdcTmp,330,370,text,strlen(text));
		break;
	case SEARCH:
	case SURRENDER:
	case BEHEAD:
	case AWARD:
	case CONFISCATE:
		TextOut(hdcTmp,300,300,name,strlen(name));
		TextOut(hdcTmp,300,370,name1,strlen(name1));
		TextOut(hdcTmp,300,440,name2,strlen(name2));
		break;
	case GOVERN:
		TextOut(hdcTmp,300,300,name,strlen(name));
		TextOut(hdcTmp,300,370,name1,strlen(name1));
		TextOut(hdcTmp,500,370,text,strlen(text));
		TextOut(hdcTmp,300,440,name2,strlen(name2));
		break;
	case TOUR:
		TextOut(hdcTmp,300,300,name,strlen(name));
		TextOut(hdcTmp,500,300,text,strlen(text));
		TextOut(hdcTmp,300,370,text1,strlen(text1));
		break;
	case BANQUET:
	case PLUNDER:
		TextOut(hdcTmp,300,300,name,strlen(name));
		TextOut(hdcTmp,300,370,name1,strlen(name1));
		break;
	case TRANSPORT:
	case MOVE:
	case SCOUT:
	case EXPEDITION:
		TextOut(hdcTmp,300,300,name,strlen(name));
		break;

	}

	switch(choice)
	{
	case DZNQ:
		head.Init("Res\\Head\\1dznq.sbp",x);
		break;
	case CCJQ:	
		head.Init("Res\\Head\\2ccjq.sbp",x);
		break;
	case CBZZ:
		head.Init("Res\\Head\\3cbzz.sbp",x);
		break;
	case SGDL:
		head.Init("Res\\Head\\4sgdl.sbp",x);
		break;
	default:
		{
			char name[NORMALSTRLEN];
			sprintf_s(name,"Res\\Head\\period%d.sbp",choice+1);
			head.Init(name,x);
		}
		break;
	}
	head.Show(100,290);
	char heroname[20];
	OverflowCheck(__FILE__,__LINE__,HEROMAX,x);
	sprintf_s(heroname,"%s",t_heroName[x]);
	TextOut(hdcTmp,120,430,heroname,strlen(heroname));
	SelectObject(hdcTmp,oldh);
	DeleteObject(h);
	SetTextColor(hdcTmp,RGB(0, 0, 0));
}

int GameMap::GetCityNum()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int number;
	//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);
	return number;
}

int GameMap::ArriveEnable()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int num=GetCityNum()+1;

	//ChangeRes(name);
	ifstream infile("Res\\arrive.sdt",ios::in);;
	int tmpa;
	int tmpb;
	while(infile>>tmpa)
	{
		infile>>tmpb;
		if(tmpa==currentcitynum&&tmpb==num)
		{
			infile.close();	
			//ChangeRes(name);
			return 1;
		}

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

void GameMap::ShowEnd()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	char str[30];
	for(int ff=0;ff<HEROMAX;ff++)
	{
		if(herolist.hero[ff].no+1==herolist.hero[ff].owner&&herolist.hero[ff].no+1!=ownernum)
		{

			sprintf_s(str,"%s",t_heroName[ff]);
			TimerMessage(str,GetStrText("TACTIC_STR"),100,450,10,1,100);//"策略中‥‥‥"
		}
	}
}

void GameMap::GetCityPrefect()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	/*int tp=herolist.count+herolist.statf;
	int ww=GetCityNum();
	citylist.city[ww].ownto=herolist.heroowned[0];
	int zili=herolist.hero[herolist.heroowned[0]].zili;
	int kk;
	for(kk=1;kk<herolist.heronum;kk++)
	{
	if(herolist.hero[herolist.heroowned[kk]].zili>zili)
	{
	citylist.city[ww].ownto=herolist.heroowned[kk];
	zili=herolist.hero[herolist.heroowned[kk]].zili;
	}
	}*/
	int tmpwj[HEROMAX];//20161216修正为300防止溢出
	int op=0;
	for(int ya=0;ya<CITYMAX;ya++)
	{
		op=0;
		tmpwj[0]=-1;
		for(int yb=0;yb<HEROMAX;yb++)
		{

			if((herolist.hero[yb].hiscity-1)==ya&&herolist.hero[yb].owner!=0&&herolist.hero[yb].owner<HEROMAX&&herolist.hero[yb].inlistflag!=3)
			{
				tmpwj[op]=yb;
				op++;
			}

		}
		if(tmpwj[0]==-1)
		{
			citylist.city[ya].ownto=0;
			continue;
		}
		OverflowCheck(__FILE__,__LINE__,HEROMAX,tmpwj[0]);
		int zili=herolist.hero[tmpwj[0]].zili;
		citylist.city[ya].ownto=tmpwj[0]+1;
		if(citylist.city[ya].ownto==citylist.city[ya].owner)
		{
			;
		}
		else
		{
			int kk=0;
			for(kk=1;kk<op;kk++)
			{
				OverflowCheck(__FILE__,__LINE__,HEROMAX,kk);
				OverflowCheck(__FILE__,__LINE__,HEROMAX,tmpwj[kk]);
				if(herolist.hero[tmpwj[kk]].zili>zili)
				{
					citylist.city[ya].ownto=tmpwj[kk]+1;
					zili=herolist.hero[tmpwj[kk]].zili;
				}
			}
		}
	}
}

int GameMap::GetClever(int ya)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int tmpwj[100];
	int op=0;
	int clever;
	tmpwj[0]=-1;
	for(int yb=0;yb<HEROMAX;yb++)
	{

		if((herolist.hero[yb].hiscity-1)==ya&&herolist.hero[yb].owner!=0&&herolist.hero[yb].owner<HEROMAX)
		{
			tmpwj[op]=yb;
			op++;
		}

	}
	if(tmpwj[0]==-1)return 0;
	OverflowCheck(__FILE__,__LINE__,HEROMAX,tmpwj[0]);
	int zili=herolist.hero[tmpwj[0]].zili;
	clever=tmpwj[0]+1;
	int kk=0;
	for(kk=1;kk<op;kk++)
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,kk);
		OverflowCheck(__FILE__,__LINE__,HEROMAX,tmpwj[kk]);
		if(herolist.hero[tmpwj[kk]].zili>zili&&herolist.hero[tmpwj[kk]].bingli>0)//增加条件：兵力不为0
		{
			clever=tmpwj[kk]+1;
			zili=herolist.hero[tmpwj[kk]].zili;
		}
	}

	return clever;
}

int GameMap::IsCity()
{
	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)
		{
			infile.close();	
			//ChangeRes(name);
			return 1;
		}

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

void GameMap::AddMoney()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	for (int c = 0;c < 40;c ++)
	{
		citylist.city[c].money += citylist.city[c].business/2;
		if (citylist.city[c].money  > 30000)
		{
			citylist.city[c].money=30000;
		}

	}
}

void GameMap::AddFood()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	for (int c = 0;c < 40;c ++)
	{
		citylist.city[c].foods += citylist.city[c].agriculture/4;
		if (citylist.city[c].foods  > 30000)
		{
			citylist.city[c].foods=30000;
		}
	}
}

void GameMap::DoEndEvent()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	if(warlistflag==2)
	{
		WarRun();
		return;
	}
	if(warinflag==0)
	{
		//粮食金钱增加
		if(date.month==6||date.month==10)
		{
			AddFood();
		}
		if(date.month%3==0)
		{
			AddMoney();
		}
		for (int c = 0;c < CITYMAX;c ++)//增加人口
		{
			citylist.city[c].people += 50;
			if (citylist.city[c].people>citylist.city[c].peoplemax)
			{
				citylist.city[c].people=citylist.city[c].peoplemax;
			}
		}
		date.Caculate();
		herolist.ClearInListFlag();

		//ChangeOwnerNum();
		//AI策略
		ComputerStatic();
		//队列执行
		TaskListRun();
		//战争进行
		WarRun();
		if(warlistflag==1)
		{
			return;
		}
		if(warinflag>0)return;
	}

	if(warinflag>0)
	{
		if(newownerflag==2)
		{
			newownerflag=0;
			goto yui;
		}

		AfterWar(reqresult,reqcitynum,reqcityto);
		reqresult=0;
		captiveflag=0;
		endthisflag=0;
		if(newownerflag==1)return;
yui:	
		WarRun();
		if(warlistflag==1)
		{
			return;
		}
		if(warinflag>0)return;
	}
	if(warinflag==-2)goto yuq;
	if(warinflag==-1)
	{
		if(newownerflag==2)
		{
			newownerflag=0;
			goto yuq;
		}
		{
			int utflag=0;
			int i;
			for(i=1;i<TASKLISTMAX;i++)
			{
				if((tasklist[i].event==EXPEDITIONTASK||tasklist[i].event==DEFENCETASK||tasklist[i].event==WARTASK)&&GetClever(tasklist[i].data[0]-1)!=0)
				{
					utflag=1;		
				}
			}
			if(utflag)
			{
				AfterWar(reqresult,reqcitynum,reqcityto);
				if(newownerflag==1)return;
			}
			reqresult=0;
			captiveflag=0;
			endthisflag=0;
		}
yuq:
		WarRun();//保证无空城
		//清空队列
		for(int i=1;i<TASKLISTMAX;i++)
		{		
			tasklist[i].Init();
		}
		tasknum=0;
		//武将信息更新,体力+4，年龄+1，自然死亡
		HeroUpdate();
		//城市信息更新
		CityUpdate();

		//城市状态获取及报告
		GetCityState();
		//判断是否胜利或失败
		IsWinOrLose();
		KeyDown(0);
		warinflag=0;
		herolist.ClearInListFlag();
		tmpflag=0;
	}

}

void GameMap::CityUpdate()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	citynumber=0;
	for(int c=0;c<CITYMAX;c++)
	{
		if(citylist.city[c].owner==ownernum)
		{
			citynumber++;
		}
	}
	//GetCityPrefect();
}

void GameMap::HeroUpdate()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	heronumber=0;
	for (int c = 0;c < HEROMAX;c ++)
	{
		HeroCheck(c);
		herolist.hero[c].tili+=4;
		if (120<=herolist.hero[c].age)
		{
			if (rand()%100 < 20)//自然死亡
			{
				herolist.hero[c].hiscity=0;

				if((herolist.hero[c].owner-1)==c&&c==(ownernum-1))//君主死亡
				{
					TimerMessage("君主老死，请另立新君","",50,280,12,1,1000);
					herolist.hero[c].owner=0;
					herolist.Init(unx,uny,choice,25,ownernum);
					herolist.Show(0);
					newownerflag=1;
					swFlag=1;
				}
				herolist.hero[c].owner=0;

			}
		}
		if(herolist.hero[c].tili>100)
		{
			herolist.hero[c].tili=100;
		}
		if(date.month==1)
		{
			herolist.hero[c].age++;
		}
		if(herolist.hero[c].owner==ownernum)
		{
			heronumber++;
		}
		//自然出现，暂时不实现
	}

}

void GameMap::GetCityState()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int rnd;
	int as,df;
	for (int c=0;c<CITYMAX;c++)
	{
		int sdflag=0;
		df=citylist.city[c].soldierspace;
		for(int bb=0;bb<HEROMAX;bb++)
		{
			as=herolist.hero[bb].bingli;
			if((herolist.hero[bb].hiscity-1)==c&&(citylist.city[c].statue==2||citylist.city[c].statue==3))
			{
				if(sdflag==0)
				{
					sdflag=1;
				}
			}
			else if((herolist.hero[bb].hiscity-1)==c&&citylist.city[c].statue==4)
			{
				if(sdflag==0)
				{

					sdflag=2;
				}

			}
			if((herolist.hero[bb].hiscity-1)==c)
			{
				df+=as;
			}
			herolist.hero[bb].bingli=as;
		}
		if(sdflag==2)
		{
			as=as/2;
		}
		else if(sdflag==1)
		{
			as=as-as/4;
		}
		df/=50;
		int food=citylist.city[c].foods;
		if(food>df)
		{
			food-=df;
		}
		else
		{
			for(int bc=0;bc<HEROMAX;bc++)
			{
				if((herolist.hero[bc].hiscity-1)==c)
				{
					herolist.hero[bc].bingli/=2;
				}
			}
			food = 0;
			/*闹饥荒*/
			citylist.city[c].statue = 1;
			citylist.city[c].heart = citylist.city[c].heart-citylist.city[c].heart/20;
			citylist.city[c].business = citylist.city[c].business-citylist.city[c].business/20;
			citylist.city[c].soldierspace/=2;
			citylist.city[c].people = citylist.city[c].people-citylist.city[c].people/4;

			//herolist.ChangeOwnerNum(unum);
			if(citylist.city[c].owner==ownernum)
			{
				//tasknum++;
				//tasklist[tasknum].isend=0;

				//tasklist[tasknum].event=11;
				//tasklist[tasknum].heronum=citylist.city[c].ownto;
				//tasklist[tasknum].citynum=c;
				//tasklist[tasknum].data[0]=citylist.city[c].statue;//城市状态
				if(citylist.city[c].ownto!=0)
				{
					ReportCityState(c,citylist.city[c].statue,citylist.city[c].ownto);//报告城市状态
				}
				else
				{
					ReportCityState(c,citylist.city[c].statue,citylist.city[c].owner);//报告城市状态
				}

			}
		}
		citylist.city[c].foods=food;
	}


	if (date.month%3!=0)
	{

		for (int c = 0;c < CITYMAX;c ++)
		{
			rnd = 1 + rand()%4;
			if (citylist.city[c].disease>rnd)
			{
				citylist.city[c].disease-=rnd;
			}
			rnd=rand()%100;
			if (rnd >citylist.city[c].disease&&citylist.city[c].statue==0)
			{
				rnd=rand()%20;
				switch (rnd)
				{
				case 0:		//遭旱灾
					citylist.city[c].statue = 2;
					break;
				case 1:		//遭水灾
					citylist.city[c].statue = 3;
					break;
				case 2:		//暴动
					if (rnd >citylist.city[c].heart )
					{
						citylist.city[c].statue = 4;
					}
					break;
				}
				if(citylist.city[c].statue!=0)
				{
					int heron=citylist.city[c].owner;
					if(heron==ownernum)
					{
						if(citylist.city[c].ownto!=0)
						{
							ReportCityState(c,citylist.city[c].statue,citylist.city[c].ownto);//报告城市状态
						}
						else
						{
							ReportCityState(c,citylist.city[c].statue,citylist.city[c].owner);//报告城市状态
						}
					}
				}
			}
			else if (citylist.city[c].statue == 1)
			{
				if (citylist.city[c].foods!=0)
				{
					citylist.city[c].statue=0;
				}
				else
				{
					citylist.city[c].heart = citylist.city[c].heart-citylist.city[c].heart/20;
					citylist.city[c].business = citylist.city[c].business-citylist.city[c].business/20;
					citylist.city[c].soldierspace/=2;
					citylist.city[c].people = citylist.city[c].people-citylist.city[c].people/4;
					citylist.city[c].agriculture = citylist.city[c].agriculture-citylist.city[c].agriculture/20;
				}
			}
			else if (citylist.city[c].statue == 2)
			{
				if (rnd<citylist.city[c].disease)
				{
					citylist.city[c].statue=0;
				}
				else
				{
					citylist.city[c].foods = citylist.city[c].foods-citylist.city[c].foods/20;
					citylist.city[c].soldierspace=citylist.city[c].soldierspace-citylist.city[c].soldierspace/4;
					citylist.city[c].people = citylist.city[c].people-citylist.city[c].people/4;
					citylist.city[c].agriculture = citylist.city[c].agriculture-citylist.city[c].agriculture/20;
				}
			}
			else if (citylist.city[c].statue == 3)
			{
				if (rnd<citylist.city[c].disease)
				{
					citylist.city[c].statue=0;
				}
				else
				{
					citylist.city[c].foods = citylist.city[c].foods-citylist.city[c].foods/20;
					citylist.city[c].business  = citylist.city[c].business-citylist.city[c].business/10;
					citylist.city[c].money = citylist.city[c].money-citylist.city[c].money/10;
					citylist.city[c].soldierspace=citylist.city[c].soldierspace-citylist.city[c].soldierspace/4;
					citylist.city[c].people = citylist.city[c].people-citylist.city[c].people/4;
					citylist.city[c].agriculture = citylist.city[c].agriculture-citylist.city[c].agriculture/20;
				}
			}
			else if (citylist.city[c].statue == 4)
			{
				if (rnd<citylist.city[c].heart )
				{
					citylist.city[c].statue=0;
				}
				else
				{
					citylist.city[c].foods = citylist.city[c].foods-citylist.city[c].foods/20;
					citylist.city[c].business  = citylist.city[c].business-citylist.city[c].business/20;
					citylist.city[c].money = citylist.city[c].money-citylist.city[c].money/20;
					citylist.city[c].heart = citylist.city[c].heart-citylist.city[c].heart/10;
					citylist.city[c].soldierspace/=2;
					citylist.city[c].agriculture = citylist.city[c].agriculture-citylist.city[c].agriculture/20;
				}
			}

		}
	}

}

void GameMap::ReportCityState(int c,int statue,int ownto)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	char name[NORMALSTRLEN];
	char name1[10];
	char name2[NORMALSTRLEN];
	switch(statue)
	{
	case 1:
		sprintf_s(name2,"%s %s",GetStrText("STR_RP1"),GetStrText("CITY_STATE_STR2"));
		break;
	case 2:
		sprintf_s(name2,"%s %s",GetStrText("STR_RP1"),GetStrText("CITY_STATE_STR3"));
		break;
	case 3:
		sprintf_s(name2,"%s %s",GetStrText("STR_RP1"),GetStrText("CITY_STATE_STR4"));
		break;
	case 4:
		sprintf_s(name2,"%s %s",GetStrText("STR_RP1"),GetStrText("CITY_STATE_STR5"));
		break;
	}

	sprintf_s(name1,"%s",t_cityName[c]);
	sprintf_s(name,"%s",GetStrText("STR_RP2"));
	Show(0);
	MyCreateFont(0.8);
	HFONT	h = t_h;
	HFONT oldh=(HFONT)SelectObject(hdcTmp,h);
	MySetTextColor(FONTB,USEHDCTMP);
	if(color==0)
	{
		MySetShowStyle();
		HPEN hpen=t_hpen;
		HPEN oldhpen=(HPEN)SelectObject(hdcTmp,hpen);

		Rectangle(hdcTmp,20,250,780,500); 	
		SelectObject(hdcTmp,oldhpen);
		DeleteObject(hpen);


	}
	else
	{
		ShowCG(0,"Res\\Fight\\fight_imformation.sbp",20,200);


	}



	TextOut(hdcTmp,300,330,name1,strlen(name1));
	TextOut(hdcTmp,410,330,name2,strlen(name2));
	TextOut(hdcTmp,300,370,name,strlen(name));

	switch(choice)
	{
	case DZNQ:
		head.Init("Res\\Head\\1dznq.sbp",ownto-1);
		break;
	case CCJQ:	
		head.Init("Res\\Head\\2ccjq.sbp",ownto-1);
		break;
	case CBZZ:
		head.Init("Res\\Head\\3cbzz.sbp",ownto-1);
		break;
	case SGDL:
		head.Init("Res\\Head\\4sgdl.sbp",ownto-1);
		break;
	default:
		{
			char name[NORMALSTRLEN];
			sprintf_s(name,"Res\\Head\\period%d.sbp",choice+1);
			head.Init(name,ownto-1);
		}
		break;
	}
	head.Show(100,290);
	char heroname[20];
	OverflowCheck(__FILE__,__LINE__,HEROMAX,ownto-1);
	sprintf_s(heroname,"%s",t_heroName[ownto-1]);
	TextOut(hdcTmp,120,430,heroname,strlen(heroname));
	BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);
	Delay(500);
	Show(0);
	SelectObject(hdcTmp,oldh);
	DeleteObject(h);

	SetTextColor(hdcTmp,RGB(0,0,0));

}

void GameMap::ComputerStatic()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int TacticOddsIH,TacticOddsD;

	for(int c=0;c<CITYMAX;c++)
	{
		int heron=citylist.city[c].owner;
		OverflowCheck(__FILE__,__LINE__,HEROMAX,heron);
		switch(herolist.hero[heron].charcter )
		{
		case 0:
			TacticOddsIH=70;//50;
			TacticOddsD=80;
			break;
		case 1:
			TacticOddsIH=60;//40;
			TacticOddsD=70;
			break;
		case 2:
			TacticOddsIH=50;//30;
			TacticOddsD=70;
			break;
		case 3:
			TacticOddsIH=30;//20;
			TacticOddsD=40;
			break;
		case 4:
			TacticOddsIH=15;//10;
			TacticOddsD=20;
			break;
		}
		//herolist.ChangeOwnerNum(unum);
		if(heron!=ownernum)
		{
			citylist.city[c].statue=0;
			citylist.city[c].disease++;
			if(citylist.city[c].disease>100)citylist.city[c].disease=100;
			if(citylist.city[c].foods <100)citylist.city[c].foods=500;
			if(citylist.city[c].money>10000)citylist.city[c].money=5000;
			int rnd=rand()%100;
			if(TacticOddsIH>rnd)
			{
				ComputerTacticInterior(c);
				ComputerTacticHarmonize(c);
			}
			else if(TacticOddsD>rnd)	
			{
				ComputerTacticDiplomatism(c);
			}
			else
			{
				ComputerTacticArmament(c);

				//ChangeDataToSave();	
				//save.Write(0);
				//TimerMessage("存储中. . .","",50,280,12,1,1000);
			}


		}
	}
}

void GameMap::ComputerTacticInterior(int c)//内政
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int agriculture=citylist.city[c].agriculture;
	int agriculturemax=citylist.city[c].agriculturemax;
	int business=citylist.city[c].business;
	int businessmax=citylist.city[c].businessmax;
	int people=citylist.city[c].people;
	int peoplemax=citylist.city[c].peoplemax;
	int heart=citylist.city[c].heart;

	for(int i=0;i<HEROMAX;i++)
	{
		if((herolist.hero[i].hiscity-1)==c&&herolist.hero[i].owner!=0&&herolist.hero[i].owner<HEROMAX)
		{
			int rnd=rand()%5;
			switch(rnd)
			{
			case 0://开垦
				agriculture+=200;
				if(agriculture>agriculturemax)
				{
					agriculture=agriculturemax;
				}

				break;
			case 1://招商
				business+=200;
				if(business>businessmax)
				{
					business=businessmax;
				}

				break;
			case 2:
				{	//搜寻,完成
					int citynum=c;
					int heronum=i;
					int pss=rand()%4;
					//pss=1;
					int rnd;
					int dateq;
					OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
					int zili=herolist.hero[heronum].zili;
					switch(pss)
					{
					case 1:
						{	
							pss=0;
							rnd=rand()%150;
							//rnd=0;
							if(rnd<zili)
							{
								switch(rnd%2)
								{
								case 0:
									{//搜寻武将
										int k[HEROMAX];
										int pcount=0;
										for(int i=0;i<HEROMAX;i++)
										{
											if((herolist.hero[i].hiscity-1)==citynum&&herolist.hero[i].owner==0)
											{
												k[pcount]=i;
												OverflowCheck(__FILE__,__LINE__,HEROMAX,pcount);
												pcount++;//空闲武将数
											}
										}

										if(pcount)
										{
											int sp=rand()%pcount;
											int count=sp;
											OverflowCheck(__FILE__,__LINE__,HEROMAX,count);
											OverflowCheck(__FILE__,__LINE__,HEROMAX,k[count]);
											int fo=herolist.hero[k[count]].hisfinder;

											if(fo-1==heronum)//指定武将搜索时
											{
												rnd=1;
												pss=1;
												herolist.hero[k[count]].owner=citylist.city[citynum].owner;
												herolist.hero[k[count]].heart=70+rand()%30;
												dateq=k[count];
											}
											else if(!fo)//随机武将搜索
											{
												rnd=rand()%110;
												//rnd=0;
												if(rnd<zili)//同意
												{
													rnd=1;
													pss=1;
													herolist.hero[k[count]].owner=citylist.city[citynum].owner;
													herolist.hero[k[count]].heart=70+rand()%30;
													dateq=k[count];
												}
												else//不同意
												{
													rnd=2;
													pss=1;
													dateq=-k[count];
												}
											}
											else
											{
												rnd=1;
												pss=5;
												dateq=0;
											}
										}
										break;
									}
								case 1:
									{
										//搜索道具
										int k[GOODMAX];
										int pcount=0;
										for(int i=0;i<CITYMAX;i++)
										{
											if((goodlist.good[i].hiscity-1)==citynum&&goodlist.good[i].finded==0)
											{
												k[pcount]=i;
												OverflowCheck(__FILE__,__LINE__,GOODMAX,pcount);
												pcount++;//空闲武将数
											}
										}
										if(pcount)
										{
											
											int sp=rand()%pcount;
											int count=sp;
											OverflowCheck(__FILE__,__LINE__,GOODMAX,count);
											OverflowCheck(__FILE__,__LINE__,GOODMAX,k[count]);
											int fo=goodlist.good[k[count]].hisfinder;
											rnd=0;
											if(fo-1==heronum)//指定武将搜索时
											{
												rnd=1;
												pss=2;
												goodlist.good[k[count]].owner=heronum;
												dateq=k[count];
											}
											else if(!fo)//随机武将搜索
											{
												rnd=rand()%110;
												//rnd=0;
												if(rnd<zili)
												{
													rnd=1;
													pss=2;
													goodlist.good[k[count]].finded=1;
													dateq=k[count];
												}
												else
												{
													rnd=2;
													pss=0;
												}
											}

										}

										break;
									}
								}
							}

							break;
						}
					case 2:
						{	
							OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
							OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
							int zili=herolist.hero[heronum].zili;
							rnd = 10 + rand() % (zili * 2);
							citylist.city[citynum].money  += rnd;
							pss=3;
							dateq=rnd;
							break;
						}
					case 3:
						{
							OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
							OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
							int zili=herolist.hero[heronum].zili;
							rnd = 10 + rand() % (zili * 2);
							citylist.city[citynum].foods  += rnd;
							pss=4;
							dateq=rnd;
							break;
						}
					}
					//ShowItAfter(tasklist[i].event,pss,dateq,heronum);

					break;
				}
			case 3://出巡
				heart+=4;
				if(heart>100)
				{
					heart=100;
				}

				break;
			}
			citylist.city[c].agriculture=agriculture;
			citylist.city[c].business=business;
			citylist.city[c].people=people;
			citylist.city[c].heart=heart;
			//删除hero(无需增加)
		}
	}

}

void GameMap::ComputerTacticDiplomatism(int c)//外交
{
	wlogfile(1,__FUNCTION__,"开始",0);
	for(int i=0;i<HEROMAX;i++)
	{
		if((herolist.hero[i].hiscity-1)==c&&herolist.hero[i].owner!=0&&herolist.hero[i].owner<HEROMAX)
		{
			int rnd=rand()%8;
			int ecount=0;
			int ecount1=0;
			int ecount2=0;
			int b[HEROMAX];
			int b1[HEROMAX];
			int b2[HEROMAX];
			for(int j=0;j<HEROMAX;j++)
			{
				if((herolist.hero[j].hiscity-1)==c&&herolist.hero[j].iscaptive == 1/*herolist.hero[j].owner>HEROMAX*/)
				{
					OverflowCheck(__FILE__,__LINE__,HEROMAX,ecount);
					b[ecount]=j;
					ecount++;
				}
				if(herolist.hero[j].owner!=0&&herolist.hero[j].iscaptive == 0/*&&herolist.hero[j].owner<HEROMAX*/&&herolist.hero[j].owner!=ownernum)
				{
					OverflowCheck(__FILE__,__LINE__,HEROMAX,ecount1);
					b1[ecount1]=j;
					ecount1++;
				}
				if(herolist.hero[j].owner==j+1&&herolist.hero[j].owner!=ownernum)
				{
					OverflowCheck(__FILE__,__LINE__,HEROMAX,ecount2);
					b2[ecount2]=j;
					ecount2++;
				}

			}
			if(ecount)
			{
				rnd=0;
			}
			//rnd=5;
			switch(rnd)
			{
			case 0:
				//招降
				if(ecount)
				{
					rnd=rand()%ecount;
					OverflowCheck(__FILE__,__LINE__,HEROMAX,rnd);
					OverflowCheck(__FILE__,__LINE__,HEROMAX,b[rnd]);
					herolist.hero[b[rnd]].owner=herolist.hero[i].owner;
					herolist.hero[b[rnd]].iscaptive = 0;
					herolist.hero[b[rnd]].bingli=800;
					//随机 必定获取一个俘虏归顺,完成
				}
				break;
			case 1:
				//处斩
				if(ecount)
				{
					rnd=rand()%ecount;
					OverflowCheck(__FILE__,__LINE__,HEROMAX,rnd);
					OverflowCheck(__FILE__,__LINE__,HEROMAX,b[rnd]);
					herolist.hero[b[rnd]].owner=HEROMAX;
				}
				break;
			case 2:
				//流放
				if(ecount)
				{
					rnd=rand()%ecount;
					OverflowCheck(__FILE__,__LINE__,HEROMAX,rnd);
					OverflowCheck(__FILE__,__LINE__,HEROMAX,b[rnd]);
					herolist.hero[b[rnd]].owner=0;
				}
				break;
			case 3:
				{	//离间，完成
					int heronum=i;
					if(ecount1==0)break;
					int enemynum=b1[rand()%ecount1];
					OverflowCheck(__FILE__,__LINE__,HEROMAX,enemynum);
					OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
					int citynum=herolist.hero[enemynum].hiscity-1;
					int temp=herolist.hero[heronum].zili-herolist.hero[enemynum].zili+50;
					int temp1=rand()%100;
					if(temp1>temp)
					{
						break;
					}
					temp1=rand()%100;
					if(temp1<herolist.hero[enemynum].heart )
					{
						break;
					}
					else
					{
						switch (herolist.hero[enemynum].charcter )
						{
						case 4:
							temp= 5;
							break;
						case 3:
							temp= 30;
							break;
						case 2:
							temp= 40;
							break;
						case 1:
							temp= 30;
							break;
						case 0:
							temp= 50;
							break;
						}

						temp1 = rand() % 100;
						if (temp1 > temp)
						{
							break;
						}
						else
						{
							herolist.hero[enemynum].heart -=4;
							if(herolist.hero[enemynum].heart <0)herolist.hero[enemynum].heart=0;
						}

					}
					break;
				}
			case 4:
				{
					//招揽
					int heronum=i;
					int enemynum=b1[rand()%ecount1];
					OverflowCheck(__FILE__,__LINE__,HEROMAX,enemynum);

					int citynum=herolist.hero[enemynum].hiscity-1;
					int temp=herolist.hero[heronum].zili-herolist.hero[enemynum].zili+50;
					int temp1=rand()%100;
					if(temp1>temp)
					{
						break;
					}
					temp1=rand()%100;
					if(temp1<herolist.hero[enemynum].heart )
					{
						break;
					}
					else
					{
						switch (herolist.hero[enemynum].charcter)
						{
						case 4:
							temp= 5;
							break;
						case 3:
							temp= 20;
							break;
						case 2:
							temp= 30;
							break;
						case 1:
							temp= 40;
							break;
						case 0:
							temp= 15;
							break;
						}

						temp1 = rand() % 100;
						if (temp1 > temp)
						{
							break;
						}
						else
						{
							if(rand()%100>20)break;
							herolist.hero[enemynum].owner =citylist.city[citynum].owner;
							herolist.hero[enemynum].hiscity=citynum+1;
						}

					}
					//ShowItAfter(tasklist[i].event,result,0,tasklist[i].heronum);
					break;
				}
			case 5:
				{
					//策反
					int heronum=i;
					int enemynum=b1[rand()%ecount1];
					int citynum=herolist.hero[enemynum].hiscity-1;
					OverflowCheck(__FILE__,__LINE__,HEROMAX,enemynum);
					OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
					OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
					int temp=herolist.hero[heronum].zili-herolist.hero[enemynum].zili+50;
					int temp1=rand()%100;
					if(temp1>temp)
					{
						break;
					}
					temp1=rand()%100;
					if(temp1<herolist.hero[enemynum].heart )
					{
						break;

					}
					else
					{
						switch (herolist.hero[enemynum].charcter)
						{
						case 4:
							temp= 5;
							break;
						case 3:
							temp= 60;
							break;
						case 2:
							temp= 20;
							break;
						case 1:
							temp= 10;
							break;
						case 0:
							temp= 30;
							break;
						}

						temp1 = rand() % 100;
						if (temp1 > temp)
						{
							break;

						}
						else
						{
							if(rand()%100>20)break;
							if(citylist.city[citynum].owner==citylist.city[citynum].ownto)break;
							herolist.hero[enemynum].owner =enemynum+1;
							herolist.hero[enemynum].heart =100;
							citylist.city[citynum].owner =enemynum;
							for(int j=0;j<HEROMAX;j++)
							{
								if((herolist.hero[j].hiscity -1)==citynum&&herolist.hero[j].owner<HEROMAX&&herolist.hero[j].owner!=0)
								{
									herolist.hero[j].owner =enemynum+1;
								}
							}
							ShowItAfter(6,1,0,enemynum);
						}

					}

					break;
				}
			case 6:
				{
					//劝降
					int heronum=i;
					if(ecount2 == 0)break;//20170330增加修正
					int enemynum=b2[rand()%ecount2];
					int citynum=herolist.hero[enemynum].hiscity-1;
					OverflowCheck(__FILE__,__LINE__,HEROMAX,enemynum);
					OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
					OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
					int temp=herolist.hero[heronum].zili-herolist.hero[enemynum].zili+50;
					int temp1=rand()%100;
					if(temp1>temp)
					{
						break;
					}
					else
					{
						switch (herolist.hero[enemynum].charcter)
						{
						case 4:
							temp1 = 15;
							break;
						case 3:
							temp1 = 5;
							break;
						case 2:
							temp1 = 20;
							break;
						case 1:
							temp1 = 1;
							break;
						case 0:
							temp1 = 10;
							break;
						}
						temp=rand()%100;
						if(temp>temp1)
						{
							break;
						}
						else
						{
							//劝降成功
							if(rand()%100>20)break;
							if(enemynum+1==herolist.hero[heronum].owner)break;
							if(herolist.hero[heronum].owner==ownernum)break;
							herolist.hero[enemynum].owner =herolist.hero[heronum].owner;
							citylist.city[citynum].owner =herolist.hero[heronum].owner;
							citylist.city[citynum].ownto =herolist.hero[heronum].owner;
							for(int j=0;j<HEROMAX;j++)
							{
								if(herolist.hero[j].owner==enemynum+1)
								{
									herolist.hero[j].owner =herolist.hero[heronum].owner;
									citylist.city[herolist.hero[j].hiscity-1].owner=herolist.hero[heronum].owner;
								}
							}
							heronum=herolist.hero[heronum].owner-1;
							ShowItAfter(11,1,heronum,enemynum);
						}

					}
					break;
				}
			}
			//删除hero(无需增加)
		}
	}

}

void GameMap::ComputerTacticHarmonize(int c)//协调
{
	wlogfile(1,__FUNCTION__,"开始",0);
	for(int i=0;i<HEROMAX;i++)
	{
		if((herolist.hero[i].hiscity-1)==c&&herolist.hero[i].owner!=0&&herolist.hero[i].owner<HEROMAX)
		{
			int rnd=rand()%7;
			switch(rnd)
			{
			case 0://治理
				citylist.city[c].disease+=4;
				if(citylist.city[c].disease>100)
				{
					citylist.city[c].disease=100;
				}
				break;
			case 5://移动
				{
					int k[HEROMAX];
					int tamp=0;
					for(int j=0;j<HEROMAX;j++)
					{
						if((herolist.hero[j].hiscity-1)==c&&herolist.hero[j].owner!=0&&herolist.hero[j].owner<HEROMAX)
						{
							OverflowCheck(__FILE__,__LINE__,HEROMAX,tamp);
							k[tamp]=j;
							tamp++;
						}
					}
					if(tamp>2)
					{
						for(int y=0;y<CITYMAX;y++)
						{
							if(citylist.city[y].owner==citylist.city[c].owner&&c!=y)
							{
								int rnd=rand()%2;
								if(rnd)herolist.hero[i].hiscity=y+1;
							}
						}
					}
				}
			}
			//删除hero(无需增加)
		}
	}


}

void GameMap::ComputerTacticArmament(int c)//军备
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int k[HEROMAX];
	int tamp=0;
	for(int i=0;i<HEROMAX;i++)
	{
		if((herolist.hero[i].hiscity-1)==c&&herolist.hero[i].owner!=0&&herolist.hero[i].owner<HEROMAX)
		{
			OverflowCheck(__FILE__,__LINE__,HEROMAX,tamp);
			k[tamp]=i;
			tamp++;
		}
	}

	if (date.month %3!=0&&tamp!=0)
	{
		int rnd=rand()%tamp;//随机一个武将等级提升一级,完成
		OverflowCheck(__FILE__,__LINE__,HEROMAX,k[rnd]);
		herolist.hero[k[rnd]].degree++;
		if (herolist.hero[k[rnd]].degree> 20)
		{
			herolist.hero[k[rnd]].degree = 20;
		}
	}
	for(int i=0;i<HEROMAX;i++)
	{
		if((herolist.hero[i].hiscity-1)==c&&herolist.hero[i].owner!=0&&herolist.hero[i].owner<HEROMAX)
		{
			int rnd=rand()%13;//9;
			//rnd=7;
			if(highAtk==1&&rnd!=6)rnd=7;
			switch(rnd)
			{
			case 0:
				break;
			case 1://征兵分配
			case 2:
			case 3:
			case 4:
			case 5:
				{
					int bingli=herolist.hero[i].degree;
					bingli*=10;
					bingli += (herolist.hero[i].wuli+herolist.hero[i].zili);
					bingli*=10;
					herolist.hero[i].bingli=bingli;
					break;
				}
			case 6:
				{	//掠夺，完成
					int citynum=c;
					int heronum=i;
					int valf,valm;
					citylist.city[citynum].heart /=2;
					citylist.city[citynum].agriculture /=2;
					citylist.city[citynum].business /=2;
					valf=herolist.hero[heronum].zili +herolist.hero[heronum].wuli;
					valm=valf*2;
					valf*=5;
					citylist.city[citynum].foods+=valf;
					citylist.city[citynum].money+=valm;

					break;
				}
			case 7://出征

				if(tamp<4)break;
				if((herolist.hero[i].owner-1)!=herolist.hero[i].no)break;
				int citynum=c;//攻击方城市
				int heronum=herolist.hero[i].owner-1;//攻击方主将
				int soldier=0;//20170606修正初始值不判断城内兵力citylist.city[citynum].soldierspace;//攻击方的兵力
				int foods=citylist.city[citynum].foods;

				int cityto=GetEnemyCity(citynum+1)-1;//获取攻击的城市；
				OverflowCheck(__FILE__,__LINE__,CITYMAX,cityto);
				int heronumto=citylist.city[cityto].owner-1;//被攻击方主将
				int soldierto=citylist.city[cityto].soldierspace;//被攻击方的兵力
				int foodsto=citylist.city[cityto].foods;//被攻击方
				//cityto=8;
				if(citylist.city[cityto].owner==ownernum)
				{
					int rd=rand()%10;
					//if(rd<9)break;
					//攻击玩家城市；
					if(tmpflag==1)break;
					tmpflag=1;
					tasknum++;
					OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,tasknum);
					tasklist[tasknum].isend=0;				
					tasklist[tasknum].event=EXPEDITIONTASK;
					OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
					tasklist[tasknum].heronum=citylist.city[citynum].owner-1;//ownernum-1;
					tasklist[tasknum].citynum=citynum+1;//herolist.hero[zujiang].hiscity;

					tasklist[tasknum].data[0]=cityto+1;//选择的进攻城市
					tasklist[tasknum].data[1]=citylist.city[citynum].foods;//粮食数目
					tmp0[1]=0;

					for(int iq=0;iq<9;iq++)warherono[iq]=-1;

					for(int rj=0;rj<HEROMAX;rj++)
					{
						if((herolist.hero[rj].hiscity-1)==citynum&&herolist.hero[rj].owner==citylist.city[citynum].owner&&rj!=(citylist.city[citynum].ownto-1))
						{
							OverflowCheck(__FILE__,__LINE__,10,tmp0[1]);
							warherono[tmp0[1]]=rj;
							tmp0[1]++;
							if(tmp0[1]>=9)break;//20161216修正 20170423修正10-》9
						}
					}
					tasklist[tasknum].data[2]=tmp0[1]+1;//武将数目 
					tasklist[tasknum].data[3]=citylist.city[citynum].ownto-1;//主将编号
					tasklist[tasknum].data[4]=-1;//敌方与我方作战
					/*
					citynum;所在城市编号
					heronum;君主编号
					date[0]所攻打城市编号
					date[1]粮食
					date[2]武将数目
					date[3]主将编号
					date[4]结果
					*/
					tasklist[tasknum+1].data[0]=warherono[0];
					tasklist[tasknum+1].data[1]=warherono[1];
					tasklist[tasknum+1].data[2]=warherono[2];
					tasklist[tasknum+1].data[3]=warherono[3];
					tasklist[tasknum+1].data[4]=warherono[4];
					tasklist[tasknum+2].data[0]=warherono[5];
					tasklist[tasknum+2].data[1]=warherono[6];
					tasklist[tasknum+2].data[2]=warherono[7];
					tasklist[tasknum+2].data[3]=warherono[8];
					tasklist[tasknum+2].data[4]=1;//防守战
					tasknum++;
					tasklist[tasknum].isend=0;	
					tasknum++;
					tasklist[tasknum].isend=0;	




					break;
				}
				if(citylist.city[cityto].owner==0)//攻击空城,无法
				{
					break;
				}
				for(int gg=0;gg<HEROMAX;gg++)
				{
					if((herolist.hero[gg].hiscity-1)==citynum&&herolist.hero[gg].owner!=0&&herolist.hero[gg].owner<HEROMAX)
					{
						soldier+=herolist.hero[gg].bingli;
					}
					if((herolist.hero[gg].hiscity-1)==cityto&&herolist.hero[gg].owner!=0&&herolist.hero[gg].owner<HEROMAX)
					{
						soldierto+=herolist.hero[gg].bingli;
					}
				}
				if(soldier<1000)break;
				if(heronum==heronumto)break;
				if(citylist.city[cityto].owner!=0&&citylist.city[cityto].owner!=ownernum)
				{
					int retauto=AutoBattle(soldier,foods,soldierto,foodsto);//自动战斗；
					if(heronumto>HEROMAX ||heronumto < 0)heronumto = 0;//20171210
					ShowItAfterWar(retauto,heronum,heronumto,cityto);
					//需增加自动战斗战后处理
					AfterWar_Auto(retauto,citynum,cityto,heronum,heronumto);//战后处理
				}
				endthisflag=0;
				captiveflag=0;
				break;
			}
			//删除hero
		}
	}
}

void GameMap::WarRun()//队列执行
{
	wlogfile(1,__FUNCTION__,"开始",0);
	if(warlistflag==2)goto nt;
	if(warinflag==0)warinflag=-1;
	if(warinflag==-1)
	{
		for(int i=1;i<TASKLISTMAX;i++)
		{
			if(tasklist[i].isend==0)
			{	
				if(tasklist[i].event==EXPEDITIONTASK)
				{
					int result=tasklist[i].data[4];
					int zujiangnumto=GetClever(tasklist[i].data[0]-1)-1;
					if(result==-1&&zujiangnumto!=-1)
					{	
						if(warinflag==-1)warinflag=0;
						warinflag++;
					}
				}
			}
		}
	}
nt:
	for(int i=1;i<TASKLISTMAX;i++)
	{
		if(tasklist[i].isend==0)
		{	
			if(tasklist[i].event==EXPEDITIONTASK)
			{
				tasklist[i].event=WARTASK;				
				int result=tasklist[i].data[4];
				int heronum=tasklist[i].heronum;
				int heroamount=tasklist[i].data[2];
				int citynum=tasklist[i].citynum-1;
				int cityto=tasklist[i].data[0]-1;
				int zujiangnum=tasklist[i].data[3];
				int foodamount=tasklist[i].data[1];
				OverflowCheck(__FILE__,__LINE__,CITYMAX,cityto);
				int heronumto=citylist.city[cityto].owner-1;
				//int zujiangnumto=citylist.city[cityto].ownto-1;
				int zujiangnumto=GetClever(cityto)-1;
				reqcitynum=citynum;
				reqcityto=cityto;
				OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,i+2);
				if(heronumto==-1||(zujiangnumto==-1&&tasklist[i+2].data[4]==0))//空城、敌方无武将城池
				{
					ShowItAfterWar(-2,heronum,-10,cityto);
				}
				else if(citylist.city[cityto].owner==ownernum&&zujiangnumto!=-1&&tasklist[i+2].data[4]==0)//已经获胜,第二次攻打
				{
					ShowItAfterWar(-2,heronum,-10,cityto);
					result=-2;
				}
				else if(zujiangnumto==-1&&tasklist[i+2].data[4]==1)//我方无武将城池被打
				{
					ShowItAfterWar(-3,heronum,heronumto,cityto);
					result=-3;
				}
				else
				{
					ShowItAfterWar(result,heronum,heronumto,cityto);
				}
				if(result==-1&&zujiangnumto!=-1)//我方与敌人交火
				{	
					OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,i+2);
					int style=tasklist[i+2].data[4];
					if(style==0)
					{
						//warinflag++;
						fight.citynumfrom=reqcitynum+1;
						fight.InitData(heroamount,zujiangnum,cityto,foodamount);
						//武将数目、主将编号、所攻打城市编号、粮食
						fight.heronumberto=0;
						fight.fighthero[10].num=zujiangnumto;
						fight.heronumberto++;

						for(int k=0;k<HEROMAX;k++)
						{
							if(herolist.hero[k].owner>0&&herolist.hero[k].owner<HEROMAX&&herolist.hero[k].hiscity-1==cityto&&k!=zujiangnumto&&herolist.hero[k].bingli>0)
							{
								if(fight.heronumberto==10)break;
								OverflowCheck(__FILE__,__LINE__,20,fight.heronumberto+10);
								fight.fighthero[fight.heronumberto+10].num=k;
								fight.heronumberto++;
							}
						}
						for(int uu=fight.heronumberto;uu<10;uu++)
						{
							OverflowCheck(__FILE__,__LINE__,20,uu+10);
							fight.fighthero[uu+10].num=-1;
						}
						//fight.heronumberto;//敌方武将数目
						fight.zujiangto=zujiangnumto;//敌方主将
						fight.owner=heronum;
						fight.ownerto=heronumto;
						fight.foodsto=citylist.city[cityto].foods;
						fight.allbingli=0;
						fight.allbinglito=0;

						SetFightHeroData(i);
						i+=2;
						fight.Show(-100);
						fight.Show(0);
						flagwar=1;
						return;
					}
					else//防守战
					{
						//warinflag++;
						my_unx=GetUnx(cityto);//0-
						my_uny=GetUny(cityto);//0-
						herolist.Init(my_unx,my_uny,choice,26,ownernum);
						herolist.Show(0);
						warlistflag=1;
						tasklist[i].event=DEFENCETASK;
						tasklistinuse  = i;//用于后续的战争数据初始化
						return;
						//增加列表选择出征武将


					}
				}
				else if(zujiangnumto==-1&&tasklist[i+2].data[4]==0)//攻击空城，敌方无武将城池
				{
					AfterWar_SpaceCity(1,citynum,cityto,i);
				}
				else if(result==-2)//（我方已占城池）
				{
					warinflag--;
					if(warinflag==0)warinflag=-2;

					AfterWar_SpaceCity(1,citynum,cityto,i);

				}
				else if(zujiangnumto==-1&&tasklist[i+2].data[4]==1)//我方无武将城池被攻击
				{
					AfterWar_SpaceCity(2,citynum,cityto,i);
					//warinflag--;
				}
			}
			else if(tasklist[i].event==DEFENCETASK)
			{
				warlistflag=0;
				tasklist[i].event=WARTASK;	
				if(warcomedonothingflag == 1)
				{
					warcomedonothingflag = 0;
					return;
				}

				int ai_heronum=tasklist[i].heronum-1;
				int ai_heroamount=tasklist[i].data[2];
				int ai_citynum=tasklist[i].citynum-1;
				int my_cityto=tasklist[i].data[0]-1;
				int ai_zujiangnum=tasklist[i].data[3];
				int ai_foodamount=tasklist[i].data[1];
				OverflowCheck(__FILE__,__LINE__,CITYMAX,my_cityto);
				int my_heronumto=citylist.city[my_cityto].owner-1;
				int my_foodamount=citylist.city[my_cityto].foods;
				fight.citynumfrom=ai_citynum+1;
				fight.InitData(my_warherononum+1,my_zujiang,my_cityto,my_foodamount);//+1为增加主将
				//武将数目、主将编号、所攻打城市编号、粮食(我方)
				fight.heronumberto=ai_heroamount>10?10:ai_heroamount;
				//fight.citynumfrom=ai_citynum+1;


				fight.fighthero[0].num=my_zujiang;
				//fight.heronumberto++;
				for(int yu=1;yu<my_warherononum+1;yu++)
				{
					OverflowCheck(__FILE__,__LINE__,20,yu);
					fight.fighthero[yu].num=my_warherono[yu-1];
				}

				for(int uu=my_warherononum+1;uu<10;uu++)
				{
					OverflowCheck(__FILE__,__LINE__,20,uu);
					fight.fighthero[uu].num=-1;
				}
				//fight.heronumberto;//敌方武将数目
				fight.zujiangto=ai_zujiangnum;//敌方主将
				fight.owner=my_heronumto;
				fight.ownerto=ai_heronum+1;
				fight.foodsto=ai_foodamount;
				fight.allbingli=0;
				fight.allbinglito=0;

				SetFightHeroData2(i);
				i+=2;


				fight.Show(-100);
				fight.Show(0);
				flagwar=1;
				return;


			}
		}
	}

}


void GameMap::TaskListRun()//队列执行
{
	wlogfile(1,__FUNCTION__,"开始",0);
	for(int i=1;i<TASKLISTMAX;i++)
	{
		if(tasklist[i].isend==0)
		{	

			switch(tasklist[i].event)
			{
			case 1:
				{	//搜寻
					int heronum=tasklist[i].heronum;
					int citynum=tasklist[i].citynum ;
					int pss=rand()%4;
					//pss=1;
					int rnd = 0;
					int dateq = 0;
					OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
					int zili=herolist.hero[heronum].zili;
					switch(pss)
					{
					case 1:
						{	
							pss=0;
							rnd=rand()%150;
							//rnd=0;
							if(rnd<zili)
							{
								switch(rnd%2)
								{
								case 0:
									{//搜寻武将
										int k[HEROMAX];
										int pcount=0;
										for(int i=0;i<HEROMAX;i++)
										{
											if((herolist.hero[i].hiscity-1)==citynum&&herolist.hero[i].owner==0)
											{
												OverflowCheck(__FILE__,__LINE__,HEROMAX,pcount);
												k[pcount]=i;
												pcount++;//空闲武将数
											}
										}

										if(pcount)
										{
											int sp=rand()%pcount;
											int count=sp;
											OverflowCheck(__FILE__,__LINE__,HEROMAX,count);
											OverflowCheck(__FILE__,__LINE__,HEROMAX,k[count]);
											int fo=herolist.hero[k[count]].hisfinder;

											if(fo-1==heronum)//指定武将搜索时
											{
												rnd=1;
												pss=1;
												OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
												herolist.hero[k[count]].owner=citylist.city[citynum].owner;
												herolist.hero[k[count]].heart=70+rand()%30;
												dateq=k[count];
											}
											else if(!fo)//随机武将搜索
											{
												rnd=rand()%110;
												//rnd=0;
												if(rnd<zili)//同意
												{
													rnd=1;
													pss=1;
													OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
													herolist.hero[k[count]].owner=citylist.city[citynum].owner;
													herolist.hero[k[count]].heart=70+rand()%30;
													dateq=k[count];
												}
												else//不同意
												{
													rnd=2;
													pss=1;
													dateq=-k[count];
												}
											}
											else
											{
												rnd=1;
												pss=5;
												dateq=0;
											}
										}
										break;
									}
								case 1:
									{
										//搜索道具
										int k[GOODMAX];
										int pcount=0;
										for(int i=0;i<GOODMAX;i++)
										{
											if((goodlist.good[i].hiscity-1)==citynum&&goodlist.good[i].finded==0)
											{
												OverflowCheck(__FILE__,__LINE__,GOODMAX,pcount);
												k[pcount]=i;
												pcount++;//空闲武将数
											}
										}
										if(pcount)
										{
											int sp=rand()%pcount;
											int count=sp;
											OverflowCheck(__FILE__,__LINE__,GOODMAX,count);
											OverflowCheck(__FILE__,__LINE__,GOODMAX,k[count]);
											int fo=goodlist.good[k[count]].hisfinder;
											rnd=0;
											if(fo-1==heronum)//指定武将搜索时
											{
												rnd=1;
												pss=2;
												goodlist.good[k[count]].finded=1;
												dateq=k[count];
											}
											else if(!fo)//随机武将搜索
											{
												rnd=rand()%110;
												//rnd=0;
												if(rnd<zili)
												{
													rnd=1;
													pss=2;
													goodlist.good[k[count]].finded=1;
													dateq=k[count];
												}
												else
												{
													rnd=2;
													pss=0;
												}
											}

										}

										break;
									}
								}
							}

							break;
						}
					case 2:
						{	
							int zili=herolist.hero[heronum].zili;
							rnd = 10 + rand() % (zili * 2);
							OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
							citylist.city[citynum].money  += rnd;
							pss=3;
							dateq=rnd;
							break;
						}
					case 3:
						{
							int zili=herolist.hero[heronum].zili;
							if(zili == 0)zili = 1;//20170115修正  20170421修正==为=
							rnd = 10 + rand() % (zili * 2);
							OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
							citylist.city[citynum].foods  += rnd;
							pss=4;
							dateq=rnd;
							break;
						}
					}
					ShowItAfter(tasklist[i].event,pss,dateq,heronum);

					break;
				}
			case 2:
				{	//招降
					int result=tasklist[i].data[0];
					OverflowCheck(__FILE__,__LINE__,HEROMAX,tasklist[i].heronum);
					if(herolist.hero[tasklist[i].heronum].iscaptive == 1/*.owner>HEROMAX*/&&result==1)
					{
						ShowItAfter(tasklist[i].event,result,0,tasklist[i].heronum);
						herolist.hero[tasklist[i].heronum].owner=ownernum;
						herolist.hero[tasklist[i].heronum].iscaptive = 0;
					}
					else if(herolist.hero[tasklist[i].heronum].iscaptive == 1/*.owner>HEROMAX*/&&result==0)
					{
						ShowItAfter(tasklist[i].event,result,0,tasklist[i].heronum);
					}
					break;
				}
			case 3:
				{	//输送
					int citynum=tasklist[i].citynum;			
					int result=tasklist[i].data[3];
					OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
					if(result)
					{
						citylist.city[citynum].money +=tasklist[i].data[0];
						citylist.city[citynum].foods +=tasklist[i].data[1];
						citylist.city[citynum].soldierspace +=tasklist[i].data[2];

					}

					ShowItAfter(tasklist[i].event,result,0,tasklist[i].heronum);
					break;
				}
			case 5:
				{
					//招揽
					int citynum=tasklist[i].citynum;
					int heronum=tasklist[i].heronum;
					int result=tasklist[i].data[0];
					OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
					OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
					if(result)
					{

						herolist.hero[heronum].owner =citylist.city[citynum].owner;
						herolist.hero[heronum].hiscity=citynum+1;
					}
					//ShowItAfter(tasklist[i].event,result,0,tasklist[i].heronum);
					break;
				}
			case 6:
				{
					//策反
					int citynum=tasklist[i].citynum-1;
					int heronum=tasklist[i].heronum;
					OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
					OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
					int result=tasklist[i].data[0];
					if(result)
					{
						herolist.hero[heronum].owner =heronum+1;
						herolist.hero[heronum].heart =100;
						citylist.city[citynum].owner =heronum;
						for(int j=0;j<HEROMAX;j++)
						{
							if((herolist.hero[j].hiscity -1)==citynum&&herolist.hero[j].owner<HEROMAX&&herolist.hero[j].owner!=0)
							{
								herolist.hero[j].owner =heronum+1;
							}
						}
						ShowItAfter(tasklist[i].event,result,0,tasklist[i].heronum);
					}

					break;
				}
			case 7:
				{
					//劝降
					int citynum=tasklist[i].citynum;
					int heronum=tasklist[i].heronum;
					OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
					OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
					int result=tasklist[i].data[0];
					//herolist.ChangeOwnerNum(unum);
					if(result==1)//成功
					{
						int ty=heronum;
						herolist.hero[heronum].owner =ownernum;
						citylist.city[citynum].owner =ownernum;
						citylist.city[citynum].ownto =ownernum;
						for(int j=0;j<HEROMAX;j++)
						{
							if(herolist.hero[j].owner==heronum+1)
							{
								herolist.hero[j].owner =ownernum;
								citylist.city[herolist.hero[j].hiscity-1].owner=ownernum;
							}
						}
					}
					ShowItAfter(tasklist[i].event,result,0,tasklist[i].heronum);
					break;
				}
			case 8:
				{
					if(tasklist[i].data[4]==-1)i+=2;		
					//出征
					/*
					citynum;所在城市编号
					heronum;君主编号
					date[0]所攻打城市编号
					date[1]粮食
					date[2]武将数目
					date[3]主将编号
					date[4]结果

					int result=tasklist[i].data[4];
					int heronum=tasklist[i].heronum-1;
					int heroamount=tasklist[i].data[2];
					int citynum=tasklist[i].citynum-1;
					int cityto=tasklist[i].data[0]-1;
					int zujiangnum=tasklist[i].data[3];
					int foodamount=tasklist[i].data[1];
					int heronumto=citylist.city[cityto].owner-1;
					//int zujiangnumto=citylist.city[cityto].ownto-1;
					int zujiangnumto=GetClever(cityto)-1;

					ShowItAfterWar(result,heronum,heronumto,cityto);
					if(result==-1)
					{	
					//i+=2;
					fight.InitData(heroamount,zujiangnum,cityto,foodamount);
					//武将数目、主将编号、所攻打城市编号、粮食
					fight.heronumberto=0;

					fight.fighthero[fight.heronumberto+10].num=zujiangnumto;
					fight.heronumberto++;

					for(int k=0;k<300;k++)
					{
					if(herolist.hero[k].owner>0&&herolist.hero[k].owner<100&&herolist.hero[k].hiscity-1==cityto&&k!=zujiangnumto)
					{
					fight.fighthero[fight.heronumberto+10].num=k;
					fight.heronumberto++;
					}
					}
					for(int uu=fight.heronumberto;uu<10;uu++)
					fight.fighthero[uu+10].num=-1;
					//fight.heronumberto;//敌方武将数目
					fight.zujiangto=zujiangnumto;//敌方主将
					fight.owner=heronum+1;
					fight.ownerto=heronumto;
					fight.foodsto=citylist.city[cityto].foods;
					fight.allbingli=0;
					fight.allbinglito=0;
					//传其他9个武将编号，未完成
					/*fight.otherwj[0]=tasklist[i+1].data[0];
					fight.otherwj[1]=tasklist[i+1].data[1];
					fight.otherwj[2]=tasklist[i+1].data[2];
					fight.otherwj[3]=tasklist[i+1].data[3];
					fight.otherwj[4]=tasklist[i+1].data[4];
					fight.otherwj[5]=tasklist[i+2].data[0];
					fight.otherwj[6]=tasklist[i+2].data[1];
					fight.otherwj[7]=tasklist[i+2].data[2];
					fight.otherwj[8]=tasklist[i+2].data[3];
					SetFightHeroData(i);
					i+=2;
					fight.Show(-100);
					fight.Show(0);
					flagwar=1;
					}


					AfterWar(result,citynum,cityto);//战后处理事件，未完成
					break;}*/
					break;
				}
			case 9:
				{
					//掠夺
					int citynum=tasklist[i].citynum;
					int heronum=tasklist[i].heronum;
					OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
					OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
					int valf,valm;
					citylist.city[citynum].heart /=2;
					citylist.city[citynum].agriculture /=2;
					citylist.city[citynum].business /=2;
					valf=herolist.hero[heronum].zili +herolist.hero[heronum].wuli;
					valm=valf*2;
					valf*=5;
					citylist.city[citynum].foods+=valf;
					citylist.city[citynum].money+=valm;
					ShowItAfter(tasklist[i].event,valm,valf,tasklist[i].heronum);
					break;
				}

			}
		}
		else
		{
			break;
		}
	}

	//tasknum=0;
}

void GameMap::ShowItAfter(int event,int result,int data,int x)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	char text[30];
	char text1[30];
	char name[NORMALSTRLEN];
	char name1[NORMALSTRLEN];
	char name2[NORMALSTRLEN];
	static int fleg;

	switch(event)
	{
	case 1://搜寻
		{	
			switch(result)
			{
			case 0:
				{
					sprintf_s(name,"%s",GetStrTextSpilted("STR_GETNOTHING",0,7));
					sprintf_s(name1,"%s",GetStrTextSpilted("STR_GETNOTHING",1,7));
					break;
				}
			case 1://找到武将
				{
					if(fleg==0)
					{
						fleg=1;
						ShowItAfter(event,result,-data,x);
						x=data;
						if(data<0)//不同意
						{
							int rr=rand()%4;
							if(rr==0)
							{
								sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR17",0,7));
								sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR17",1,7));
								sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR17",2,7));
							}
							else if(rr==1)
							{
								sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR18",0,7));
								sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR18",1,7));
								sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR18",2,7));

							}
							else if(rr==2)
							{
								sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR19",0,7));
								sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR19",1,7));
								sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR19",2,7));

							}
							else
							{
								sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR20",0,7));
								sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR20",1,7));
								sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR20",2,7));

							}
							x=-x;
							data=-data;
						}
						else//同意
						{
							int rr=rand()%4;
							if(rr==0)
							{
								sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR13",0,7));
								sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR13",1,7));
								sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR13",2,7));
							}
							else if(rr==1)
							{
								sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR14",0,7));
								sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR14",1,7));
								sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR14",2,7));
							}
							else if(rr==2)
							{
								sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR15",0,7));
								sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR15",1,7));
								sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR15",2,7));

							}
							else
							{
								sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR16",0,7));
								sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR16",1,7));
								sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR16",2,7));

							}
						}

					}
					else
					{
						fleg=0;
						sprintf_s(name,"%s",GetStrText("STR_GETGOODS"));

						if(data<0)data=-data;
						sprintf_s(text,"%s",t_heroName[data]);

					}

					break;
				}
			case 2://找到道具
				{	
					sprintf_s(name,"%s",GetStrText("STR_GETGOODS"));
					sprintf_s(text,"%s",t_goodName[data]);
					break;
				}
			case 3://找到金钱
				{	
					sprintf_s(name,"%s",GetStrText("STR_GETSOME1"));
					sprintf_s(text,"%d",data);
					break;
				}
			case 4://找到粮食
				{
					sprintf_s(name,"%s",GetStrText("STR_GETSOME2"));
					sprintf_s(text,"%d",data);
					break;
				}
			case 5://听说武将
				{
					sprintf_s(name,"%s",GetStrTextSpilted("STR_HEARPERSON",0,7));
					sprintf_s(name1,"%s",GetStrTextSpilted("STR_HEARPERSON",1,7));
					sprintf_s(name2,"%s",GetStrTextSpilted("STR_HEARPERSON",2,7));
					break;
				}
			}
			break;
		}
	case 2://招降
		{	
			switch(result)
			{
			case 0:
				{
					int rr=rand()%3;
					if(rr==0)
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR1",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR1",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR1",2,7));
					}
					else if(rr==1)
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR2",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR2",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR2",2,7));

					}
					else
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR3",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR3",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR3",2,7));

					}
					break;
				}
			case 1:
				{
					int rr=rand()%3;
					if(rr==0)
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR10",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR10",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR10",2,7));
					}
					else if(rr==1)
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR11",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR11",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR11",2,7));

					}
					else
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR12",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR12",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR12",2,7));

					}
					break;
				}
			}
			break;
		}
	case 3://输送	 
		{
			switch(result)
			{
			case 0:
				sprintf_s(name,"%s",GetStrTextSpilted("STR_RP10",0,7));
				sprintf_s(name1,"%s",GetStrTextSpilted("STR_RP10",1,7));
				sprintf_s(name2,"%s",GetStrTextSpilted("STR_RP10",2,7));
				break;
			case 1:
				sprintf_s(name,"%s",GetStrText("STR_RP9"));
				sprintf_s(name1,"%s","              ");
				sprintf_s(name2,"%s","              ");
				break;
			}
			break;
		}
	case 6://策反 
		{	
			sprintf_s(name,"%s",GetStrText("STR_BEKINGED"));
			sprintf_s(text,"%s",t_heroName[x]);

			TimerMessageCF(text,name,50,300,12,1,1000);
			//TextOut(hdcTmp,300,300,name,strlen(name));
			//TextOut(hdcTmp,550,300,text,strlen(text));
			return;
		}
	case 11://劝降，电脑 
		{	
			sprintf_s(name,"%s",GetStrText("STR_INDUCENOTE"));
			sprintf_s(text,"%s",t_heroName[x]);
			sprintf_s(text1,"%s",t_heroName[data]);
			TimerMessageGS(name,text,text1,50,300,12,1,1000);
			//TextOut(hdcTmp,300,300,name,strlen(name));
			//TextOut(hdcTmp,550,300,text,strlen(text));
			return;
		}
	case 7://劝降
		{	
			switch(result)
			{
			case 0:
				{
					int rr=rand()%4;
					if(rr==0)
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR32",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR32",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR32",2,7));
					}
					else if(rr==1)
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR33",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR33",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR33",2,7));

					}
					else if(rr==2)
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR34",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR34",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR34",2,7));

					}
					else
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR35",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR35",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR35",2,7));

					}
					break;
				}
			case 1:
				{
					int rr=rand()%4;
					if(rr==0)
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR36",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR36",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR36",2,7));
					}
					else if(rr==1)
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR37",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR37",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR37",2,7));

					}
					else if(rr==2)
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR38",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR38",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR38",2,7));

					}
					else
					{
						sprintf_s(name,"%s",GetStrTextSpilted("P_SAY_STR39",0,7));
						sprintf_s(name1,"%s",GetStrTextSpilted("P_SAY_STR39",1,7));
						sprintf_s(name2,"%s",GetStrTextSpilted("P_SAY_STR39",2,7));

					}
					break;
				}
			}
			break;
		}

	case 9://掠夺
		{
			sprintf_s(name,"%s",GetStrText("P_SAY_STR28"));
			sprintf_s(name1,"%s",GetStrText("P_SAY_STR29"));
			sprintf_s(name2,"%s",GetStrText("P_SAY_STR30"));
			sprintf_s(text,"%d",result);
			sprintf_s(text1,"%d",data);
			break;
		}


	}
	Show(0);

	MyCreateFont(0.8);
	HFONT	h = t_h;
	HFONT oldh=(HFONT)SelectObject(hdcTmp,h);
	MySetTextColor(FONTB,USEHDCTMP);
	if(color==0)
	{

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

		Rectangle(hdcTmp,20,250,780,500); 	
		SelectObject(hdcTmp,oldhpen);
		DeleteObject(hpen);
	}
	else
	{

		ShowCG(0,"Res\\Fight\\fight_imformation.sbp",20,200);
	}

	switch(event)
	{
	case 1:
		{
			switch(result)
			{
			case 0:
				{	
					TextOut(hdcTmp,300,300,name,strlen(name));
					TextOut(hdcTmp,300,370,name1,strlen(name1));
					break;
				}

			case 1:
				{
					if(x!=data)
					{
						TextOut(hdcTmp,300,300,name,strlen(name));
						TextOut(hdcTmp,500,300,text,strlen(text));
					}
					else
					{
						TextOut(hdcTmp,300,300,name,strlen(name));
						TextOut(hdcTmp,300,370,name1,strlen(name1));
						TextOut(hdcTmp,300,440,name2,strlen(name2));
					}
					break;
				}
			case 2:
				{
					TextOut(hdcTmp,300,300,name,strlen(name));
					TextOut(hdcTmp,500,300,text,strlen(text));
					break;
				}
			case 3:
				{
					TextOut(hdcTmp,300,300,name,strlen(name));
					TextOut(hdcTmp,550,300,text,strlen(text));
					break;
				}
			case 4:
				{
					TextOut(hdcTmp,300,300,name,strlen(name));
					TextOut(hdcTmp,550,300,text,strlen(text));
					break;
				}
			case 5:
				{
					TextOut(hdcTmp,300,300,name,strlen(name));
					TextOut(hdcTmp,300,370,name1,strlen(name1));
					TextOut(hdcTmp,300,440,name2,strlen(name2));
					break;
				}
			}
			break;
		}
	case 2:
	case 3:
	case 7:
		TextOut(hdcTmp,300,300,name,strlen(name));
		TextOut(hdcTmp,300,370,name1,strlen(name1));
		TextOut(hdcTmp,300,440,name2,strlen(name2));
		break;

	case 9:
		TextOut(hdcTmp,300,300,name,strlen(name));
		TextOut(hdcTmp,300,370,name1,strlen(name1));
		TextOut(hdcTmp,300,440,name2,strlen(name2));
		TextOut(hdcTmp,480,300,text,strlen(text));
		TextOut(hdcTmp,510,370,text1,strlen(text1));
		break;
	}

	switch(choice)
	{
	case DZNQ:
		head.Init("Res\\Head\\1dznq.sbp",x);
		break;
	case CCJQ:	
		head.Init("Res\\Head\\2ccjq.sbp",x);
		break;
	case CBZZ:
		head.Init("Res\\Head\\3cbzz.sbp",x);
		break;
	case SGDL:
		head.Init("Res\\Head\\4sgdl.sbp",x);
		break;
	default:
		{
			char name[NORMALSTRLEN];
			sprintf_s(name,"Res\\Head\\period%d.sbp",choice+1);
			head.Init(name,x);
		}
		break;
	}
	head.Show(100,290);
	char heroname[20];
	sprintf_s(heroname,"%s",t_heroName[x]);

	TextOut(hdcTmp,120,430,heroname,strlen(heroname));
	BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);
	Delay(500);
	Show(0);
	SelectObject(hdcTmp,oldh);
	DeleteObject(h);
	SetTextColor(hdcTmp,RGB(0, 0, 0));
}



void GameMap::ChangeOwnerNum()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	ownernum=0;

	char name[50];
	int t_choice;
	int t_id;
	//ChangeRes(name);
	memset(name,0,sizeof(name));
	sprintf_s(name,"%s","Res\\emperorid.sdt");

	ifstream infile(name,ios::in);

	while(infile>>t_choice)
	{
		infile>>t_id;
		infile>>emperorid[t_choice][t_id];
	}

	infile.close();

	ownernum = emperorid[choice][unum];
	/*
	if(choice==DZNQ)
	{
	switch (unum)
	{
	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;
	}
	}
	if(choice==CCJQ)
	{
	switch (unum)
	{
	case 0:
	ownernum=12;
	break;
	case 1:
	ownernum=4;
	break;
	case 2:
	ownernum=11;
	break;
	case 3:
	ownernum=16;
	break;
	case 4:
	ownernum=1;
	break;
	case 5:
	ownernum=9;
	break;
	case 6:
	ownernum=3;
	break;
	case 7:
	ownernum=15;
	break;
	case 8:
	ownernum=2;
	break;
	case 9:
	ownernum=14;
	break;
	case 10:
	ownernum=8;
	break;
	case 11:
	ownernum=5;
	break;
	case 12:
	ownernum=6;
	break;
	case 13:
	ownernum=13;
	break;
	case 14:
	ownernum=10;
	break;
	case 15:
	ownernum=7;
	break;

	}
	}
	if(choice==CBZZ)
	{
	switch (unum)
	{
	case 0:
	ownernum=8;
	break;
	case 1:
	ownernum=5;
	break;
	case 2:
	ownernum=11;
	break;
	case 3:
	ownernum=9;
	break;
	case 4:
	ownernum=10;
	break;
	case 5:
	ownernum=7;
	break;
	case 6:
	ownernum=6;
	break;
	case 7:
	ownernum=4;
	break;
	case 8:
	ownernum=1;
	break;
	case 9:
	ownernum=2;
	break;
	case 10:
	ownernum=3;
	break;

	}
	}
	if(choice==SGDL)
	{
	switch (unum)
	{
	case 0:
	ownernum=1;
	break;
	case 1:
	ownernum=5;
	break;
	case 2:
	ownernum=2;
	break;
	case 3:
	ownernum=3;
	break;
	case 4:
	ownernum=4;
	break;

	}
	}*/
}

int GameMap::GetCityPostion(int pox,int poy,int choice,int num)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int j=0;
	int posx[CITYMAX];
	int posy[CITYMAX];
	char name[NORMALSTRLEN];
	//ChangeRes(name);
	sprintf_s(name,"%s","Res\\City\\postion.sdt");
	ifstream infile(name,ios::in);
	for(int g=0;g<CITYMAX;g++)
	{

		infile>>posx[g];
		infile>>posy[g];
		if(posx[g]==pox&&posy[g]==poy)
		{
			if(citylist.city[g].owner==ownernum)
			{
				return 1;
			}
			else if(citylist.city[g].owner==0)
			{
				return 3;
			}
			else
			{
				return 2;
			}
		}
	}
	infile.close();
	//ChangeRes(name);
	return 0;
}

int GameMap::IsWinOrLose()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	for(int i=0;i<CITYMAX;i++)
	{
		if(citylist.city[i].owner!=ownernum&&citylist.city[i].owner!=0)
			return 0;
	}
	TimerMessage(GetStrText("STR_GAMEWON"),"",50,280,12,1,1000);
	DeleteLog();
	PostQuitMessage(0);
	return 0;

}

void GameMap::ShowItAfterWar(int result,int hero1,int hero2,int city)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	char text[30];
	char text1[30];
	char name[NORMALSTRLEN];
	char name1[NORMALSTRLEN];
	//char *name2;
	HPEN hpen;
	HPEN oldhpen;
	MyCreateFont(0.8);
	HFONT	h = t_h;
	HFONT oldh=(HFONT)SelectObject(hdcTmp,h);
	MySetTextColor(FONTB,USEHDCTMP);
	if(color==0)
	{
		MySetShowStyle();
		hpen=t_hpen;
		oldhpen=(HPEN)SelectObject(hdcTmp,hpen);

		Rectangle(hdcTmp,80,70,720,510); 
		SelectObject(hdcTmp,oldhpen);
		DeleteObject(hpen);


	}
	else
	{
		ShowCG(0,"Res\\Fight\\fight_msgback.sbp",80,20);


	}


	sprintf_s(name,"%s",GetStrText("STR_ATTACKC"));
	sprintf_s(text,"%s",t_heroName[hero1]);


	sprintf_s(text1,"%s",t_cityName[city]);
	if(result<0&&hero2!=(ownernum-1)&&hero2!=-1&&result!=-3)sprintf_s(name1,"%s",GetStrText("STR_OURS"));


	if(result<0&&hero2!=(ownernum-1)&&hero2!=-1&&result!=-3)
	{
		TextOut(hdcTmp,220,430,name1,strlen(name1));
		TextOut(hdcTmp,220+strlen(name1)*20,430,name,strlen(name));
		TextOut(hdcTmp,220+strlen(name1)*20+strlen(name)*20,430,text1,strlen(text1));
	}
	else if(result==-3)//我方空城被攻击情况
	{
		sprintf_s(text,"%s",t_heroName[hero1]);

		TextOut(hdcTmp,220,430,text,strlen(text));
		TextOut(hdcTmp,220+strlen(text)*20,430,name,strlen(name));
		TextOut(hdcTmp,220+strlen(text)*20+strlen(name)*20,430,text1,strlen(text1));
	}
	else
	{
		TextOut(hdcTmp,220,430,text,strlen(text));
		TextOut(hdcTmp,220+strlen(text)*20,430,name,strlen(name));
		TextOut(hdcTmp,220+strlen(text)*20+strlen(name)*20,430,text1,strlen(text1));
	}

	//显示图片
	ShowCG(0,"Res\\Fight\\fight_go.sbp",220,50);
	BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);
	Delay(1000);

	Show(0);
	if(result==-1)
	{

		return;//为-1说明非自动战斗
	}
	if(result==-2)goto endl1;//-2打无人城
	if(result==-3)goto endl2;//-3我方无武将城池被进攻
	if(color==0)
	{
		MySetShowStyle();
		hpen=t_hpen;
		oldhpen=(HPEN)SelectObject(hdcTmp,hpen);

		Rectangle(hdcTmp,80,70,720,510); 
		SelectObject(hdcTmp,oldhpen);
		DeleteObject(hpen);
	}
	else
	{
		ShowCG(0,"Res\\Fight\\fight_msgback.sbp",80,20);
		SetTextColor(hdcTmp,RGB(180,106,41));
	}

	sprintf_s(name,"%s",GetStrText("STR_FIGHT_NOTE1"));
	sprintf_s(name1,"%s",GetStrText("STR_FIGHT_NOTE2"));
	sprintf_s(text,"%s",t_heroName[hero1]);
	sprintf_s(text1,"%s",t_heroName[hero2]);

	TextOut(hdcTmp,220,430,text,strlen(text));
	TextOut(hdcTmp,230+strlen(text)*20,430,name,strlen(name));
	TextOut(hdcTmp,240+strlen(text)*20+strlen(name)*20,430,text1,strlen(text1));
	TextOut(hdcTmp,250+strlen(text)*20+strlen(name)*20+strlen(text1)*20,430,name1,strlen(name1));
	//显示图片
	ShowCG(0,"Res\\Fight\\fight_vs.sbp",220,50);
	BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);
	Delay(1000);


	Show(0);
endl1:	
	if(color==0)
	{
		MySetShowStyle();
		hpen=t_hpen;
		oldhpen=(HPEN)SelectObject(hdcTmp,hpen);

		Rectangle(hdcTmp,80,70,720,510); 
		SelectObject(hdcTmp,oldhpen);
		DeleteObject(hpen);
	}
	else
	{
		ShowCG(0,"Res\\Fight\\fight_msgback.sbp",80,20);
		SetTextColor(hdcTmp,RGB(180,106,41));
	}

	sprintf_s(name,"%s",GetStrText("STR_WON"));

	if(result==0)
	{
		sprintf_s(text,"%s",t_heroName[hero2]);

		TextOut(hdcTmp,240,430,text,strlen(text));
		TextOut(hdcTmp,260+strlen(text)*20,430,name,strlen(name));
	}
	else if(result==1||hero2==-1)
	{
		sprintf_s(text,"%s",t_heroName[hero1]);

		TextOut(hdcTmp,240,430,text,strlen(text));
		TextOut(hdcTmp,260+strlen(text)*20,430,name,strlen(name));
	}
	else if(hero2!=-1)
	{
		sprintf_s(name1,"%s",GetStrText("STR_OURS"));
		TextOut(hdcTmp,240,430,name1,strlen(name1));
		TextOut(hdcTmp,260+strlen(name1)*20,430,name,strlen(name));

	}


	//显示图片
	ShowCG(0,"Res\\Fight\\fight_win.sbp",220,50);
	BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);
	Delay(1000);
	Show(0);
	SelectObject(hdcTmp,oldh);
	DeleteObject(h);
	SetTextColor(hdcTmp,RGB(0, 0, 0));
	return;
endl2:	
	if(color==0)
	{
		MySetShowStyle();
		hpen=t_hpen;
		oldhpen=(HPEN)SelectObject(hdcTmp,hpen);

		Rectangle(hdcTmp,80,70,720,510); 
		SelectObject(hdcTmp,oldhpen);
		DeleteObject(hpen);
	}
	else
	{
		ShowCG(0,"Res\\Fight\\fight_msgback.sbp",80,20);
		SetTextColor(hdcTmp,RGB(180,106,41));
	}
	sprintf_s(name1,"%s",GetStrText("STR_OURS"));
	sprintf_s(name,"%s",GetStrText("STR_LOST"));


	TextOut(hdcTmp,250,430,name1,strlen(name1));
	TextOut(hdcTmp,270+strlen(name1)*25,430,name,strlen(name));

	//显示图片
	ShowCG(0,"Res\\Fight\\fight_lose.sbp",220,50);
	BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);
	Delay(1000);
	Show(0);
	SelectObject(hdcTmp,oldh);
	DeleteObject(h);
	SetTextColor(hdcTmp,RGB(0, 0, 0));
	return;
}

void GameMap::ChangeDataToSave()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	//将武将城市道具类中数据转换为sava类的数组数据
	int i;

	save.owner1=ownernum;
	save.choice=choice;
	for(i=0;i<HEROMAX;i++)
	{
		save.herosave[i][0]=herolist.hero[i].no;
		save.herosave[i][1]=herolist.hero[i].owner;
		save.herosave[i][2]=herolist.hero[i].degree;
		save.herosave[i][3]=herolist.hero[i].wuli;
		save.herosave[i][4]=herolist.hero[i].zili;
		save.herosave[i][5]=herolist.hero[i].heart;
		save.herosave[i][6]=herolist.hero[i].charcter;
		save.herosave[i][7]=herolist.hero[i].experience;
		save.herosave[i][8]=herolist.hero[i].tili;
		save.herosave[i][9]=herolist.hero[i].style;
		save.herosave[i][10]=herolist.hero[i].bingli;
		save.herosave[i][11]=herolist.hero[i].goods1;
		save.herosave[i][12]=herolist.hero[i].goods2;
		save.herosave[i][13]=herolist.hero[i].age;
		save.herosave[i][14]=herolist.hero[i].hiscity;
		//save.herosave[i][15]=herolist.hero[i].number;
		save.herosave[i][15]=herolist.hero[i].inlistflag;
		save.herosave[i][16]=herolist.hero[i].speedup;
		save.herosave[i][17]=herolist.hero[i].hisfinder;
	}
	for(i=0;i<CITYMAX;i++)
	{
		save.citysave[i][0]=citylist.city[i].no;
		save.citysave[i][1]=citylist.city[i].owner;
		save.citysave[i][2]=citylist.city[i].ownto;
		save.citysave[i][3]=citylist.city[i].agriculturemax;
		save.citysave[i][4]=citylist.city[i].agriculture;
		save.citysave[i][5]=citylist.city[i].businessmax;
		save.citysave[i][6]=citylist.city[i].business;
		save.citysave[i][7]=citylist.city[i].heart;
		save.citysave[i][8]=citylist.city[i].disease;
		save.citysave[i][9]=citylist.city[i].peoplemax;
		save.citysave[i][10]=citylist.city[i].people;
		save.citysave[i][11]=citylist.city[i].money;
		save.citysave[i][12]=citylist.city[i].foods;
		save.citysave[i][13]=citylist.city[i].soldierspace;
		save.citysave[i][14]=citylist.city[i].employers;
		save.citysave[i][15]=citylist.city[i].employnum;
		save.citysave[i][16]=citylist.city[i].goods;
		save.citysave[i][17]=citylist.city[i].goodnum;
		save.citysave[i][18]=citylist.city[i].statue;
		//save.citysave[i][19]=citylist.city[i].number;
	}
	for(i=0;i<GOODMAX;i++)
	{
		save.goodsave[i][0]=goodlist.good[i].no;
		save.goodsave[i][1]=goodlist.good[i].owner;
		save.goodsave[i][2]=goodlist.good[i].style;
		save.goodsave[i][3]=goodlist.good[i].wuliup;
		save.goodsave[i][4]=goodlist.good[i].ziliup;
		save.goodsave[i][5]=goodlist.good[i].speedup;
		save.goodsave[i][6]=goodlist.good[i].bingzhong;
		//save.goodsave[i][7]=goodlist.good[i].number;
		save.goodsave[i][7]=goodlist.good[i].hiscity;
		save.goodsave[i][8]=goodlist.good[i].hisfinder;
		save.goodsave[i][9]=goodlist.good[i].finded;

	}
	for(i=0;i<TASKLISTMAX;i++)
	{
		save.tasklistsave[i][0]=tasklist[i].num;
		save.tasklistsave[i][1]=tasklist[i].citynum;
		save.tasklistsave[i][2]=tasklist[i].heronum;
		save.tasklistsave[i][3]=tasklist[i].event;
		save.tasklistsave[i][4]=tasklist[i].data[0];
		save.tasklistsave[i][5]=tasklist[i].data[1];
		save.tasklistsave[i][6]=tasklist[i].data[2];
		save.tasklistsave[i][7]=tasklist[i].data[3];
		save.tasklistsave[i][8]=tasklist[i].data[4];
		save.tasklistsave[i][9]=tasklist[i].isend;
	}

	save.herolistsave[0]=herolist.unx;
	save.herolistsave[1]=herolist.uny;
	save.herolistsave[2]=herolist.number;
	save.herolistsave[3]=herolist.choice;
	save.herolistsave[4]=herolist.heronum;
	save.herolistsave[5]=herolist.fulunum;
	save.herolistsave[6]=herolist.athomenum;
	save.herolistsave[7]=herolist.otherwjnum;
	save.herolistsave[8]=herolist.otherjznum;
	save.herolistsave[9]=herolist.count;
	save.herolistsave[10]=herolist.listno;
	save.herolistsave[11]=herolist.ownernum;

	save.citylistsave[0]=citylist.unx;
	save.citylistsave[1]=citylist.uny;
	save.citylistsave[2]=citylist.number;
	save.citylistsave[3]=citylist.choice;

	save.goodlistsave[0]=goodlist.unx;
	save.goodlistsave[1]=goodlist.uny;
	save.goodlistsave[2]=goodlist.number;
	save.goodlistsave[3]=goodlist.choice;
	save.goodlistsave[4]=goodlist.goodnum;
	save.goodlistsave[5]=goodlist.herogoodnum;
	save.goodlistsave[6]=goodlist.count;
	save.goodlistsave[7]=goodlist.listno;
	save.goodlistsave[8]=goodlist.goodowner;

	save.gamemapsave[0]=unx;
	save.gamemapsave[1]=uny;
	save.gamemapsave[2]=currentcitynum;
	save.gamemapsave[3]=choice;
	save.gamemapsave[4]=citynumber;
	save.gamemapsave[5]=heronumber;
	save.gamemapsave[6]=ownernum;
	save.gamemapsave[7]=unum;
	save.gamemapsave[8]=choice;

	save.month=date.month;
	save.year1=date.year;

	save.tasknum=tasknum;

}

int GameMap::GetEnemyCity(int g)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	//ChangeRes(name);
	ifstream infile("Res\\arrive.sdt",ios::in);
	int tmpa;
	int tmpb;
	int x=0;
	int val[6];
	while(infile>>tmpa)
	{
		infile>>tmpb;
		if(tmpa==g)
		{
			val[x]=tmpb;
			x++;
		}
	}
	infile.close();	
	//ChangeRes(name);
	if(x == 0)return 0;//20170107
	//int rnd=rand()%x;

	int armsnow=0;//20170107
	int armsmax=0;
	int maxk=0;
	for(int k=0;k<x;k++)
	{
		for(int i=0;i<HEROMAX;i++)
		{
			if(herolist.hero[i].hiscity==val[k])
			{
				armsnow+=herolist.hero[i].bingli;
			}
		}
		if(armsnow>armsmax)
		{
			armsnow=armsmax;
			maxk=k;
		}
	}
	return val[maxk];
}

int GameMap::AutoBattle(int soldier,int foods,int soldierto,int foodsto)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int rnd=rand()%101;
	if(soldier==0)
	{
		return 0;//攻击方败
	}
	if(soldierto==0)
	{
		return 1;//攻击方胜
	}
	if(soldier>soldierto)
	{
		if((soldier>>2)>soldierto)
		{
			return (rnd>30);
		}
		else if(foods>foodsto)
		{
			return (rnd>40);
		}
		else
		{
			return (rnd>60);
		}
	}
	else
	{
		if(soldier<(soldierto>>2))
		{
			return (rnd>2);
		}
		else if(foods>foodsto)
		{
			return (rnd>30);
		}
		else
		{
			return (rnd>10);
		}
	}
	return 0;
}

void GameMap::AfterWar(int result,int citynum,int cityto)
{   
	wlogfile(1,__FUNCTION__,"开始",0);
	wlogfile(1,"GameMap::AfterWar","result = ",result);
	wlogfile(1,"GameMap::AfterWar","citynum = ",citynum);
	wlogfile(1,"GameMap::AfterWar","cityto = ",cityto);
	//char str[20]; 
	//sprintf_s(str,"%d %d %d",result,citynum,cityto);
	//ShowTextDirect(str,100,100,50);
	//Delay(10000);
	//战后处理
	if(result==0)return;
	endthisflag=0;
	my_warherononum = 0;//20150516修正的有关溢出问题，因此结束战斗后初始化
	warherononum = 0;
	OverflowCheck(__FILE__,__LINE__,CITYMAX,cityto);
	citylist.city[cityto].foods+=(fight.foodsto>0?fight.foodsto:0);
	citylist.city[cityto].foods+=(fight.foods>0?fight.foods:0);

	for(int i=0;i<fight.heronumber;i++)
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,fight.fighthero[i].num);
		herolist.hero[fight.fighthero[i].num].bingli=fight.fighthero[i].bingli;
		herolist.hero[fight.fighthero[i].num].degree=fight.fighthero[i].degree;
		herolist.hero[fight.fighthero[i].num].experience=fight.fighthero[i].experience;
	}
	for(int i=10;i<fight.heronumberto+10;i++)
	{
		OverflowCheck(__FILE__,__LINE__,HEROMAX,fight.fighthero[i].num);
		herolist.hero[fight.fighthero[i].num].bingli=fight.fighthero[i].bingli;
		herolist.hero[fight.fighthero[i].num].degree=fight.fighthero[i].degree;
		herolist.hero[fight.fighthero[i].num].experience=fight.fighthero[i].experience;
	}

	//攻击方
	if(fight.warstyle==0)
	{
		if(result==-1)//失败
		{
			int ret=0;
			int retval = 0;
			int retvalDeath = 0;
			captiveflag=0;
			fighttodeathflag = 0;
			for(int i=0;i<fight.heronumber;i++)//我方武将被俘
			{
				int ret=BeCapatured(fight.fighthero[i].num,cityto);//判断是否被俘，并处理
				if(ret != -1 && ret < HEROMAX)retval=ret;
				if(ret != -1 && ret >= HEROMAX )retvalDeath=ret;
			}
			if(captiveflag==1)
			{
				char str[20];
				OverflowCheck(__FILE__,__LINE__,HEROMAX,retval);
				sprintf_s(str,"%s",t_heroName[retval]);

				TimerMessage(str,GetStrText("STR_CAV_NOTE1"),50,280,12,1,1000);
			}
			else if(captiveflag>1)
			{
				char str[20];
				OverflowCheck(__FILE__,__LINE__,HEROMAX,retval);
				sprintf_s(str,"%s",t_heroName[retval]);

				TimerMessage(str,GetStrText("STR_CAV_NOTE2") ,50,280,12,1,1000);

			}
			if(fighttodeathflag>=1 && retvalDeath > 0)
			{
				char str[20];
				OverflowCheck(__FILE__,__LINE__,HEROMAX,retvalDeath-HEROMAX);
				sprintf_s(str,"%s",t_heroName[retvalDeath-HEROMAX]);

				TimerMessage(str,GetStrText("STR_PERSONOVER"),50,280,12,1,1000);
			}


			if(endthisflag==1)//君主遭劫
			{
				char str[20];
				endthisflag=0;
				OverflowCheck(__FILE__,__LINE__,HEROMAX,ownernum-1);
				sprintf_s(str,"%s",t_heroName[ownernum-1]);
				TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
				//另立新君
				TimerMessage(GetStrText("STR_MAKENEWKING"),"",50,280,12,1,1000);
				//列表
				Show(0);
				herolist.Init(unx,uny,choice,25,ownernum);
				herolist.Show(0);
				if(heronumber - captiveflag == 0)//20150516增加对武将全部没有后的游戏结束
				{
					TimerMessage(GetStrText("STR_GAMELOST"),"",50,280,12,1,1000);
					PostQuitMessage(0);
					ExitProcess(0);
				}
				newownerflag=1;
			}
			else if(endthisflag==3)//我方势力灭亡
			{
				char str[20];
				endthisflag=0;
				OverflowCheck(__FILE__,__LINE__,HEROMAX,ownernum-1);
				sprintf_s(str,"%s",t_heroName[ownernum-1]);
				TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
				TimerMessage(GetStrText("STR_GAMELOST"),"",50,280,12,1,1000);
				DeleteLog();
				PostQuitMessage(0);
				ExitProcess(0);
			}
			captiveflag=0;
		}
		else if (result==-2)//胜利
		{
			OverflowCheck(__FILE__,__LINE__,CITYMAX,cityto);
			int tmpcityown=citylist.city[cityto].owner;
			citynumber++;
			captiveflag=0;
			for (int i=0;i<HEROMAX;i++)
			{
				if(herolist.hero[i].hiscity-1==cityto&&herolist.hero[i].owner<HEROMAX&&herolist.hero[i].owner>0&&herolist.hero[i].owner!=ownernum)
				{
					int ret=GetCaptive(i,cityto);//判断是否俘虏武将
				}

			}
			int tmpzlwj=0;
			for(int i=0;i<fight.heronumber;i++)//我方武将入驻
			{
				OverflowCheck(__FILE__,__LINE__,HEROMAX,fight.fighthero[i].num);
				herolist.hero[fight.fighthero[i].num].hiscity=cityto+1;
				if(i==0)
				{
					tmpzlwj=fight.fighthero[0].num;
				}
				else
				{
					if(herolist.hero[fight.fighthero[i].num].zili>herolist.hero[tmpzlwj].zili)
						tmpzlwj=fight.fighthero[i].num;
				}

			}
			citylist.city[cityto].ownto=tmpzlwj;//城市归属
			citylist.city[cityto].owner=ownernum;

			if(endthisflag==1)
			{
				char str[20];
				endthisflag=0;
				OverflowCheck(__FILE__,__LINE__,HEROMAX,tmpcityown-1);
				sprintf_s(str,"%s",t_heroName[tmpcityown-1]);

				TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
				//敌方另立新君
				//ownernum;
				int select=-1;
				for(int ko=0;ko<HEROMAX;ko++)
				{
					if(select==-1&&herolist.hero[ko].owner==tmpcityown)
					{
						select=ko;
					}
					if(select==-1)continue;
					OverflowCheck(__FILE__,__LINE__,HEROMAX,select);
					if(herolist.hero[ko].zili>herolist.hero[select].zili&&herolist.hero[ko].owner==tmpcityown)
					{
						select=ko;
					}
				}
				//select
				//ownernum=select;
				//处理城池变更主公
				for(int ko=0;ko<CITYMAX;ko++)
				{
					if(citylist.city[ko].owner==tmpcityown)
						citylist.city[ko].owner=select+1;
				}
				//处理武将变更主公
				for(int ko=0;ko<HEROMAX;ko++)
				{
					if(herolist.hero[ko].owner==tmpcityown)
						herolist.hero[ko].owner=select+1;
				}
				sprintf_s(str,"%s",t_heroName[select]);

				TimerMessage(str,GetStrText("STR_BEKING"),50,280,12,1,1000);

			}
			else if(endthisflag==2)//敌方势力灭亡
			{
				char str[20];
				endthisflag=0;
				OverflowCheck(__FILE__,__LINE__,HEROMAX,tmpcityown-1);
				sprintf_s(str,"%s",t_heroName[tmpcityown-1]);
				TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
				TimerMessage(str,GetStrText("STR_OVER"),50,280,12,1,1000);
				//增加检测势力数量，是否大获全胜
				CheckWin();
			}
			captiveflag=0;
		}
	}
	else
	{
		if(result==-1)//失败,防守方（我方）
		{
			int ret=0;
			int retval;
			citynumber--;
			OverflowCheck(__FILE__,__LINE__,CITYMAX,cityto);
			citylist.city[cityto].owner=-1;//先变为非我方所有
			captiveflag=0;
			for (int i=0;i<HEROMAX;i++)
			{
				if(herolist.hero[i].hiscity-1==cityto&&herolist.hero[i].owner>0&&herolist.hero[i].owner<HEROMAX)
				{
					int ret=BeCapatured(i,cityto);//判断是否被俘，并处理
					if(ret!=-1)retval=ret;
				}

			}

			int tmpzlwj=0;
			for(int i=10;i<fight.heronumberto+10;i++)//敌方武将入驻
			{
				OverflowCheck(__FILE__,__LINE__,HEROMAX,fight.fighthero[i].num);
				herolist.hero[fight.fighthero[i].num].hiscity=cityto+1;
				if(i==10)
				{
					tmpzlwj=fight.fighthero[10].num;
				}
				else
				{
					if(herolist.hero[fight.fighthero[i].num].zili>herolist.hero[tmpzlwj].zili)
						tmpzlwj=fight.fighthero[i].num;
				}

			}
			citylist.city[cityto].ownto=tmpzlwj;//城市归属
			OverflowCheck(__FILE__,__LINE__,HEROMAX,tmpzlwj);
			citylist.city[cityto].owner=herolist.hero[tmpzlwj].owner;

			//citylist.city[cityto].foods+=fight.foodsto;
			//citylist.city[cityto].foods+=fight.foods;



			if(captiveflag==1)
			{
				char str[20];
				OverflowCheck(__FILE__,__LINE__,HEROMAX,retval);
				sprintf_s(str,"%s",t_heroName[retval]);
				TimerMessage(str,GetStrText("STR_CAV_NOTE1"),50,280,12,1,1000);
			}
			else if(captiveflag>1)
			{
				char str[20];
				OverflowCheck(__FILE__,__LINE__,HEROMAX,retval);
				sprintf_s(str,"%s",t_heroName[retval]);
				TimerMessage(str,GetStrText("STR_CAV_NOTE2"),50,280,12,1,1000);

			}
			if(endthisflag==1)//君主遭劫
			{
				char str[20];
				endthisflag=0;
				OverflowCheck(__FILE__,__LINE__,HEROMAX,ownernum-1);
				sprintf_s(str,"%s",t_heroName[ownernum-1]);

				TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
				//另立新君
				TimerMessage(GetStrText("STR_MAKENEWKING"),"",50,280,12,1,1000);
				//列表
				Show(0);
				herolist.Init(unx,uny,choice,25,ownernum);
				herolist.Show(0);
				newownerflag=1;
			}
			else if(endthisflag==3)//我方势力灭亡
			{
				char str[20];
				endthisflag=0;
				OverflowCheck(__FILE__,__LINE__,HEROMAX,ownernum-1);
				sprintf_s(str,"%s",t_heroName[ownernum-1]);

				TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
				TimerMessage(GetStrText("STR_GAMELOST"),"",50,280,12,1,1000);
				DeleteLog();
				PostQuitMessage(0);
				ExitProcess(0);

			}
			captiveflag=0;
		}
		else if (result==-2)//胜利,我方防守
		{
			OverflowCheck(__FILE__,__LINE__,CITYMAX,citynum);
			int tmpcityown=citylist.city[citynum].owner;
			captiveflag=0;
			tempFlagForCap=5;
			for(int i=10;i<fight.heronumberto+10;i++)//我方俘虏武将
			{
				int ret=GetCaptive(fight.fighthero[i].num,cityto);//判断是否俘虏，并处理
			}
			tempFlagForCap=0;

			//citylist.city[cityto].foods+=fight.foodsto;
			//citylist.city[cityto].foods+=fight.foods;

			if(endthisflag==1)
			{
				char str[20];
				endthisflag=0;
				int tmpcityown=citylist.city[citynum].owner;
				OverflowCheck(__FILE__,__LINE__,HEROMAX,tmpcityown-1);
				sprintf_s(str,"%s",t_heroName[tmpcityown-1]);

				TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
				//另立新君
				//ownernum;
				int select=-1;
				for(int ko=0;ko<HEROMAX;ko++)
				{
					if(select==-1&&herolist.hero[ko].owner==tmpcityown)
					{
						select=ko;
					}
					if(select==-1)continue;
					OverflowCheck(__FILE__,__LINE__,HEROMAX,select);
					if(herolist.hero[ko].zili>herolist.hero[select].zili&&herolist.hero[ko].owner==tmpcityown)
					{
						select=ko;
					}
				}
				//2013-8-1增加 处理敌方武将全部进攻而且全部被俘虏的情况
				if(select==-1)
				{
					endthisflag=2;
					goto st;
				}
				//select
				//ownernum=select;
				//处理城池变更主公
				for(int ko=0;ko<CITYMAX;ko++)
				{
					if(citylist.city[ko].owner==tmpcityown)
						citylist.city[ko].owner=select+1;
				}
				//处理武将变更主公
				for(int ko=0;ko<HEROMAX;ko++)
				{
					if(herolist.hero[ko].owner==tmpcityown)
						herolist.hero[ko].owner=select+1;
				}
				sprintf_s(str,"%s",t_heroName[select]);

				TimerMessage(str,GetStrText("STR_BEKING"),50,280,12,1,1000);

			}
st:
			if(endthisflag==2)
			{
				char str[20];
				endthisflag=0;
				OverflowCheck(__FILE__,__LINE__,HEROMAX,tmpcityown-1);
				sprintf_s(str,"%s",t_heroName[tmpcityown-1]);

				TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
				TimerMessage(str,GetStrText("STR_OVER"),50,280,12,1,1000);
				//增加检测势力数量，是否大获全胜
				for(int ko=0;ko<CITYMAX;ko++)
				{
					if(citylist.city[ko].owner==tmpcityown)
						citylist.city[ko].owner=ownernum;
				}
				CheckWin();
			}
			captiveflag=0;
		}
	}

}

void GameMap::AfterWar_Auto(int result,int citynum,int cityto,int heronum,int heronumto)//0失败 1胜利
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int tp_hero_now[HEROMAX];
	int tp_hero_to[HEROMAX];
	int tp_now=0;
	int tp_to=0;
	endthisflag=0;
	for (int i=0;i<HEROMAX;i++)
	{
		if((herolist.hero[i].hiscity-1)==citynum&&herolist.hero[i].owner>0&&herolist.hero[i].owner<HEROMAX)
		{
			tp_hero_now[tp_now]=i;
			tp_now++;
		}
		if((herolist.hero[i].hiscity-1)==cityto&&herolist.hero[i].owner>0&&herolist.hero[i].owner<HEROMAX)
		{
			tp_hero_to[tp_to]=i;
			tp_to++;
		}
	}
	if(result==0)//失败
	{
		int tip=tp_now>10?10:tp_now;
		captiveflag=0;
		for(int i=0;i<tip;i++)//攻方武将被俘
		{
			int ret=BeCapatured_Auto(tp_hero_now[i],cityto,heronum+1);//判断是否被俘，并处理
		}

		if(endthisflag==1)//君主遭劫
		{
			endthisflag=0;
			char str[20];
			OverflowCheck(__FILE__,__LINE__,HEROMAX,heronum);
			sprintf_s(str,"%s",t_heroName[heronum]);

			TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
			//另立新君
			int select=-1;
			for(int ko=0;ko<HEROMAX;ko++)
			{
				if(select==-1&&herolist.hero[ko].owner==heronum+1)
				{
					select=ko;
				}
				if(select==-1)continue;
				OverflowCheck(__FILE__,__LINE__,HEROMAX,select);
				if(herolist.hero[ko].zili>herolist.hero[select].zili&&herolist.hero[ko].owner==heronum+1)
				{
					select=ko;
				}
			}
			//处理城池变更主公
			for(int ko=0;ko<CITYMAX;ko++)
			{
				if(citylist.city[ko].owner==(heronum+1))
					citylist.city[ko].owner=(select+1);
			}
			//处理武将变更主公
			for(int ko=0;ko<HEROMAX;ko++)
			{
				if(herolist.hero[ko].owner==(heronum+1))
					herolist.hero[ko].owner=(select+1);
			}
			sprintf_s(str,"%s",t_heroName[select]);
			TimerMessage(str,GetStrText("STR_BEKING"),50,280,12,1,1000);
		}
		else if(endthisflag==2)//敌方势力灭亡
		{
			char str[20];
			sprintf_s(str,"%s",t_heroName[heronum]);
			TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
			TimerMessage(str,GetStrText("STR_OVER"),50,280,12,1,1000);

		}
		captiveflag=0;
	}
	else if (result==1)//胜利
	{
		int tip=tp_to;
		OverflowCheck(__FILE__,__LINE__,CITYMAX,cityto);
		int tmpcityown=citylist.city[cityto].owner;
		captiveflag=0;
		for(int i=0;i<tip;i++)//守方武将被俘
		{
			int ret=GetCaptive_Auto(tp_hero_to[i],cityto,heronumto+1);//判断是否被俘，并处理
		}
		tip=tp_now>10?10:tp_now;
		int tmpzlwj=0;
		for(int i=0;i<tip;i++)//我方武将入驻
		{
			OverflowCheck(__FILE__,__LINE__,HEROMAX,tp_hero_now[i]);
			herolist.hero[tp_hero_now[i]].hiscity=cityto+1;
			if(i==0)
			{
				tmpzlwj=tp_hero_now[i];
			}
			else
			{
				if(herolist.hero[tp_hero_now[i]].zili>herolist.hero[tmpzlwj].zili)
					tmpzlwj=tp_hero_now[i];
			}

		}
		citylist.city[cityto].ownto=tmpzlwj;//城市归属
		citylist.city[cityto].owner=heronum+1;

		//citylist.city[cityto].foods+=fight.foodsto;
		//citylist.city[cityto].foods+=fight.foods;
		//citynumber++;
		if(endthisflag==1)
		{
			char str[20];
			endthisflag=0;
			OverflowCheck(__FILE__,__LINE__,HEROMAX,tmpcityown-1);
			sprintf_s(str,"%s",t_heroName[tmpcityown-1]);

			TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
			//敌方另立新君
			//ownernum;
			int select=-1;
			for(int ko=0;ko<HEROMAX;ko++)
			{
				if(select==-1&&herolist.hero[ko].owner==tmpcityown)
				{
					select=ko;
				}
				if(select==-1)continue;
				if(herolist.hero[ko].zili>herolist.hero[select].zili&&herolist.hero[ko].owner==tmpcityown)
				{
					select=ko;
				}
			}
			//处理城池变更主公
			for(int ko=0;ko<CITYMAX;ko++)
			{
				if(citylist.city[ko].owner==tmpcityown)
					citylist.city[ko].owner=select+1;
			}
			//处理武将变更主公
			for(int ko=0;ko<HEROMAX;ko++)
			{
				if(herolist.hero[ko].owner==tmpcityown)
					herolist.hero[ko].owner=select+1;
			}
			OverflowCheck(__FILE__,__LINE__,HEROMAX,select);
			if(select != -1)//20170721
			{
				sprintf_s(str,"%s",t_heroName[select]);
				TimerMessage(str,GetStrText("STR_BEKING"),50,280,12,1,1000);
			}

		}
		else if(endthisflag==2)//敌方势力灭亡
		{
			char str[20];
			OverflowCheck(__FILE__,__LINE__,HEROMAX,tmpcityown-1);
			sprintf_s(str,"%s",t_heroName[tmpcityown-1]);
			TimerMessagePlus(GetStrText("STR_KING"),str,GetStrText("STR_DEAD"),50,280,12,1,1000);
			TimerMessage(str,GetStrText("STR_OVER"),50,280,12,1,1000);

		}
		captiveflag=0;
	}

}

void GameMap::AfterWar_SpaceCity(int a,int citynum,int cityto,int io)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	my_warherononum = 0;//20150516修正的有关溢出问题，因此结束战斗后初始化
	warherononum = 0;
	if(a==1)
	{
		int tmpzlwj=0;
		int tjp[10];
		OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,io);
		OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,io+1);
		OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,io+2);
		tjp[0]=tasklist[io].data[3];
		tjp[1]=tasklist[io+1].data[0];
		tjp[2]=tasklist[io+1].data[1];
		tjp[3]=tasklist[io+1].data[2];
		tjp[4]=tasklist[io+1].data[3];
		tjp[5]=tasklist[io+1].data[4];
		tjp[6]=tasklist[io+2].data[0];
		tjp[7]=tasklist[io+2].data[1];
		tjp[8]=tasklist[io+2].data[2];
		tjp[9]=tasklist[io+2].data[3];
		for(int i=0;i<10;i++)//我方武将入驻
		{
			if(tjp[i]==-1)break;
			OverflowCheck(__FILE__,__LINE__,HEROMAX,tjp[i]);
			herolist.hero[tjp[i]].hiscity=cityto+1;
			if(i==0)
			{
				tmpzlwj=tjp[i];
			}
			else
			{
				if(herolist.hero[tjp[i]].zili>herolist.hero[tmpzlwj].zili)
					tmpzlwj=tjp[i];
			}

		}
		OverflowCheck(__FILE__,__LINE__,CITYMAX,cityto);
		citylist.city[cityto].ownto=tmpzlwj;//城市归属
		citylist.city[cityto].owner=ownernum;

		citylist.city[cityto].foods+=tasklist[io].data[1];
		citynumber++;
	}
	else//a=2,我方无人城被攻占情况
	{
		int tmpzlwj=0;
		int tjp[10];
		OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,io);
		OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,io+1);
		OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,io+2);
		tjp[0]=tasklist[io].data[3];
		tjp[1]=tasklist[io+1].data[0];
		tjp[2]=tasklist[io+1].data[1];
		tjp[3]=tasklist[io+1].data[2];
		tjp[4]=tasklist[io+1].data[3];
		tjp[5]=tasklist[io+1].data[4];
		tjp[6]=tasklist[io+2].data[0];
		tjp[7]=tasklist[io+2].data[1];
		tjp[8]=tasklist[io+2].data[2];
		tjp[9]=tasklist[io+2].data[3];
		for(int i=0;i<10;i++)//敌方武将入驻
		{
			if(tjp[i]==-1)break;
			OverflowCheck(__FILE__,__LINE__,HEROMAX,tjp[i]);
			herolist.hero[tjp[i]].hiscity=cityto+1;
			if(i==0)
			{
				tmpzlwj=tjp[i];
			}
			else
			{
				if(herolist.hero[tjp[i]].zili>herolist.hero[tmpzlwj].zili)
					tmpzlwj=tjp[i];
			}

		}
		OverflowCheck(__FILE__,__LINE__,CITYMAX,cityto);
		citylist.city[cityto].ownto=tmpzlwj+1;//城市归属
		citylist.city[cityto].owner=herolist.hero[tmpzlwj].owner;

		citylist.city[cityto].foods+=tasklist[io].data[1];
		citynumber--;
	}

}

void GameMap::SetFightHeroData(int i)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int style;
	OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,i);
	OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,i+1);
	OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,i+2);
	style=tasklist[i+2].data[4];//0进攻战 1防守
	fight.warstyle=style;

	fight.fighthero[0].num=tasklist[i].data[3];
	fight.fighthero[1].num=tasklist[i+1].data[0];
	fight.fighthero[2].num=tasklist[i+1].data[1];
	fight.fighthero[3].num=tasklist[i+1].data[2];
	fight.fighthero[4].num=tasklist[i+1].data[3];
	fight.fighthero[5].num=tasklist[i+1].data[4];
	fight.fighthero[6].num=tasklist[i+2].data[0];
	fight.fighthero[7].num=tasklist[i+2].data[1];
	fight.fighthero[8].num=tasklist[i+2].data[2];
	fight.fighthero[9].num=tasklist[i+2].data[3];

	//specicalhero;//1庞统 2诸葛亮 3华佗 4徐庶
	for(int j=0;j<10;j++)//我方
	{
		if(fight.fighthero[j].num>=0)
		{
			
			OverflowCheck(__FILE__,__LINE__,HEROMAX,fight.fighthero[i].num);
			fight.fighthero[j].degree=herolist.hero[fight.fighthero[j].num].degree;
			fight.fighthero[j].style=herolist.hero[fight.fighthero[j].num].style;
			fight.fighthero[j].wuli=herolist.hero[fight.fighthero[j].num].wuli;
			fight.fighthero[j].zili=herolist.hero[fight.fighthero[j].num].zili;
			fight.fighthero[j].bingli=herolist.hero[fight.fighthero[j].num].bingli;
			fight.allbingli+=herolist.hero[fight.fighthero[j].num].bingli;
			fight.fighthero[j].experience=herolist.hero[fight.fighthero[j].num].experience;
			fight.fighthero[j].tili=herolist.hero[fight.fighthero[j].num].tili;
			fight.fighthero[j].moveup=herolist.hero[fight.fighthero[j].num].speedup;
			fight.fighthero[j].specicalhero=0;

			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
				fight.fighthero[j].isemporer = 1;
			}
			fight.fighthero[j].InitSpecialHeroList();
			/*switch(choice)
			{
			case DZNQ:
			{
			if(fight.fighthero[j].num==124)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==157)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==184)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==135)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			case CCJQ:
			{
			if(fight.fighthero[j].num==170)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==169)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==171)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			case CBZZ:
			{
			if(fight.fighthero[j].num==165)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==90)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==185)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==20)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			case SGDL:
			{
			if(fight.fighthero[j].num==72)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==152)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==5)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			}*/
		}
		else
		{
			break;
		}
	}



	for(int j=10;j<20;j++)//敌方
	{
		if(fight.fighthero[j].num>=0)
		{
			OverflowCheck(__FILE__,__LINE__,HEROMAX,fight.fighthero[i].num);
			fight.fighthero[j].degree=herolist.hero[fight.fighthero[j].num].degree;
			fight.fighthero[j].style=herolist.hero[fight.fighthero[j].num].style;
			fight.fighthero[j].wuli=herolist.hero[fight.fighthero[j].num].wuli;
			fight.fighthero[j].zili=herolist.hero[fight.fighthero[j].num].zili;
			fight.fighthero[j].bingli=herolist.hero[fight.fighthero[j].num].bingli;
			fight.allbinglito+=herolist.hero[fight.fighthero[j].num].bingli;
			fight.fighthero[j].experience=herolist.hero[fight.fighthero[j].num].experience;
			fight.fighthero[j].tili=herolist.hero[fight.fighthero[j].num].tili;
			fight.fighthero[j].moveup=herolist.hero[fight.fighthero[j].num].speedup;
			fight.fighthero[j].specicalhero=0;

			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
				fight.fighthero[j].isemporer = 1;
			}
			fight.fighthero[j].InitSpecialHeroList();
			/*switch(choice)
			{
			case DZNQ:
			{
			if(fight.fighthero[j].num==124)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==157)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==184)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==135)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer = 1;
			}
			break;
			}
			case CCJQ:
			{
			if(fight.fighthero[j].num==170)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==169)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==171)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer = 1;
			}
			break;
			}
			case CBZZ:
			{
			if(fight.fighthero[j].num==165)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==90)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==185)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==20)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer = 1;
			}
			break;
			}
			case SGDL:
			{
			if(fight.fighthero[j].num==72)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==152)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==5)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer = 1;
			}
			break;
			}
			}*/
		}
		else
		{
			break;
		}
	}

}

void GameMap::SetFightHeroData2(int i)
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int style;
	style=tasklist[i+2].data[4];//0进攻战 1防守
	fight.warstyle=style;
	OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,i);
	OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,i+1);
	OverflowCheck(__FILE__,__LINE__,TASKLISTMAX,i+2);

	fight.fighthero[10].num=tasklist[i].data[3];
	fight.fighthero[11].num=tasklist[i+1].data[0];
	fight.fighthero[12].num=tasklist[i+1].data[1];
	fight.fighthero[13].num=tasklist[i+1].data[2];
	fight.fighthero[14].num=tasklist[i+1].data[3];
	fight.fighthero[15].num=tasklist[i+1].data[4];
	fight.fighthero[16].num=tasklist[i+2].data[0];
	fight.fighthero[17].num=tasklist[i+2].data[1];
	fight.fighthero[18].num=tasklist[i+2].data[2];
	fight.fighthero[19].num=tasklist[i+2].data[3];

	//specicalhero;//1庞统 2诸葛亮 3华佗 4徐庶
	for(int j=0;j<10;j++)//我方
	{
		if(fight.fighthero[j].num>=0)
		{
			OverflowCheck(__FILE__,__LINE__,HEROMAX,fight.fighthero[i].num);
			fight.fighthero[j].degree=herolist.hero[fight.fighthero[j].num].degree;
			fight.fighthero[j].style=herolist.hero[fight.fighthero[j].num].style;
			fight.fighthero[j].wuli=herolist.hero[fight.fighthero[j].num].wuli;
			fight.fighthero[j].zili=herolist.hero[fight.fighthero[j].num].zili;
			fight.fighthero[j].bingli=herolist.hero[fight.fighthero[j].num].bingli;
			fight.allbingli+=herolist.hero[fight.fighthero[j].num].bingli;
			fight.fighthero[j].experience=herolist.hero[fight.fighthero[j].num].experience;
			fight.fighthero[j].tili=herolist.hero[fight.fighthero[j].num].tili;
			fight.fighthero[j].moveup=herolist.hero[fight.fighthero[j].num].speedup;
			fight.fighthero[j].specicalhero=0;

			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
				fight.fighthero[j].isemporer = 1;
			}
			fight.fighthero[j].InitSpecialHeroList();
			/*switch(choice)
			{
			case DZNQ:
			{
			if(fight.fighthero[j].num==124)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==157)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==184)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==135)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			case CCJQ:
			{
			if(fight.fighthero[j].num==170)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==169)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==171)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			case CBZZ:
			{
			if(fight.fighthero[j].num==165)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==90)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==185)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==20)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			case SGDL:
			{
			if(fight.fighthero[j].num==72)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==152)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==5)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			}*/
		}
		else
		{
			break;
		}
	}



	for(int j=10;j<20;j++)//敌方
	{
		if(fight.fighthero[j].num>=0)
		{
			OverflowCheck(__FILE__,__LINE__,HEROMAX,fight.fighthero[i].num);
			fight.fighthero[j].degree=herolist.hero[fight.fighthero[j].num].degree;
			fight.fighthero[j].style=herolist.hero[fight.fighthero[j].num].style;
			fight.fighthero[j].wuli=herolist.hero[fight.fighthero[j].num].wuli;
			fight.fighthero[j].zili=herolist.hero[fight.fighthero[j].num].zili;
			fight.fighthero[j].bingli=herolist.hero[fight.fighthero[j].num].bingli;
			fight.allbinglito+=herolist.hero[fight.fighthero[j].num].bingli;
			fight.fighthero[j].experience=herolist.hero[fight.fighthero[j].num].experience;
			fight.fighthero[j].tili=herolist.hero[fight.fighthero[j].num].tili;
			fight.fighthero[j].moveup=herolist.hero[fight.fighthero[j].num].speedup;
			fight.fighthero[j].specicalhero=0;

			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
				fight.fighthero[j].isemporer = 1;
			}
			fight.fighthero[j].InitSpecialHeroList();
			/*switch(choice)
			{
			case DZNQ:
			{
			if(fight.fighthero[j].num==124)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==157)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==184)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==135)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			case CCJQ:
			{
			if(fight.fighthero[j].num==170)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==169)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==171)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			case CBZZ:
			{
			if(fight.fighthero[j].num==165)
			{
			fight.fighthero[j].specicalhero=1;
			}
			if(fight.fighthero[j].num==90)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==185)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==20)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			case SGDL:
			{
			if(fight.fighthero[j].num==72)
			{
			fight.fighthero[j].specicalhero=2;
			}
			if(fight.fighthero[j].num==152)
			{
			fight.fighthero[j].specicalhero=3;
			}
			if(fight.fighthero[j].num==5)
			{
			fight.fighthero[j].specicalhero=4;
			}
			if(fight.fighthero[j].num==herolist.hero[fight.fighthero[j].num].owner-1)
			{
			fight.fighthero[j].isemporer == 1;
			}
			break;
			}
			}*/

		}
		else
		{
			break;
		}
	}

}

void GameMap::SetForce()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	for(int y=0;y<HEROMAX;y++)
	{
		if(herolist.hero[y].owner==ownernum)
		{
			herolist.hero[y].bingli=100;
		}
		else if(herolist.hero[y].owner>0&&herolist.hero[y].owner<HEROMAX)
		{
			herolist.hero[y].bingli=800;
		}
	}
}

int GameMap::BeCapatured(int num,int cityto)//我方武将是否被俘虏
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int tpcity[CITYMAX];
	int k=0;
	for(int i=0;i<CITYMAX;i++)
	{
		if(citylist.city[i].owner==ownernum)
		{
			tpcity[k]=i;
			k++;
		}
	}
	if(k==0)//(我方为防守方，全军覆没情况)
	{
		//我方势力灭亡
		endthisflag=3;	
		return -1;
	}
	int rnd = rand() % 100;
	if (rnd >herolist.hero[num].zili)
	{
		//被俘虏
		if(herolist.hero[num].no+1==ownernum)
		{
			//俘虏了君主，君主遭劫
			endthisflag=1;
		}


		captiveflag++;
		herolist.hero[num].hiscity=1+cityto;
		herolist.hero[num].owner+=HEROMAX;//表明为俘虏
		herolist.hero[num].iscaptive = 1;
		herolist.hero[num].bingli=0;
		DelCaptureGood(num,cityto);
		return num;
	}
	else if(rnd == 0)//战死
	{
		if(herolist.hero[num].no+1==ownernum)//如果是君主 不处理战死
		{
			int rnd=rand()%k;
			herolist.hero[num].hiscity=1+tpcity[rnd];//随机转移武将
			return -1;
		}
		fighttodeathflag++;
		herolist.hero[num].hiscity=0;//战死的城池
		herolist.hero[num].owner = 0;//170603
		herolist.hero[num].iscaptive = 0;//战死不俘虏
		herolist.hero[num].bingli=0;
		DelCaptureGood(num,cityto);
		return HEROMAX+num;
	}
	else
	{
		int rnd=rand()%k;
		herolist.hero[num].hiscity=1+tpcity[rnd];//随机转移武将
	}
	return -1;
}

int GameMap::GetCaptive(int num,int cityto)//我方是否获得俘虏
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int tpcitynumto=0;
	int tpcity[CITYMAX];
	for(int i=0;i<CITYMAX;i++)
	{
		if(citylist.city[i].owner==herolist.hero[num].owner&&i!=(herolist.hero[num].hiscity-1))//citylist.city[i].owner==citylist.city[cityto].owner&&i!=cityto
		{
			tpcity[tpcitynumto]=i;
			tpcitynumto++;
		}
	}
	if(tpcitynumto==0&&tempFlagForCap!=5)//全军覆没
	{
		//显示君主遭劫，敌方势力灭亡,需添加
		//俘虏了君主，君主遭劫
		endthisflag=2;
		herolist.hero[num].hiscity=1+cityto;//武将全部归我方
		herolist.hero[num].owner+=HEROMAX;//表明为俘虏
		herolist.hero[num].iscaptive = 1;
		herolist.hero[num].bingli=0;
		//没收道具
		DelCaptureGood(num,cityto);
		return -1;
	}
	else if (tpcitynumto == 0)//在生成攻击事件后 敌人老家被端的情况 这种情况不做任何处理
		{
			return -1;
		}

	int rnd = rand() % 100;
	if (rnd >herolist.hero[num].zili)
	{
		//俘虏
		if(herolist.hero[num].owner-1==herolist.hero[num].no)
		{
			//俘虏了君主，君主遭劫
			endthisflag=1;
		}
		captiveflag++;
		herolist.hero[num].hiscity=1+cityto;
		herolist.hero[num].owner+=HEROMAX;//表明为俘虏
		herolist.hero[num].iscaptive = 1;
		herolist.hero[num].bingli=0;
		//没收道具
		DelCaptureGood(num,cityto);
		return num;
	}
	else
	{
		if(tempFlagForCap==5)
		{
			for(int i=0;i<CITYMAX;i++)
			{
				if(citylist.city[i].owner==herolist.hero[num].owner)
				{
					tpcity[tpcitynumto]=i;
					tpcitynumto++;
				}
			}
		}
		if(tpcitynumto != 0) 
		{
			int rnd=rand()%tpcitynumto;
			herolist.hero[num].hiscity=1+tpcity[rnd];//随机转移武将
		}
	}
	return -1;
}

int GameMap::BeCapatured_Auto(int num,int cityto,int tmp_ownernum)//我方武将是否被俘虏
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int tpcity[CITYMAX];
	int k=0;
	for(int i=0;i<CITYMAX;i++)
	{
		if(citylist.city[i].owner==tmp_ownernum)
		{
			tpcity[k]=i;
			k++;
		}
	}
	if(k==0)//(防守方，全军覆没情况)
	{
		//防守方势力灭亡
		endthisflag=2;	
		return -1;
	}

	int rnd = rand() % 100;
	if (rnd >herolist.hero[num].zili)
	{
		//被俘虏
		if(herolist.hero[num].no+1==tmp_ownernum)
		{
			//俘虏了君主，君主遭劫
			endthisflag=1;
		}

		captiveflag++;
		herolist.hero[num].hiscity=1+cityto;
		herolist.hero[num].owner+=HEROMAX;//表明为俘虏
		herolist.hero[num].iscaptive = 1;
		herolist.hero[num].bingli=0;
		//没收道具
	DelCaptureGood(num,cityto);
		if(captiveflag==1)return num;
	}
	else
	{
		int rnd=rand()%k;
		herolist.hero[num].hiscity=1+tpcity[rnd];//随机转移武将
	}
	return -1;
}

int GameMap::GetCaptive_Auto(int num,int cityto,int tmp_ownernum)//我方是否获得俘虏
{
	wlogfile(1,__FUNCTION__,"开始",0);
	int tpcitynumto=0;
	int tpcity[CITYMAX];
	for(int i=0;i<CITYMAX;i++)
	{
		if(citylist.city[i].owner==citylist.city[cityto].owner&&i!=cityto)
		{
			tpcity[tpcitynumto]=i;
			tpcitynumto++;
		}
	}
	if(tpcitynumto==0)//全军覆没
	{
		//显示君主遭劫，敌方势力灭亡,需添加
		//俘虏了君主，君主遭劫
		endthisflag=2;
		herolist.hero[num].hiscity=1+cityto;//武将全部归我方
		herolist.hero[num].owner+=HEROMAX;//表明为俘虏
		herolist.hero[num].iscaptive = 1;
		herolist.hero[num].bingli=0;
		DelCaptureGood(num,cityto);
		return -1;
	}
	int rnd = rand() % 100;
	if (rnd >herolist.hero[num].zili)
	{
		//俘虏
		if((herolist.hero[num].owner-1)==herolist.hero[num].no)
		{
			//俘虏了君主，君主遭劫
			endthisflag=1;
		}
		captiveflag++;
		herolist.hero[num].hiscity=1+cityto;
		herolist.hero[num].owner+=HEROMAX;//表明为俘虏
		herolist.hero[num].iscaptive = 1;
		herolist.hero[num].bingli=0;
		//没收道具
		DelCaptureGood(num,cityto);
		if(captiveflag==1)return num;
	}
	else
	{
		int rnd=rand()%tpcitynumto;
		herolist.hero[num].hiscity=1+tpcity[rnd];//随机转移武将
	}
	return -1;
}

int GameMap::GetUnx(int my_tpcity)
{
	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;
		if(o==my_tpcity)
		{
			return tmpx;
		}
		o++;
	}
	infile.close();	
	//ChangeRes(name);
	return 0;
}

int GameMap::GetUny(int my_tpcity)
{
	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;
		if(o==my_tpcity)
		{
			return tmpy;
		}
		o++;
	}
	infile.close();	
	//ChangeRes(name);
	return 0;
}

void GameMap::CheckWin()
{
	wlogfile(1,__FUNCTION__,"开始",0);
	for(int i=0;i<CITYMAX;i++)
	{
		if(citylist.city[i].owner!=ownernum&&citylist.city[i].owner!=0)
			return;
	}
	TimerMessage(GetStrText("STR_GAMEWON"),"",50,280,12,1,1000);
	DeleteLog();
	PostQuitMessage(0);
}

void GameMap::DelTimeEvent()
{
	//wlogfile(1,__FUNCTION__,"开始",0);
	if(flagwar == 1)
	{
		fight.DelTimeEvent();
	}
	else if(alwaysSave == 1)//实时存档
	{
		saveTemp ++;
		if(saveTemp > 40)//1.5*40=60s
		{
			saveTemp = 0;
			ChangeDataToSave();	
			save.Write(0);
		}
	}
}

/***********************************************************************
* 说明:     武将属性检查
* 输入参数: int i
* 返回值  : 无 
* 功能	   :  
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb        2017-4-27        完成基本功能
***********************************************************************/ 
void GameMap::HeroCheck(int i)
{
	wlogfile(1,__FUNCTION__,"开始",0);

	OverflowCheck(__FILE__,__LINE__,DEGREEMAX,herolist.hero[i].degree);
	OverflowCheck(__FILE__,__LINE__,99,herolist.hero[i].experience);
	OverflowCheck(__FILE__,__LINE__,GOODMAX,herolist.hero[i].goods1);
	OverflowCheck(__FILE__,__LINE__,GOODMAX,herolist.hero[i].goods2);
	OverflowCheck(__FILE__,__LINE__,40,herolist.hero[i].hiscity);
	OverflowCheck(__FILE__,__LINE__,200,herolist.hero[i].wuli);
	OverflowCheck(__FILE__,__LINE__,200,herolist.hero[i].zili);

	if(herolist.hero[i].degree>DEGREEMAX)herolist.hero[i].degree=DEGREEMAX;
	if(herolist.hero[i].experience>99)herolist.hero[i].experience=99;
	if(herolist.hero[i].goods1>GOODMAX)herolist.hero[i].goods1=0;
	if(herolist.hero[i].goods2>GOODMAX)herolist.hero[i].goods2=0;
	if(herolist.hero[i].hiscity>CITYMAX)herolist.hero[i].hiscity=0;
	if(herolist.hero[i].owner<0)herolist.hero[i].owner=0;
	if(herolist.hero[i].wuli>200)herolist.hero[i].wuli=200;
	if(herolist.hero[i].zili>200)herolist.hero[i].zili=200;
	if(herolist.hero[i].inlistflag!=3)herolist.hero[i].inlistflag=1;
}

int GameMap::DelCaptureGood(int num,int cityto)
{
	if(herolist.hero[num].goods1!=0)
	{
		OverflowCheck(__FILE__,__LINE__,GOODMAX,herolist.hero[num].goods1-1);
		herolist.hero[num].wuli=herolist.hero[num].wuli-goodlist.good[herolist.hero[num].goods1-1].wuliup;
		herolist.hero[num].zili=herolist.hero[num].zili-goodlist.good[herolist.hero[num].goods1-1].ziliup;
		herolist.hero[num].speedup=herolist.hero[num].speedup -goodlist.good[herolist.hero[num].goods1-1].speedup;
		goodlist.good[herolist.hero[num].goods1-1].hiscity=cityto+1;
		goodlist.good[herolist.hero[num].goods1-1].owner=0;
		herolist.hero[num].goods1=0;
	}
	if(herolist.hero[num].goods2!=0)
	{
		OverflowCheck(__FILE__,__LINE__,GOODMAX,herolist.hero[num].goods2-1);
		herolist.hero[num].wuli=herolist.hero[num].wuli-goodlist.good[herolist.hero[num].goods2-1].wuliup;
		herolist.hero[num].zili=herolist.hero[num].zili-goodlist.good[herolist.hero[num].goods2-1].ziliup;
		herolist.hero[num].speedup=herolist.hero[num].speedup -goodlist.good[herolist.hero[num].goods2-1].speedup;
		goodlist.good[herolist.hero[num].goods2-1].hiscity=cityto+1;
		goodlist.good[herolist.hero[num].goods2-1].owner=0;
		herolist.hero[num].goods2=0;
	}
	return 0;
}
