/***********************************************************************
*Copyright (c)2012 , 天际边工作室
*All rights reserved.
**
文件名称：	Fight.cpp
*摘要：		游戏主地图类
**
*修改历史：
*	版本    日期     作者     改动内容和原因
*   ----------------------------------------------------
*	1.0    2012-10-5  wstjb     基本的功能完成
***********************************************************************/
#define DEBUG_CLIENTBLOCK  new( _CLIENT_BLOCK, __FILE__, __LINE__)
#define _CRTDBG_MAP_ALLOC
#define new DEBUG_CLIENTBLOCK
#include "Fight.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.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  int color;
extern  int flag;

extern int KeyReturn;
extern int KeyEsc;
extern int KeyHome;
extern int KeySpace;
extern int KeyLeft0;
extern int KeyUp0;
extern int KeyRight0;
extern int KeyDown0;
extern int KeyR;
extern int KeyPageUp;
extern int KeyPageDown;

extern byte resByte[2731][16384];//存储lib资源
extern int resByteLen[2731];
extern int resPos[2731][6];//存储lib地址和编号 第六位为长度
extern int resCount;

extern int g_debugFlag;
extern int disableAnima;
extern int fgtDebug;//20171003
//战斗全局变量定义
int g_selectedFightStyle[3];//战斗类型
int g_selectedEnemyId[3];//选定敌人ID
int g_selectedGood[3][2];
int g_selectedMagic[3];

extern char menu_money[6+1];//"金钱："
extern char menu_num[6+1];//"数量"
extern char menu_price[4+1];//"价"
extern char menu_name[4+1];//"名"
extern char menu_cost[6+1];//"耗真气"
extern char menu_degree[4+1];//"等级"
extern char menu_hp[4+1];//"生命"
extern char menu_mp[4+1];//"真气"
extern char menu_at[6+1];//"攻击力"
extern char menu_df[6+1];//"防御力"
extern char menu_exp[6+1];//"经验值"
extern char menu_speed[4+1];//"身法"
extern char menu_anima[4+1];//"灵力"
extern char menu_luck[4+1];//"幸运"
extern char menu_anti[4+1];//menu_anti

/***********************************************************************
* 说明:     Fight类初始化函数
* 输入参数: int num——用于设定君主等信息，由君主选择传值过来
* 返回值  : 无
* 功能	   : 初始化
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void Fight::Init(int scrb,int scrl,int scrr,int f0,int f1,int f2,int f3,int f4,int f5,int f6,int f7)//INITFIGHT f0 f1 f2 f3 f4 f5 f6 f7 scrb scrl scrr
{
	this->enemyType[0] = f0;
	this->enemyType[1] = f1;
	this->enemyType[2] = f2;
	this->enemyType[3] = f3;
	this->enemyType[4] = f4;
	this->enemyType[5] = f5;
	this->enemyType[6] = f6;
	this->enemyType[7] = f7;
	this->scrb = scrb;
	this->scrl = scrl;
	this->scrr = scrr;


	for(int i = 0 ; i< 3;i++)
	{
		//fighthero[i] = new FightHero();
		fighthero[i].Init();

	}

	for(int i = 0 ; i< 3;i++)
	{
		//fightEnemy[i] = new FightEnemy();
		//fightEnemy[i].Init();

	}

	for(int i = 0 ;i< 6;i++)
	{
		//magicList[i] = new MagicList();
	}

	for(int i = 0 ;i< 3;i++)
	{
		//degreeList[i] = new DegreeList();
		//degreeList[i].Init(i+1);
	}

	//随机化选择敌人
	//randomEnemy();

	////menuChoice = new Menu();
	//menuChoice.Init(0,0,0,0,0);

	//menuChoice = new Menu();
	menuChoice.Init(2,5,9,4,6,0);

	//menuGood = new Menu();
	menuGood.Init(2,3,26,14,7,0);

	//goodList = new GoodList();
	goodList.Init();
	//equipList = new GoodList();
	equipList.Init();
	//throwList = new GoodList();
	throwList.Init();

	tmpselectedEnemy = 0;
	selectedFightHero = 0;//初始化 选定使用角色
	selectedHeroFinished = 0;
	keytmp = 0;
	missflag = 1;//默认开启miss
}

/***********************************************************************
* 说明:     Fight类初始化函数
* 输入参数: int num——用于设定君主等信息，由君主选择传值过来
* 返回值  : 无
* 功能	   : 初始化
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void Fight::EnterInit(int roundmax,int f0,int f1,int f2,int scrb ,int scrl,int scrr,int evtrnd0 ,int evtrnd1,int evtrnd2 ,int evt0 ,int evt1 ,int evt2 ,int lossto ,int winto)//ENTERFIGHT roundmax f0 f1 f2 scrb scrl scrr evtrnd0 evtrnd1 evtrnd2 evt0 evt1 evt2 lossto winto
{
	wlogfile(1, __FUNCTION__ ,"开始",0);
	allMoney = 0;//20160817修正
	allExp = 0;//20160817修正

	memset(fightEnemy,0,sizeof(fightEnemy));
	fightEnemy[0].hp = 0;
	fightEnemy[1].hp = 0;
	fightEnemy[2].hp = 0;
	flagEnemyDied[0] = 1;
	flagEnemyDied[1] = 1;
	flagEnemyDied[2] = 1;

	this->e_enemyType[0] = f0;
	this->e_enemyType[1] = f1;
	this->e_enemyType[2] = f2;

	this->e_scrb = scrb;
	this->e_scrl = scrl;
	this->e_scrr = scrr;

	this->e_roundmax =roundmax;
	this->e_evtrnd[0] =evtrnd0;
	this->e_evtrnd[1] =evtrnd1;
	this->e_evtrnd[2] =evtrnd2;

	this->e_evt[0] =evt0;
	this->e_evt[1] =evt1;
	this->e_evt[2] =evt2;

	this->e_lossto = lossto;
	this->e_winto = winto;
	fightType = 1;
	currentRound = 0;

	selectedFightHero = 0;
	selectedFightStyle =0;


	enemySum = 0;
	livedEnemySum = 0;

	//20161030修正goodhave初始化
	for(int p_i = 0 ;p_i < 6 ;p_i ++)
	{
		for(int p_j = 0 ; p_j < 3 ; p_j ++)
		{
			goodHave[p_i][p_j] = 0;
		}
	}

	enemy[0] = 0;//20161220
	enemy[1] = 0;//20161220
	enemy[2] = 0;//20161220

	for(int i = 0 ; i< 3;i++)
	{
		flagDied[i] = 0;
		flagEnemyDied[i] = 0;
		fightEnemy[i].Init(e_enemyType[i]);

		if(e_enemyType[i]!=0)
		{
			enemySum++;
			livedEnemySum ++ ;
			livedEnemy[livedEnemySum-1] = i;
			enemy[livedEnemySum-1] = i;
			allMoney+=fightEnemy[i].money;
			allExp+=fightEnemy[i].exp;
			goodHave[i*2][0]=fightEnemy[i].goods1type;
			goodHave[i*2][1]=fightEnemy[i].goods1idx;
			goodHave[i*2][2]=fightEnemy[i].goods1num;
			goodHave[i*2+1][0]=fightEnemy[i].goods2type;
			goodHave[i*2+1][1]=fightEnemy[i].goods2idx;
			goodHave[i*2+1][2]=fightEnemy[i].goods2num;
		}
	}
	tmpselectedEnemy = livedEnemy[0];

}

/***********************************************************************
* 说明:     Fight类显示函数
* 输入参数: WPARAM KeyCode——按键信息，用于控制地图移动与对应的显示
* 返回值  : 无
* 功能	   : 显示地图及相关界面
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-5       完成基本功能
***********************************************************************/
void Fight::Show(WPARAM KeyCode)
{

	if(flagShowEquipCompare == 1)
	{
		int equipType = equipList.equipInList[selectedGood][0];
		int equipIdx = equipList.equipInList[selectedGood][1];

		int equipType1 = equipList.equipInList[selectedGood][0];
		int equipIdx1 = 0;
		if(equipType1 == 1)//head
		{
			equipIdx1 = fighthero[t_selectedFightHero].head;
		}
		if(equipType1 == 2)//body
		{
			equipIdx1 = fighthero[t_selectedFightHero].body;
		}
		if(equipType1 == 3)//foot
		{
			equipIdx1 = fighthero[t_selectedFightHero].foot;
		}
		if(equipType1 == 4)//shoulder
		{
			equipIdx1 = fighthero[t_selectedFightHero].shoulder;
		}
		if(equipType1 == 5)//sleeve
		{
			equipIdx1 = fighthero[t_selectedFightHero].sleeve;
		}
		if(equipType1 == 6)//decorate1
		{
			if(fighthero[t_selectedFightHero].decorate1!=0&&fighthero[t_selectedFightHero].decorate2==0)
			{
				equipIdx1 = fighthero[t_selectedFightHero].decorate2;
				flagDecorate = 2;
			}
			else
			{
				equipIdx1 = fighthero[t_selectedFightHero].decorate1;
				flagDecorate = 1;
			}
		}
		if(equipType1 == 7)//hand
		{
			equipIdx1 = fighthero[t_selectedFightHero].hand;
		}

		ClrScence();

		ShowHeadPic(0,fighthero[t_selectedFightHero].no,10,62);

		ShowGoodPic(0,equipType,equipIdx,10,2);
		ShowGoodPic(0,equipType1,equipIdx1,10,32);


		//attFlag2 = 0;

		MoveToEx(hdcTmp,1,10+attFlag2*30,NULL);
		LineTo(hdcTmp,1,25+attFlag2*30);
		MoveToEx(hdcTmp,2,11+attFlag2*30,NULL);
		LineTo(hdcTmp,2,24+attFlag2*30);
		MoveToEx(hdcTmp,3,12+attFlag2*30,NULL);
		LineTo(hdcTmp,3,23+attFlag2*30);
		MoveToEx(hdcTmp,4,13+attFlag2*30,NULL);
		LineTo(hdcTmp,4,22+attFlag2*30);
		MoveToEx(hdcTmp,5,14+attFlag2*30,NULL);
		LineTo(hdcTmp,5,21+attFlag2*30);
		MoveToEx(hdcTmp,6,15+attFlag2*30,NULL);
		LineTo(hdcTmp,6,20+attFlag2*30);
		MoveToEx(hdcTmp,7,16+attFlag2*30,NULL);
		LineTo(hdcTmp,7,19+attFlag2*30);
		MoveToEx(hdcTmp,8,17+attFlag2*30,NULL);
		LineTo(hdcTmp,8,18+attFlag2*30);
		MoveToEx(hdcTmp,40,10,NULL);
		LineTo(hdcTmp,40,86);

		char tmp[20];
		if(attFlag == 0 && attFlag2 == 1)
		{
			ShowText(menu_degree,45,5);
			sprintf_s(tmp,"%d",fighthero[t_selectedFightHero].degree);
			ShowText(tmp,100,5);
			ShowText(menu_hp,45,23);
			sprintf_s(tmp,"%d/%d",fighthero[t_selectedFightHero].hp,fighthero[t_selectedFightHero].hpMax);
			ShowText(tmp,100,23);
			ShowText(menu_mp,45,41);
			sprintf_s(tmp,"%d/%d",fighthero[t_selectedFightHero].mp,fighthero[t_selectedFightHero].mpMax);
			ShowText(tmp,100,41);
			ShowText(menu_at,45,59);
			sprintf_s(tmp,"%d",fighthero[t_selectedFightHero].att);
			ShowText(tmp,100,59);
			ShowText(menu_df,45,77);
			sprintf_s(tmp,"%d",fighthero[t_selectedFightHero].def);
			ShowText(tmp,100,77);
		}
		else if(attFlag == 1 && attFlag2 == 1)
		{
			ShowText(menu_exp,45,5);
			sprintf_s(tmp,"%d",fighthero[t_selectedFightHero].exp);
			ShowText("/",100+strlen(tmp)*5,5);
			ShowText(tmp,100,5,10);
			sprintf_s(tmp,"%d",fighthero[t_selectedFightHero].expMax);
			ShowText(tmp,108+strlen(tmp)*5,9,10);
			ShowText(menu_speed,45,23);
			sprintf_s(tmp,"%d",fighthero[t_selectedFightHero].speed);
			ShowText(tmp,100,23);
			ShowText(menu_anima,45,41);
			sprintf_s(tmp,"%d",fighthero[t_selectedFightHero].anima);
			ShowText(tmp,100,41);
			ShowText(menu_luck,45,59);
			sprintf_s(tmp,"%d",fighthero[t_selectedFightHero].lucky);
			ShowText(tmp,100,59);
			ShowText(menu_anti,45,77);
			if(fighthero[t_selectedFightHero].anti == 0)
			{
				ShowText("无",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 8)
			{
				ShowText("毒",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 4)
			{
				ShowText("乱",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 2)
			{
				ShowText("封",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 1)
			{
				ShowText("眠",100,77);

			}
			else if(fighthero[t_selectedFightHero].anti == 12)
			{
				ShowText("毒乱",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 10)
			{
				ShowText("毒封",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 9)
			{
				ShowText("毒眠",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 6)
			{
				ShowText("乱封",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 5)
			{
				ShowText("乱眠",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 3)
			{
				ShowText("封眠",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 6)
			{
				ShowText("乱封",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 14)
			{
				ShowText("毒乱封",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 13)
			{
				ShowText("毒乱眠",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 11)
			{
				ShowText("毒封眠",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 7)
			{
				ShowText("乱封眠",100,77);
			}
			else if(fighthero[t_selectedFightHero].anti == 15)
			{
				ShowText("毒乱封眠",100,77);
			}
		}
		else if(attFlag == 0 && attFlag2 == 0)
		{
			ShowText(menu_degree,45,5);
			sprintf_s(tmp,"%d",fighthero[t_selectedFightHero].degree);
			ShowText(tmp,100,5);
			ShowText(menu_hp,45,23);
			int itmp,itmp1;
			itmp = fighthero[t_selectedFightHero].hp + goodList.good[equipType-1][equipIdx-1].hp - goodList.good[equipType1-1][equipIdx1-1].hp;
			itmp1 = fighthero[t_selectedFightHero].hpMax + goodList.good[equipType-1][equipIdx-1].hpmax - goodList.good[equipType1-1][equipIdx1-1].hpmax;
			sprintf_s(tmp,"%d/%d",itmp,itmp1);
			ShowText(tmp,100,23);
			ShowText(menu_mp,45,41);
			itmp = fighthero[t_selectedFightHero].mp + goodList.good[equipType-1][equipIdx-1].mp - goodList.good[equipType1-1][equipIdx1-1].mp;
			itmp1 = fighthero[t_selectedFightHero].mpMax + goodList.good[equipType-1][equipIdx-1].mpmax - goodList.good[equipType1-1][equipIdx1-1].mpmax;
			sprintf_s(tmp,"%d/%d",itmp,itmp1);
			ShowText(tmp,100,41);
			ShowText(menu_at,45,59);
			itmp = fighthero[t_selectedFightHero].att + goodList.good[equipType-1][equipIdx-1].at - goodList.good[equipType1-1][equipIdx1-1].at;
			sprintf_s(tmp,"%d",itmp);
			ShowText(tmp,100,59);
			ShowText(menu_df,45,77);
			itmp = fighthero[t_selectedFightHero].def + goodList.good[equipType-1][equipIdx-1].df - goodList.good[equipType1-1][equipIdx1-1].df;
			sprintf_s(tmp,"%d",itmp);
			ShowText(tmp,100,77);
		}
		else if(attFlag == 1 && attFlag2 == 0)
		{
			ShowText(menu_exp,45,5);
			sprintf_s(tmp,"%d",fighthero[t_selectedFightHero].exp);
			ShowText("/",100+strlen(tmp)*5,5);
			ShowText(tmp,100,5,10);
			sprintf_s(tmp,"%d",fighthero[t_selectedFightHero].expMax);
			ShowText(tmp,108+strlen(tmp)*5,9,10);
			int itmp;
			itmp = fighthero[t_selectedFightHero].speed + goodList.good[equipType-1][equipIdx-1].speed - goodList.good[equipType1-1][equipIdx1-1].speed;
			ShowText(menu_speed,45,23);
			sprintf_s(tmp,"%d",itmp);
			ShowText(tmp,100,23);
			ShowText(menu_anima,45,41);
			itmp = fighthero[t_selectedFightHero].anima + goodList.good[equipType-1][equipIdx-1].anima - goodList.good[equipType1-1][equipIdx1-1].anima;
			sprintf_s(tmp,"%d",itmp);
			ShowText(tmp,100,41);
			ShowText(menu_luck,45,59);
			itmp = fighthero[t_selectedFightHero].lucky + goodList.good[equipType-1][equipIdx-1].lucky - goodList.good[equipType1-1][equipIdx1-1].lucky;
			sprintf_s(tmp,"%d",itmp);
			ShowText(tmp,100,59);
			ShowText(menu_anti,45,77);
			//itmp = fighthero[t_selectedFightHero].anti + goodList.good[equipType-1][equipIdx-1].all_dlfm_Flag - goodList.good[equipType1-1][equipIdx1-1].all_dlfm_Flag;
			int tmp1 = 0;
			//CheckAntiCauseBy检测角色anti是否由该物品引起，0-不是 1-是  1-4毒乱封眠

			//usedecorateflag
			if(fighthero[t_selectedFightHero].anti/ 8 > 0 && CheckAntiCauseBy(1,equipType1-1,equipIdx1-1,flagDecorate)== 1)
			{
				tmp1 += 8;
			}
			if(fighthero[t_selectedFightHero].anti%8/4 > 0 &&CheckAntiCauseBy(2,equipType1-1,equipIdx1-1,flagDecorate)== 1)
			{
				tmp1 += 4;
			}
			if(fighthero[t_selectedFightHero].anti%4/2 > 0 &&CheckAntiCauseBy(3,equipType1-1,equipIdx1-1,flagDecorate)== 1)
			{
				tmp1 += 2;
			}
			if(fighthero[t_selectedFightHero].anti%2 > 0 &&CheckAntiCauseBy(4,equipType1-1,equipIdx1-1,flagDecorate)== 1)
			{
				tmp1 += 1;
			}
			if(equipType < 6)//非饰品、武器20181230
            {
                itmp = fighthero[t_selectedFightHero].anti + goodList.good[equipType-1][equipIdx-1].all_dlfm_Flag - tmp1;
            }
            else
            {
                itmp = fighthero[t_selectedFightHero].anti ;
            }

			if(itmp== 0)
			{
				ShowText("无",100,77);
			}
			else if(itmp == 8)
			{
				ShowText("毒",100,77);
			}
			else if(itmp == 4)
			{
				ShowText("乱",100,77);
			}
			else if(itmp == 2)
			{
				ShowText("封",100,77);
			}
			else if(itmp == 1)
			{
				ShowText("眠",100,77);

			}
			else if(itmp == 12)
			{
				ShowText("毒乱",100,77);
			}
			else if(itmp == 10)
			{
				ShowText("毒封",100,77);
			}
			else if(itmp == 9)
			{
				ShowText("毒眠",100,77);
			}
			else if(itmp == 6)
			{
				ShowText("乱封",100,77);
			}
			else if(itmp == 5)
			{
				ShowText("乱眠",100,77);
			}
			else if(itmp == 3)
			{
				ShowText("封眠",100,77);
			}
			else if(itmp == 6)
			{
				ShowText("乱封",100,77);
			}
			else if(itmp == 14)
			{
				ShowText("毒乱封",100,77);
			}
			else if(itmp == 13)
			{
				ShowText("毒乱眠",100,77);
			}
			else if(itmp == 11)
			{
				ShowText("毒封眠",100,77);
			}
			else if(itmp == 7)
			{
				ShowText("乱封眠",100,77);
			}
			else if(itmp == 15)
			{
				ShowText("毒乱封眠",100,77);
			}
		}
		return;
	}
	else if(flagGood == 1)//使用装备
	{
		if(KeyCode == -100)return;
		char tmp[20];
		ClrScence();
		MoveToEx(hdcTmp,140,21,NULL);
		LineTo(hdcTmp,42,21);
		MoveToEx(hdcTmp,140,0,NULL);
		LineTo(hdcTmp,55,0);
		MoveToEx(hdcTmp,140,20,NULL);
		LineTo(hdcTmp,59,20);

		LineTo(hdcTmp,39,0);
		LineTo(hdcTmp,6,0);
		LineTo(hdcTmp,0,6);
		LineTo(hdcTmp,0,95);
		LineTo(hdcTmp,41,95);
		LineTo(hdcTmp,41,22);
		MoveToEx(hdcTmp,42,95,NULL);
		LineTo(hdcTmp,42,22);
		Rectangle(hdcTmp,43,22,158,58);
		Rectangle(hdcTmp,43,59,158,96);

		MoveToEx(hdcTmp,140,57,NULL);
		LineTo(hdcTmp,42,58);

		ShowText(menu_num,60,3);



		int goodCount = goodAll;


		int equipType = equipList.equipInList[attFlag][0];
		int equipIdx = equipList.equipInList[attFlag][1];
		int equipSum = equipList.equipInList[attFlag][2];


		sprintf_s(tmp,"%d",equipSum);
		ShowText(tmp,100,3);
		ShowText(menu_name,47,24);
		ShowText(goodList.good[equipType-1][equipIdx-1].name,71,24);
		ShowText(menu_price,47,41);
		sprintf_s(tmp,"%d",goodList.good[equipType-1][equipIdx-1].sell);
		ShowText(tmp,71,41);

		int max = equipAll>4?3:equipAll - 1;

		if(flagd==1&&KeyCode==KeyDown0)
		{
			showPos=max;

		}
		else if(flagu==1&&KeyCode==KeyUp0)
		{
			showPos=0;

		}
		else if(flagd==1&&KeyCode==KeyUp0)
		{
			flagd=0;
			showPos--;
		}
		else if(flagu==1&&KeyCode==KeyDown0)
		{
			flagu=0;
			showPos++;
		}
		else if(KeyCode==KeyUp0)
		{
			showPos--;
		}
		else if(KeyCode==KeyDown0)
		{
			showPos++;
		}
		if(showPos==max)flagd=1;
		if(showPos==0)flagu=1;



		if(showPos == 0)
		{
			ShowGoodPic(0,equipList.equipInList[attFlag][0],equipList.equipInList[attFlag][1],13,24*0);
			ShowGoodPic(0,equipList.equipInList[attFlag+1][0],equipList.equipInList[attFlag+1][1],13,24*1);
			ShowGoodPic(0,equipList.equipInList[attFlag+2][0],equipList.equipInList[attFlag+2][1],13,24*2);
			ShowGoodPic(0,equipList.equipInList[attFlag+3][0],equipList.equipInList[attFlag+3][1],13,24*3);
		}
		else if(showPos == 1)
		{
			ShowGoodPic(0,equipList.equipInList[attFlag-1][0],equipList.equipInList[attFlag-1][1],13,24*0);
			ShowGoodPic(0,equipList.equipInList[attFlag+0][0],equipList.equipInList[attFlag+0][1],13,24*1);
			ShowGoodPic(0,equipList.equipInList[attFlag+1][0],equipList.equipInList[attFlag+1][1],13,24*2);
			ShowGoodPic(0,equipList.equipInList[attFlag+2][0],equipList.equipInList[attFlag+2][1],13,24*3);
		}
		else if(showPos == 2)
		{
			ShowGoodPic(0,equipList.equipInList[attFlag-2][0],equipList.equipInList[attFlag-2][1],13,24*0);
			ShowGoodPic(0,equipList.equipInList[attFlag-1][0],equipList.equipInList[attFlag-1][1],13,24*1);
			ShowGoodPic(0,equipList.equipInList[attFlag+0][0],equipList.equipInList[attFlag+0][1],13,24*2);
			ShowGoodPic(0,equipList.equipInList[attFlag+1][0],equipList.equipInList[attFlag+1][1],13,24*3);
		}
		else if(showPos == 3)
		{
			ShowGoodPic(0,equipList.equipInList[attFlag-3][0],equipList.equipInList[attFlag-3][1],13,24*0);
			ShowGoodPic(0,equipList.equipInList[attFlag-2][0],equipList.equipInList[attFlag-2][1],13,24*1);
			ShowGoodPic(0,equipList.equipInList[attFlag-1][0],equipList.equipInList[attFlag-1][1],13,24*2);
			ShowGoodPic(0,equipList.equipInList[attFlag+0][0],equipList.equipInList[attFlag+0][1],13,24*3);
		}



		MoveToEx(hdcTmp,4,10+showPos*24,NULL);
		LineTo(hdcTmp,4,25+showPos*24);
		MoveToEx(hdcTmp,5,11+showPos*24,NULL);
		LineTo(hdcTmp,5,24+showPos*24);
		MoveToEx(hdcTmp,6,12+showPos*24,NULL);
		LineTo(hdcTmp,6,23+showPos*24);
		MoveToEx(hdcTmp,7,13+showPos*24,NULL);
		LineTo(hdcTmp,7,22+showPos*24);
		MoveToEx(hdcTmp,8,14+showPos*24,NULL);
		LineTo(hdcTmp,8,21+showPos*24);
		MoveToEx(hdcTmp,9,15+showPos*24,NULL);
		LineTo(hdcTmp,9,20+showPos*24);
		MoveToEx(hdcTmp,10,16+showPos*24,NULL);
		LineTo(hdcTmp,10,19+showPos*24);
		MoveToEx(hdcTmp,11,17+showPos*24,NULL);
		LineTo(hdcTmp,11,18+showPos*24);


		char showedText[15][15];
		char text[102];
		int textLen = 0;
		int linestart = 0;
		int lineCount = 0;

		for(int u = 0; u < 102;u++)
		{
			text[u] = ' ';
		}
		for(int u = 0; u < 102;u++)
		{
			if(goodList.good[equipType-1][equipIdx-1].description[u]=='\0')
			{
				textLen = u;
				break;
			}
			text[u] = goodList.good[equipType-1][equipIdx-1].description[u];
		}

		int v = 0;
		for(v = 0;v<15;v++)
		{

			int p=0;
			for(int k = 0 ;k<14;k++)//20160625
			{
				if((int)text[linestart+k] < 128 && (int)text[linestart+k] >= 0)//单字节字符
				{
					p++;
				}
			}
			if(p%2==0)//双字节
			{
				memcpy(showedText[v],&text[linestart],14);
				showedText[v][14]='\0';
				showedText[v+1][0]='\0';
				linestart+=14;
			}
			else
			{
				memcpy(showedText[v],&text[linestart],13);
				showedText[v][13]='\0';
				showedText[v+1][0]='\0';
				linestart+=13;
			}
			if(linestart>=textLen)
			{
				lineCount = v + 1;
				break;
			}


		}
		if(attFlag2 >= (lineCount -1) )
		{
			attFlag2 = lineCount - 2;
		}
		if(attFlag2 <0 )
		{
			attFlag2 = 0;
		}
		ShowText(showedText[attFlag2],47,61);
		ShowText(showedText[attFlag2+1],47,78);

		return;
	}
	else if(flagGood == 2)//投掷
	{
		if(KeyCode == -100)return;
		char tmp[20];
		ClrScence();
		MoveToEx(hdcTmp,140,21,NULL);
		LineTo(hdcTmp,42,21);
		MoveToEx(hdcTmp,140,0,NULL);
		LineTo(hdcTmp,55,0);
		MoveToEx(hdcTmp,140,20,NULL);
		LineTo(hdcTmp,59,20);

		LineTo(hdcTmp,39,0);
		LineTo(hdcTmp,6,0);
		LineTo(hdcTmp,0,6);
		LineTo(hdcTmp,0,95);
		LineTo(hdcTmp,41,95);
		LineTo(hdcTmp,41,22);
		MoveToEx(hdcTmp,42,95,NULL);
		LineTo(hdcTmp,42,22);
		Rectangle(hdcTmp,43,22,158,58);
		Rectangle(hdcTmp,43,59,158,96);

		MoveToEx(hdcTmp,140,57,NULL);
		LineTo(hdcTmp,42,58);

		ShowText(menu_num,60,3);

		int throwCount = throwAll;


		int throwType = throwList.goodInList[attFlag][0];
		int throwIdx = throwList.goodInList[attFlag][1];
		int throwSum = throwList.goodInList[attFlag][2];


		sprintf_s(tmp,"%d",throwSum);
		ShowText(tmp,100,3);
		ShowText(menu_name,47,24);
		ShowText(goodList.good[throwType-1][throwIdx-1].name,71,24);
		ShowText(menu_price,47,41);
		sprintf_s(tmp,"%d",goodList.good[throwType-1][throwIdx-1].sell);
		ShowText(tmp,71,41);

		int max = throwAll>4?3:throwAll - 1;

		if(flagd==1&&KeyCode==KeyDown0)
		{
			showPos=max;

		}
		else if(flagu==1&&KeyCode==KeyUp0)
		{
			showPos=0;

		}
		else if(flagd==1&&KeyCode==KeyUp0)
		{
			flagd=0;
			showPos--;
		}
		else if(flagu==1&&KeyCode==KeyDown0)
		{
			flagu=0;
			showPos++;
		}
		else if(KeyCode==KeyUp0)
		{
			showPos--;
		}
		else if(KeyCode==KeyDown0)
		{
			showPos++;
		}
		if(showPos==max)flagd=1;
		if(showPos==0)flagu=1;



		if(showPos == 0)
		{
			if(attFlag < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag][0],throwList.goodInList[attFlag][1],13,24*0);
			if(attFlag+1 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag+1][0],throwList.goodInList[attFlag+1][1],13,24*1);
			if(attFlag+2 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag+2][0],throwList.goodInList[attFlag+2][1],13,24*2);
			if(attFlag+3 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag+3][0],throwList.goodInList[attFlag+3][1],13,24*3);
		}
		else if(showPos == 1)
		{
			if(attFlag-1 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag-1][0],throwList.goodInList[attFlag-1][1],13,24*0);
			if(attFlag+0 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag+0][0],throwList.goodInList[attFlag+0][1],13,24*1);
			if(attFlag+1 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag+1][0],throwList.goodInList[attFlag+1][1],13,24*2);
			if(attFlag+2 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag+2][0],throwList.goodInList[attFlag+2][1],13,24*3);
		}
		else if(showPos == 2)
		{
			if(attFlag-2 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag-2][0],throwList.goodInList[attFlag-2][1],13,24*0);
			if(attFlag-1 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag-1][0],throwList.goodInList[attFlag-1][1],13,24*1);
			if(attFlag+0 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag+0][0],throwList.goodInList[attFlag+0][1],13,24*2);
			if(attFlag+1 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag+1][0],throwList.goodInList[attFlag+1][1],13,24*3);
		}
		else if(showPos == 3)
		{
			if(attFlag-3 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag-3][0],throwList.goodInList[attFlag-3][1],13,24*0);
			if(attFlag-2 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag-2][0],throwList.goodInList[attFlag-2][1],13,24*1);
			if(attFlag-1 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag-1][0],throwList.goodInList[attFlag-1][1],13,24*2);
			if(attFlag+0 < throwCount)ShowGoodPic(0,throwList.goodInList[attFlag+0][0],throwList.goodInList[attFlag+0][1],13,24*3);
		}



		MoveToEx(hdcTmp,4,10+showPos*24,NULL);
		LineTo(hdcTmp,4,25+showPos*24);
		MoveToEx(hdcTmp,5,11+showPos*24,NULL);
		LineTo(hdcTmp,5,24+showPos*24);
		MoveToEx(hdcTmp,6,12+showPos*24,NULL);
		LineTo(hdcTmp,6,23+showPos*24);
		MoveToEx(hdcTmp,7,13+showPos*24,NULL);
		LineTo(hdcTmp,7,22+showPos*24);
		MoveToEx(hdcTmp,8,14+showPos*24,NULL);
		LineTo(hdcTmp,8,21+showPos*24);
		MoveToEx(hdcTmp,9,15+showPos*24,NULL);
		LineTo(hdcTmp,9,20+showPos*24);
		MoveToEx(hdcTmp,10,16+showPos*24,NULL);
		LineTo(hdcTmp,10,19+showPos*24);
		MoveToEx(hdcTmp,11,17+showPos*24,NULL);
		LineTo(hdcTmp,11,18+showPos*24);


		char showedText[15][15];
		char text[102];
		int textLen = 0;
		int linestart = 0;
		int lineCount = 0;

		for(int u = 0; u < 102;u++)
		{
			text[u] = ' ';
		}
		for(int u = 0; u < 102;u++)
		{
			if(throwList.good[throwType-1][throwIdx-1].description[u]=='\0')
			{
				textLen = u;
				break;
			}
			text[u] = throwList.good[throwType-1][throwIdx-1].description[u];
		}

		int v = 0;
		for(v = 0;v<15;v++)
		{

			int p=0;
			for(int k = 0 ;k<14;k++)//20160625
			{
				if((int)text[linestart+k] < 128 && (int)text[linestart+k] >= 0)//单字节字符
				{
					p++;
				}
			}
			if(p%2==0)//双字节
			{
				memcpy(showedText[v],&text[linestart],14);
				showedText[v][14]='\0';
				showedText[v+1][0]='\0';
				linestart+=14;
			}
			else
			{
				memcpy(showedText[v],&text[linestart],13);
				showedText[v][13]='\0';
				showedText[v+1][0]='\0';
				linestart+=13;
			}
			if(linestart>=textLen)
			{
				lineCount = v + 1;
				break;
			}


		}
		if(attFlag2 >= (lineCount -1) )
		{
			attFlag2 = lineCount - 2;
		}
		if(attFlag2 <0 )
		{
			attFlag2 = 0;
		}
		ShowText(showedText[attFlag2],47,61);
		ShowText(showedText[attFlag2+1],47,78);

		return;
	}
	else if(flagGood == 3)//使用道具
	{
		if(KeyCode == -100)return;
		char tmp[20];
		ClrScence();
		MoveToEx(hdcTmp,140,21,NULL);
		LineTo(hdcTmp,42,21);
		MoveToEx(hdcTmp,140,0,NULL);
		LineTo(hdcTmp,55,0);
		MoveToEx(hdcTmp,140,20,NULL);
		LineTo(hdcTmp,59,20);

		LineTo(hdcTmp,39,0);
		LineTo(hdcTmp,6,0);
		LineTo(hdcTmp,0,6);
		LineTo(hdcTmp,0,95);
		LineTo(hdcTmp,41,95);
		LineTo(hdcTmp,41,22);
		MoveToEx(hdcTmp,42,95,NULL);
		LineTo(hdcTmp,42,22);
		Rectangle(hdcTmp,43,22,158,58);
		Rectangle(hdcTmp,43,59,158,96);

		MoveToEx(hdcTmp,140,57,NULL);
		LineTo(hdcTmp,42,58);

		ShowText(menu_num,60,3);

		int inGood[255];
		int jj = 0 ;
		for(int i = 0 ;i<100;i++)
		{
			inGood[i]=-1;
		}
		for(int i = 0 ;i<goodAll;i++)
		{
			if( goodList.goodInList[i][0]!=13 &&  goodList.goodInList[i][0]!=14)
			{
				inGood[jj++]=i;
			}
		}


		int goodCount = jj;


		int goodType = goodList.goodInList[inGood[attFlag]][0];
		int goodIdx = goodList.goodInList[inGood[attFlag]][1];
		int goodSum = goodList.goodInList[inGood[attFlag]][2];


		sprintf_s(tmp,"%d",goodSum);
		ShowText(tmp,100,3);
		ShowText(menu_name,47,24);
		ShowText(goodList.good[goodType-1][goodIdx-1].name,71,24);
		ShowText(menu_price,47,41);
		sprintf_s(tmp,"%d",goodList.good[goodType-1][goodIdx-1].sell);
		ShowText(tmp,71,41);

		int max = goodCount>4?3:goodCount - 1;

		if(flagd==1&&KeyCode==KeyDown0)
		{
			showPos=max;

		}
		else if(flagu==1&&KeyCode==KeyUp0)
		{
			showPos=0;

		}
		else if(flagd==1&&KeyCode==KeyUp0)
		{
			flagd=0;
			showPos--;
		}
		else if(flagu==1&&KeyCode==KeyDown0)
		{
			flagu=0;
			showPos++;
		}
		else if(KeyCode==KeyUp0)
		{
			showPos--;
		}
		else if(KeyCode==KeyDown0)
		{
			showPos++;
		}
		if(showPos==max)flagd=1;
		if(showPos==0)flagu=1;



		if(showPos == 0)
		{
			if(inGood[attFlag]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag]][0],goodList.goodInList[inGood[attFlag]][1],13,24*0);
			if(inGood[attFlag+1]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag+1]][0],goodList.goodInList[inGood[attFlag+1]][1],13,24*1);
			if(inGood[attFlag+2]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag+2]][0],goodList.goodInList[inGood[attFlag+2]][1],13,24*2);
			if(inGood[attFlag+3]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag+3]][0],goodList.goodInList[inGood[attFlag+3]][1],13,24*3);
		}
		else if(showPos == 1)
		{
			if(inGood[attFlag-1]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag-1]][0],goodList.goodInList[inGood[attFlag-1]][1],13,24*0);
			if(inGood[attFlag+0]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag+0]][0],goodList.goodInList[inGood[attFlag+0]][1],13,24*1);
			if(inGood[attFlag+1]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag+1]][0],goodList.goodInList[inGood[attFlag+1]][1],13,24*2);
			if(inGood[attFlag+2]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag+2]][0],goodList.goodInList[inGood[attFlag+2]][1],13,24*3);
		}
		else if(showPos == 2)
		{
			if(inGood[attFlag-2]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag-2]][0],goodList.goodInList[inGood[attFlag-2]][1],13,24*0);
			if(inGood[attFlag-1]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag-1]][0],goodList.goodInList[inGood[attFlag-1]][1],13,24*1);
			if(inGood[attFlag+0]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag+0]][0],goodList.goodInList[inGood[attFlag+0]][1],13,24*2);
			if(inGood[attFlag+1]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag+1]][0],goodList.goodInList[inGood[attFlag+1]][1],13,24*3);
		}
		else if(showPos == 3)
		{
			if(inGood[attFlag-3]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag-3]][0],goodList.goodInList[inGood[attFlag-3]][1],13,24*0);
			if(inGood[attFlag-2]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag-2]][0],goodList.goodInList[inGood[attFlag-2]][1],13,24*1);
			if(inGood[attFlag-1]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag-1]][0],goodList.goodInList[inGood[attFlag-1]][1],13,24*2);
			if(inGood[attFlag-0]>=0)ShowGoodPic(0,goodList.goodInList[inGood[attFlag-0]][0],goodList.goodInList[inGood[attFlag-0]][1],13,24*3);
		}



		MoveToEx(hdcTmp,4,10+showPos*24,NULL);
		LineTo(hdcTmp,4,25+showPos*24);
		MoveToEx(hdcTmp,5,11+showPos*24,NULL);
		LineTo(hdcTmp,5,24+showPos*24);
		MoveToEx(hdcTmp,6,12+showPos*24,NULL);
		LineTo(hdcTmp,6,23+showPos*24);
		MoveToEx(hdcTmp,7,13+showPos*24,NULL);
		LineTo(hdcTmp,7,22+showPos*24);
		MoveToEx(hdcTmp,8,14+showPos*24,NULL);
		LineTo(hdcTmp,8,21+showPos*24);
		MoveToEx(hdcTmp,9,15+showPos*24,NULL);
		LineTo(hdcTmp,9,20+showPos*24);
		MoveToEx(hdcTmp,10,16+showPos*24,NULL);
		LineTo(hdcTmp,10,19+showPos*24);
		MoveToEx(hdcTmp,11,17+showPos*24,NULL);
		LineTo(hdcTmp,11,18+showPos*24);


		char showedText[15][15];
		char text[102];
		int textLen = 0;
		int linestart = 0;
		int lineCount = 0;

		for(int u = 0; u < 102;u++)
		{
			text[u] = ' ';
		}
		for(int u = 0; u < 102;u++)
		{
			if(goodList.good[goodType-1][goodIdx-1].description[u]=='\0')
			{
				textLen = u;
				break;
			}
			text[u] = goodList.good[goodType-1][goodIdx-1].description[u];
		}

		int v = 0;
		for(v = 0;v<15;v++)
		{

			int p=0;
			for(int k = 0 ;k<14;k++)//20160625
			{
				if((int)text[linestart+k] < 128 && (int)text[linestart+k] >= 0)//单字节字符
				{
					p++;
				}
			}
			if(p%2==0)//双字节
			{
				memcpy(showedText[v],&text[linestart],14);
				showedText[v][14]='\0';
				showedText[v+1][0]='\0';
				linestart+=14;
			}
			else
			{
				memcpy(showedText[v],&text[linestart],13);
				showedText[v][13]='\0';
				showedText[v+1][0]='\0';
				linestart+=13;
			}
			if(linestart>=textLen)
			{
				lineCount = v + 1;
				break;
			}


		}
		if(attFlag2 >= (lineCount -1) )
		{
			attFlag2 = lineCount - 2;
		}
		if(attFlag2 <0 )
		{
			attFlag2 = 0;
		}
		ShowText(showedText[attFlag2],47,61);
		ShowText(showedText[attFlag2+1],47,78);

		return;
	}

	//20160627增加对selectfighthero处理
	if(flagDied[selectedFightHero])
	{
		selectedFightHero++;
		selectedHeroFinished++;
	}


	if(fightType == 1)
	{
		ShowFightScene(e_scrb,e_scrl,e_scrr);
	}
	else
	{
		ShowFightScene(scrb,scrl,scrr);
	}

	//显示战斗图片
	if(KeyCode!=300&&KeyCode!=301&&KeyCode!=302)
	{
		for(int i = 0 ;i<actorSum ;i++)
		{

			if(KeyCode !=(100+i)&&KeyCode !=(200+i))
			{
				if(flagDef[i])
				{
					ShowFightActorPic(i,8);
				}
				else if(isResisted == 1)
				{
					ShowFightActorPic(i,8);
				}
				else if(flagDied[i])
				{
					ShowFightActorPic(i,11);
				}
				else if(fighthero[i].hp>0 && fighthero[i].hpMax/fighthero[i].hp > 4)
				{
					ShowFightActorPic(i,10);
				}
				else
				{
					ShowFightActorPic(i);
				}
			}
		}
	}
	else
	{
		int i = KeyCode-300;
		if(flagDef[i])
		{
			ShowFightActorPic(i,8);
		}
		else if(isResisted == 1)
		{
			ShowFightActorPic(i,8);
		}
		else if(flagDied[i])
		{
			ShowFightActorPic(i,11);
		}
		else if(fighthero[i].hp>0 && fighthero[i].hpMax/fighthero[i].hp > 4)
		{
			ShowFightActorPic(i,10);
		}
		else
		{
			ShowFightActorPic(i);
		}
	}
	for(int i = 0 ;i<3;i++)//enemySum 
	{
		if(fightEnemy[i].picno == 0)continue;
		if(KeyCode !=(100+3+i))
		{
			if(flagEnemyDied[i])
			{
				continue;
			}
			ShowFightEnemyPic(i);
		}
	}
	//显示角色
	if(KeyCode<100||(KeyCode >=110 && KeyCode<200)||(KeyCode>210 && KeyCode<300)||KeyCode>310)
	{
		ShowFightChoice(attFlag);//轮盘
		if(selectedFightHero >=3)selectedFightHero = 0;//20170119
		if(fighthero[selectedFightHero].no == 0)selectedFightHero = 0;//20170119
		ShowHeadPic(0,fighthero[selectedFightHero].no,50,63);

		ShowNumInPic(79,72,fighthero[selectedFightHero].hp,0);
		//sprintf_s(tmp,"%d",fighthero[selectedFightHero].hp);
		//ShowText(tmp,79,72,8);
		ShowNumInPic(104,72,fighthero[selectedFightHero].hpMax,0);
		//sprintf_s(tmp,"%d",fighthero[selectedFightHero].hpMax);
		//ShowText(tmp,104,72,8);

		ShowNumInPic(79,83,fighthero[selectedFightHero].mp,0);
		//sprintf_s(tmp,"%d",fighthero[selectedFightHero].mp);
		//ShowText(tmp,79,83,8);
		ShowNumInPic(104,83,fighthero[selectedFightHero].mpMax,0);
		//sprintf_s(tmp,"%d",fighthero[selectedFightHero].mpMax);
		//ShowText(tmp,104,83,8);
		//CopyToHdc();
		//InvalidateRect(hwnd,NULL,FALSE);
	}

	//显示箭头
	//默认为只有选择玩家
	//selectedFightStyle=1 增加选择敌人
	if(KeyCode == -100)//定时事件
	{
		if(tmpselectedEnemy == -1)tmpselectedEnemy = 0;//20170102 修正-1显示位置
		if(showArrow ==0)
		{

			ShowPicAdd(0,RES_PIC,2,4,70+selectedFightHero*35,45 - 5 *selectedFightHero,0);
			if(selectedFightStyle == 2)
			{
				if(magicList[selectedFightHero].magic[selectedMagic[selectedFightHero]].type !=1 && magicList[selectedFightHero].magic[selectedMagic[selectedFightHero]].type !=5)
				{
					ShowPicAdd(0,RES_PIC,2,4,70+tmpselectedEnemy*35,45 - 5 *tmpselectedEnemy,2);
				}
				else
				{
					ShowPicAdd(0,RES_PIC,2,3,20+tmpselectedEnemy*35,10 - 5 *tmpselectedEnemy,0);
				}
			}
			if(selectedFightStyle&&selectedFightStyle != 6 && selectedFightStyle != 2)ShowPicAdd(0,RES_PIC,2,3,20+tmpselectedEnemy*35,10 - 5 *tmpselectedEnemy,0);
			if(selectedFightStyle == 6)ShowPicAdd(0,RES_PIC,2,4,70+tmpselectedEnemy*35,45 - 5 *tmpselectedEnemy,2);
			showArrow=1;

		}
		else if(showArrow ==1)
		{
			ShowPicAdd(0,RES_PIC,2,4,70+selectedFightHero*35,45 - 5 *selectedFightHero,1);
			if(selectedFightStyle == 2 )//20170119
			{
				if(magicList[selectedFightHero].magic[selectedMagic[selectedFightHero]].type ==1 || magicList[selectedFightHero].magic[selectedMagic[selectedFightHero]].type ==5)
				{
					ShowPicAdd(0,RES_PIC,2,3,20+tmpselectedEnemy*35,10 - 5 *tmpselectedEnemy,1);
				}
			}
			else if(selectedFightStyle&&selectedFightStyle != 6)
			{
				ShowPicAdd(0,RES_PIC,2,3,20+tmpselectedEnemy*35,10 - 5 *tmpselectedEnemy,1);
			}
			if(selectedFightStyle == 6)ShowPicAdd(0,RES_PIC,2,4,70+tmpselectedEnemy*35,45 - 5 *tmpselectedEnemy,3);
			showArrow=0;
		}
	}

	if(flagShowState > 0)
	{
		int tHero = flagShowState-1;
		ShowPic(0,RES_PIC,2,11,20,12);
		ShowHeadPic(0,fighthero[tHero].no,27,16);

		//char tmp[30];
		//sprintf_s(tmp,"%d",fighthero[selectedFightHero].hp);
		//ShowText(tmp,70,21,10);
		ShowNumInPic(70,21,fighthero[tHero].hp,0,10);
		//sprintf_s(tmp,"%d",fighthero[selectedFightHero].lucky);
		//ShowText(tmp,107,21,10);
		ShowNumInPic(107,21,fighthero[tHero].lucky,0,10);
		//sprintf_s(tmp,"%d",fighthero[selectedFightHero].att);
		//ShowText(tmp,70,33,10);
		ShowNumInPic(70,33,fighthero[tHero].att,0,10);
		//sprintf_s(tmp,"%d",fighthero[selectedFightHero].speed);
		//ShowText(tmp,107,33,10);
		ShowNumInPic(107,33,fighthero[tHero].speed,0,10);

		//20160702显示状态
		if(fighthero[tHero].ateffect>0)
		{
			ShowStatusInPic(28,60,0);
		}
		else if(fighthero[tHero].ateffect<0)
		{
			ShowStatusInPic(28,60,1);
		}
		else if(fighthero[tHero].ateffect==0)
		{
			ShowStatusInPic(28,60,4);
		}

		if(fighthero[tHero].dfeffect>0)
		{
			ShowStatusInPic(44,60,0);
		}
		else if(fighthero[tHero].dfeffect<0)
		{
			ShowStatusInPic(44,60,1);
		}
		else if(fighthero[tHero].dfeffect==0)
		{
			ShowStatusInPic(44,60,4);
		}

		if(fighthero[tHero].speedeffect>0)
		{
			ShowStatusInPic(60,60,0);
		}
		else if(fighthero[tHero].speedeffect<0)
		{
			ShowStatusInPic(60,60,1);
		}
		else if(fighthero[tHero].speedeffect==0)
		{
			ShowStatusInPic(60,60,4);
		}

		if(fighthero[tHero].du>0)
		{
			ShowStatusInPic(76,60,3);
		}
		else
		{
			ShowStatusInPic(76,60,2);
		}

		if(fighthero[tHero].ruan>0)
		{
			ShowStatusInPic(92,60,3);
		}
		else
		{
			ShowStatusInPic(92,60,2);
		}

		if(fighthero[tHero].feng>0)
		{
			ShowStatusInPic(108,60,3);
		}
		else
		{
			ShowStatusInPic(108,60,2);
		}

		if(fighthero[tHero].mian>0)
		{
			ShowStatusInPic(124,60,3);
		}
		else
		{
			ShowStatusInPic(124,60,2);
		}


		/*sprintf_s(tmp,"%s","回");
		ShowText(tmp,27,60,10);
		sprintf_s(tmp,"%s","回");
		ShowText(tmp,43,60,10);
		sprintf_s(tmp,"%s","回");
		ShowText(tmp,59,60,10);
		sprintf_s(tmp,"%s","×");
		ShowText(tmp,75,60,10);
		sprintf_s(tmp,"%s","×");
		ShowText(tmp,91,60,10);
		sprintf_s(tmp,"%s","×");
		ShowText(tmp,107,60,10);
		sprintf_s(tmp,"%s","×");
		ShowText(tmp,123,60,10);*/



		//sprintf_s(tmp,"%d",0);
		//ShowText(tmp,27,70,10);
		ShowNumInPic(30,70,abs(fighthero[tHero].ateffect/100),0,10);
		//sprintf_s(tmp,"%d",0);
		//ShowText(tmp,43,70,10);
		ShowNumInPic(46,70,abs(fighthero[tHero].dfeffect/100),0,10);
		//sprintf_s(tmp,"%d",0);
		//ShowText(tmp,59,70,10);
		ShowNumInPic(62,70,abs(fighthero[tHero].speedeffect/100),0,10);
		//sprintf_s(tmp,"%d",0);
		//ShowText(tmp,75,70,10);
		ShowNumInPic(78,70,fighthero[tHero].du,0,10);
		//sprintf_s(tmp,"%d",0);
		//ShowText(tmp,91,70,10);
		ShowNumInPic(94,70,fighthero[tHero].ruan,0,10);
		//sprintf_s(tmp,"%d",0);
		//ShowText(tmp,107,70,10);
		ShowNumInPic(110,70,fighthero[tHero].feng,0,10);
		//sprintf_s(tmp,"%d",0);
		//ShowText(tmp,123,70,10);
		ShowNumInPic(126,70,fighthero[tHero].mian,0,10);


	}
	else if(flagSkill == 1)
	{
		//keytmp = 0;//用于上下选项区分显示位置
		char tmp[20];
		ClrScence();

		//战斗类数据无法访问上层，需重建degreelist magiclist fighthero

		//当前玩家的魔法链长度
		int magicMax = fighthero[selectedFightHero].magicLearn;
		if(attFlag >= magicMax)
		{
			attFlag = magicMax - 1;
		}
		if(attFlag < 0)
		{
			attFlag = 0;
		}

		Rectangle(hdcTmp,8,4,150,40);
		Rectangle(hdcTmp,8,42,150,78);

		if(keytmp == 0||magicMax == 1)
		{
			keytmp = 0;
			ShowText(magicList[selectedFightHero].magic[attFlag].name,12,6);
			if((attFlag+1) < magicMax )ShowText(magicList[selectedFightHero].magic[attFlag+1].name,12,22);
		}
		else
		{
			if(attFlag > 0 )ShowText(magicList[selectedFightHero].magic[attFlag-1].name,12,6);
			ShowText(magicList[selectedFightHero].magic[attFlag].name,12,22);
		}

		char showedText[14][17];
		char text[102];
		int textLen = 0;
		int linestart = 0;
		int lineCount = 0;

		for(int i = 0; i < 102;i++)
		{
			text[i] = ' ';
		}
		for(int i = 0; i < 102;i++)
		{
			if(magicList[selectedFightHero].magic[attFlag].description[i]=='\0')
			{
				textLen = i;
				break;
			}
			text[i] = magicList[selectedFightHero].magic[attFlag].description[i];
		}

		int j = 0;
		for(j = 0;j<14;j++)
		{
			int p=0;
			for(int k = 0 ;k<16;k++)//20160625
			{
				if((int)text[linestart+k] < 128 && (int)text[linestart+k] >= 0)//单字节字符
				{
					p++;
				}
			}
			if(p%2==0)//双字节
			{
				memcpy(showedText[j],&text[linestart],16);
				showedText[j][16]='\0';
				showedText[j+1][0]='\0';
				linestart+=16;
			}
			else
			{
				memcpy(showedText[j],&text[linestart],15);
				showedText[j][15]='\0';
				showedText[j+1][0]='\0';
				linestart+=15;
			}
			if(linestart>=textLen)
			{
				lineCount = j + 1;
				break;
			}


		}
		if(attFlag2 >= (lineCount -1) )
		{
			attFlag2 = lineCount - 2;
		}
		if(attFlag2 <0 )
		{
			attFlag2 = 0;
		}
		ShowText(showedText[attFlag2],12,44);
		ShowText(showedText[attFlag2+1],12,61);
		ShowText("耗真气:",8,79);
		sprintf_s(tmp,"%d",magicList[selectedFightHero].magic[attFlag].cost);
		ShowText(tmp,64,79);
		Ellipse(hdcTmp,133,7,138,15);
		Ellipse(hdcTmp,133,15,138,23);
		Ellipse(hdcTmp,133,23,138,31);
		Ellipse(hdcTmp,133,31,138,39);

		//显示黑色标记
		if(attFlag>0)
		{
			Ellipse(hdcTmp,134,8,137,14);
			Ellipse(hdcTmp,135,9,136,13);
		}
		if((attFlag+1) < magicMax)
		{
			Ellipse(hdcTmp,134,32,137,38);
			Ellipse(hdcTmp,135,33,136,37);
		}

		MoveToEx(hdcTmp,135,10,NULL);
		LineTo(hdcTmp,135,12);
		MoveToEx(hdcTmp,135,18,NULL);
		LineTo(hdcTmp,135,20);
		MoveToEx(hdcTmp,135,26,NULL);
		LineTo(hdcTmp,135,28);
		MoveToEx(hdcTmp,135,34,NULL);
		LineTo(hdcTmp,135,36);

		MoveToEx(hdcTmp,100,20+keytmp*16,NULL);
		LineTo(hdcTmp,106,14+keytmp*16);
		MoveToEx(hdcTmp,102,20+keytmp*16,NULL);
		LineTo(hdcTmp,107,15+keytmp*16);

		Rectangle(hdcTmp,106,11+keytmp*16,108,15+keytmp*16);
		Rectangle(hdcTmp,107,15+keytmp*16,111,17+keytmp*16);
		Rectangle(hdcTmp,108,10+keytmp*16,111,11+keytmp*16);
		Rectangle(hdcTmp,111,11+keytmp*16,112,15+keytmp*16);


		return;
	}
	else if(flagMenuGood == 1)
	{
		menuChoice.Show(0);
		menuGood.Show(0);

	}
	else if(flagMenu == 1)
	{
		menuChoice.Show(0);
	}

}

/***********************************************************************
* 说明:     Fight类按键函数
* 输入参数: WPARAM KeyCode——按键信息，用于确定当前的城市
* 返回值  : 无
* 功能	   : 处理当前类的按键信息
* 修改历史:
*               姓名            日期             说明
*             ------          ----------      -------------
*             wstjb          2012-10-5       完成基本功能
*			   wstjb			2012-10-20		增加功能
***********************************************************************/
int Fight::KeyDown(WPARAM KeyCode)
{
	wlogfile(1, __FUNCTION__ ,"KeyCode=",KeyCode);
	//srand((unsigned)time(0)); 
	if(fightType == 1 && e_evtrnd[0]==currentRound && e_evt[0]!=0)//到达指定回合
	{
		int ta = e_evt[0];
		e_evt[0] = 0;
		return -100-ta;
	}
	if(fightType == 1 && e_evtrnd[1]==currentRound && e_evt[1]!=0)//到达指定回合
	{
		int ta = e_evt[1];
		e_evt[1] = 0;
		return -100-ta;
	}
	if(fightType == 1 && e_evtrnd[2]==currentRound && e_evt[2]!=0)//到达指定回合
	{
		int ta = e_evt[2];
		e_evt[2] = 0;
		return  -100-ta;
	}
	int ret = 0;
	if(flagShowEquipCompare == 1)
	{
		int max = 2;//20161119
		int equipIdx1 = 0;
		int equipType1 = equipList.equipInList[selectedGood][0];
		if(equipType1 == 1)//head
		{
			equipIdx1 = fighthero[t_selectedFightHero].head;
		}
		if(equipType1 == 2)//body
		{
			equipIdx1 = fighthero[t_selectedFightHero].body;
		}
		if(equipType1 == 3)//foot
		{
			equipIdx1 = fighthero[t_selectedFightHero].foot;
		}
		if(equipType1 == 4)//shoulder
		{
			equipIdx1 = fighthero[t_selectedFightHero].shoulder;
		}
		if(equipType1 == 5)//sleeve
		{
			equipIdx1 = fighthero[t_selectedFightHero].sleeve;
		}
		if(equipType1 == 6 )//decorate1 20160228
		{
			if(fighthero[t_selectedFightHero].decorate1!=0&&fighthero[t_selectedFightHero].decorate2!=0)
			{
				equipIdx1 = fighthero[t_selectedFightHero].decorate1;
			}
			else if(fighthero[t_selectedFightHero].decorate1!=0)
			{
				equipIdx1 = fighthero[t_selectedFightHero].decorate2;
			}
			else if(fighthero[t_selectedFightHero].decorate1==0)
			{
				equipIdx1 = fighthero[t_selectedFightHero].decorate1;
			}

		}
		if(equipType1 == 7)//hand
		{
			equipIdx1 = fighthero[t_selectedFightHero].hand;
		}
		if(equipIdx1==0)max = 1;

		if(KeyCode == KeyEsc)
		{
			flagShowEquipCompare = 0 ;
			attFlag = 0;
			Show(0);
		}
		else if(KeyCode == KeyPageUp || KeyCode == KeyPageDown)
		{
			attFlag ++;
			if(attFlag == 2)attFlag = 0;
			Show(0);
		}
		else if(KeyCode == KeyUp0 || KeyCode == KeyDown0)
		{
			attFlag2 ++;
			if(attFlag2 == max)attFlag2 = 0;
			Show(0);
		}
		else if(KeyCode == VK_LEFT || KeyCode == VK_RIGHT)
		{
			attFlag3 ++;
			attFlag2 = 0;

			int i_j = 0;//20161119
			int i_enable[3];


			int t_goodType = equipList.equipInList[selectedGood][0]-1;
			int t_goodIdx = equipList.equipInList[selectedGood][1]-1;

			for(int i_p = 0 ; i_p < 3;i_p++)i_enable[i_p]=-1;

			if(goodList.good[t_goodType][t_goodIdx].owner %2 == 1)//1
			{
				//20170116获取角色编号移到内部
				if(fighthero[0].hp>0&&fighthero[0].no == 1)
				{
					i_enable[i_j]=0;
					i_j++;
				}
				if(fighthero[1].hp>0&&fighthero[1].no == 1)
				{
					i_enable[i_j]=1;
					i_j++;
				}
				if(fighthero[2].hp>0&&fighthero[2].no == 1)
				{
					i_enable[i_j]=2;
					i_j++;
				}
			}
			if(goodList.good[t_goodType][t_goodIdx].owner %4/2 ==1)//2
			{
				//20170116获取角色编号移到内部
				if(fighthero[0].hp>0&&fighthero[0].no == 2)
				{
					i_enable[i_j]=0;
					i_j++;
				}
				if(fighthero[1].hp>0&&fighthero[1].no == 2)
				{
					i_enable[i_j]=1;
					i_j++;
				}
				if(fighthero[2].hp>0&&fighthero[2].no == 2)
				{
					i_enable[i_j]=2;
					i_j++;
				}
			}
			if(goodList.good[t_goodType][t_goodIdx].owner %8/4 == 1)//3
			{
				//20170116获取角色编号移到内部
				if(fighthero[0].hp>0&&fighthero[0].no == 3)
				{
					i_enable[i_j]=0;
					i_j++;
				}
				if(fighthero[1].hp>0&&fighthero[1].no == 3)
				{
					i_enable[i_j]=1;
					i_j++;
				}
				if(fighthero[2].hp>0&&fighthero[2].no == 3)
				{
					i_enable[i_j]=2;
					i_j++;
				}
			}
			if(goodList.good[t_goodType][t_goodIdx].owner %16/8 == 1)//4
			{
				//20170116获取角色编号移到内部
				if(fighthero[0].hp>0&&fighthero[0].no == 4)
				{
					i_enable[i_j]=0;
					i_j++;
				}
				if(fighthero[1].hp>0&&fighthero[1].no == 4)
				{
					i_enable[i_j]=1;
					i_j++;
				}
				if(fighthero[2].hp>0&&fighthero[2].no == 4)
				{
					i_enable[i_j]=2;
					i_j++;
				}
			}

			if(attFlag3 >= i_j) attFlag3 = 0;
			//attFlag3 = i_enable[0];
			if(i_j > 1 && i_enable[attFlag3] >=0)t_selectedFightHero = i_enable[attFlag3];//20161119

			int max = 2;//20161119
			int equipIdx1 = 0;
			int equipType1 = equipList.equipInList[selectedGood][0];
			if(equipType1 == 1)//head
			{
				equipIdx1 = fighthero[t_selectedFightHero].head;
			}
			if(equipType1 == 2)//body
			{
				equipIdx1 = fighthero[t_selectedFightHero].body;
			}
			if(equipType1 == 3)//foot
			{
				equipIdx1 = fighthero[t_selectedFightHero].foot;
			}
			if(equipType1 == 4)//shoulder
			{
				equipIdx1 = fighthero[t_selectedFightHero].shoulder;
			}
			if(equipType1 == 5)//sleeve
			{
				equipIdx1 = fighthero[t_selectedFightHero].sleeve;
			}
			if(equipType1 == 6 )//decorate1 20160228
			{
				if(fighthero[t_selectedFightHero].decorate1!=0&&fighthero[t_selectedFightHero].decorate2!=0)
				{
					equipIdx1 = fighthero[t_selectedFightHero].decorate1;
				}
				else if(fighthero[t_selectedFightHero].decorate1!=0)
				{
					equipIdx1 = fighthero[t_selectedFightHero].decorate2;
				}
				else if(fighthero[t_selectedFightHero].decorate1==0)
				{
					equipIdx1 = fighthero[t_selectedFightHero].decorate1;
				}

			}
			if(equipType1 == 7)//hand
			{
				equipIdx1 = fighthero[t_selectedFightHero].hand;
			}
			if(equipIdx1==0)max = 1;

			Show(0);
		}
		else if(KeyCode == KeyReturn)
		{
			//处理装备使用

			//selectedGood = attFlag2;//存储已经选择的道具
			if(attFlag2 == 0)DelEquipUse();
			attFlag = 0;
			attFlag2 = 0;
			attFlag3 = 0;
			flagShowEquipCompare = 0 ;
			flagGood = 0;
			flagMenuGood = 0;
			flagMenu = 0;
			Show(0);

		}
	}
	else if(selectedFightStyle>0)//1-普通 2-技能 3-合击 4-围攻? 5-投掷  6-补给自己 7-防御 8-逃跑（无）
	{
		if(KeyCode == KeyEsc)//取消选择
		{
			if(selectedFightStyle == 1 ||selectedFightStyle == 3)//回主界面
			{
				GetTmpEnemy(4);
				selectedFightStyle = 0 ;
				//selectedHeroFinished --;20160718修复bug
				//if(selectedHeroFinished < 0 )selectedHeroFinished = 0;20160718修复bug
				Show(0);
			}
			else if(selectedFightStyle == 6 )//回主界面
			{
				GetTmpEnemy(2);
				selectedFightStyle = 0 ;
				//selectedHeroFinished --;20160718修复bug
				//if(selectedHeroFinished < 0 )selectedHeroFinished = 0;20160718修复bug
				Show(0);
			}
			else if(selectedFightStyle == 2 )//回技能界面
			{
				GetTmpEnemy(4);
				selectedFightStyle = 0 ;
				Show(0);
			}
			else if(selectedFightStyle == 5 )//回菜单界面
			{
				GetTmpEnemy(4);
				selectedFightStyle = 0 ;
				Show(0);
			}
		}

		else if(KeyCode == KeyReturn)
		{
			//if(enemySum == 1)selectedHeroFinished ++;


			/*if(selectedHeroFinished %2 == 0)
			{
			selectedHeroFinished ++;
			//selectedFightStyle = 0 ;
			selectedFightHero = tmpselectedHero;
			if(enemySum == 1)
			{
			if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
			if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
			if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
			selectedHeroFinished ++;
			}

			Show(0);

			}
			else if(selectedHeroFinished  %2 != 0)*/
			{
				selectedHeroFinished ++;
				if(selectedFightStyle == 3)//20170102
				{
					selectedHeroFinished ++;
				}
				attFlag = 0;//20160626
				selectedFightEnemy[selectedFightHero] = tmpselectedEnemy;
				selectedFightTypeConfirmed[selectedFightHero] = selectedFightStyle;
				//g_selectedFightStyle[selectedFightHero] = selectedFightStyle;
				//g_selectedEnemyId[selectedFightHero] = tmpselectedEnemy;
				selectedFightStyle = 0 ;
				selectedFightHero++;

				if(actorSum == 1)
				{
					selectedFightHero = 0;
					//selectedHeroFinished ++;
				}
				DealMian();//20160626
				Show(0);

				int livedHero = actorSum;
				if(flagDied[0]||fighthero[0].mian>0)livedHero--;
				if((flagDied[1]&&actorSum>1)||fighthero[1].mian>0)livedHero--;
				if((flagDied[2]&&actorSum>2)||fighthero[2].mian>0)livedHero--;
				if(selectedHeroFinished >= (livedHero))
				{
					//选择完战斗对象 战斗进程 
					int ret = FightRun();
					/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
					{
					return -2;
					}
					else */if(ret>0)
					{
						//有结果
						int ret1 = DealResult(ret);
						if(ret1 == GAMEOVER_FLAG && fightType != 1 )//20170111
						{
							return GAMEOVER_FLAG;
						}
						if(fightType == 1 )
						{
							return -ret-2;
						}
						else
						{
							return -1;
						}

					}
					else if(ret == -1)
					{
						return -2;
					}
					//selectedFightHero = 0;
					//selectedHeroFinished = 0;//20160701
					//selectedFightStyle = 0;

					//ClearSelectedValue();
					//下回合预处理
					/*if(actorSum == 1)
					{
					selectedFightHero = 0;
					selectedHeroFinished ++;
					}*/
					if(livedEnemySum == 1)
					{
						tmpselectedEnemy = livedEnemy[0];//20160706
						if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
						if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
						if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
						//selectedHeroFinished ++;
					}
				}

			}



		}
		else if(KeyCode == KeyRight0)
		{
			/*if(selectedHeroFinished %2 == 0 )
			{
			tmpselectedHero ++;
			if(flagDied[tmpselectedHero])tmpselectedHero ++;
			if(tmpselectedHero >= actorSum)tmpselectedHero=0;
			if(flagDied[tmpselectedHero])tmpselectedHero ++;
			Show(0);
			}
			else if(selectedHeroFinished %2 == 1 )*/
			if(selectedFightStyle == 2 && magicList[selectedFightHero].magic[selectedMagic[selectedFightHero]].type == 4 )
			{
				tmpselectedEnemy ++;
				if(tmpselectedEnemy >= actorSum)tmpselectedEnemy=0;//actor
				Show(0);
			}
			else if(selectedFightStyle == 6 && selectedGood1[selectedFightHero][0] == 10 )
			{
				tmpselectedEnemy ++;
				if(tmpselectedEnemy >= actorSum)tmpselectedEnemy=0;//actor
				Show(0);
			}
			else if(selectedFightStyle == 6 ||(selectedFightStyle == 2 && magicList[selectedFightHero].magic[selectedMagic[selectedFightHero]].type !=1 && magicList[selectedFightHero].magic[selectedMagic[selectedFightHero]].type !=5 ))
			{
				tmpselectedEnemy ++;
				if(flagDied[tmpselectedEnemy])tmpselectedEnemy ++;
				if(tmpselectedEnemy >= actorSum)GetTmpEnemy(2);//actor
				if(flagDied[tmpselectedEnemy])tmpselectedEnemy ++;
				Show(0);
			}
			else
			{
				tmpselectedEnemy ++;
				if(flagEnemyDied[tmpselectedEnemy])tmpselectedEnemy ++;
				if(tmpselectedEnemy >= enemySum)GetTmpEnemy(4);//enemy
				if(flagEnemyDied[tmpselectedEnemy])tmpselectedEnemy ++;
				Show(0);
			}
		}
		else if(KeyCode == KeyLeft0)
		{
			/*if(selectedHeroFinished %2 == 0)
			{
			tmpselectedHero --;
			if(flagDied[tmpselectedHero])tmpselectedHero --;
			if(tmpselectedHero <= -1)tmpselectedHero=actorSum-1;
			if(flagDied[tmpselectedHero])tmpselectedHero --;
			Show(0);
			}
			else if(selectedHeroFinished %2 == 1)*/
			if(selectedFightStyle == 2 && magicList[selectedFightHero].magic[selectedMagic[selectedFightHero]].type == 4 )
			{
				tmpselectedEnemy --; 
				if(tmpselectedEnemy <= -1)tmpselectedEnemy=(actorSum-1);//actor
				Show(0);
			}
			else if(selectedFightStyle == 6 && selectedGood1[selectedFightHero][0] == 10 )
			{
				tmpselectedEnemy --; 
				if(tmpselectedEnemy <= -1)tmpselectedEnemy=(actorSum-1);//actor
				Show(0);
			}
			else if(selectedFightStyle == 6 ||(selectedFightStyle == 2 && magicList[selectedFightHero].magic[selectedMagic[selectedFightHero]].type !=1 && magicList[selectedFightHero].magic[selectedMagic[selectedFightHero]].type !=5 ))
			{
				tmpselectedEnemy --;
				if(flagDied[tmpselectedEnemy])tmpselectedEnemy --;
				if(tmpselectedEnemy <= -1)GetTmpEnemy(3);//actor
				if(flagDied[tmpselectedEnemy])tmpselectedEnemy --;
				Show(0);
			}
			else
			{
				tmpselectedEnemy --;
				if(flagEnemyDied[tmpselectedEnemy])tmpselectedEnemy --;
				if(tmpselectedEnemy <= -1)GetTmpEnemy(1);//enemy
				if(flagEnemyDied[tmpselectedEnemy])tmpselectedEnemy --;
				Show(0);
			}
		}

	}
	else if(flagGood > 0)//装备
	{
		if(KeyCode == KeyEsc)
		{
			flagGood = 0 ;
			showPos=0;
			flagu = 0;
			flagd = 0;
			attFlag = 0;
			Show(0);
		}
		else if(KeyCode == KeyUp0 )
		{
			attFlag --;
			if(attFlag < 0 )
			{
				attFlag = 0;
			}
			Show(KeyCode);
		}
		else if(KeyCode == KeyDown0)
		{
			attFlag ++;
			int goodCount = 0 ;
			if(flagGood == 3)
			{
				int jj =0;

				for(int i = 0 ;i<goodAll;i++)
				{
					if( goodList.goodInList[i][0]!=13 &&  goodList.goodInList[i][0]!=14)
					{
						jj++;
					}
				}
				goodCount = jj;

			}


			if(flagGood == 1 && equipAll == attFlag )
			{
				attFlag = equipAll - 1;
			}
			else if(flagGood == 2 && throwAll == attFlag)
			{
				attFlag = throwAll - 1;
			}
			else if(flagGood == 3 && goodCount == attFlag)
			{
				attFlag = goodCount - 1;
			}
			Show(KeyCode);
		}
		else if(KeyCode == KeyPageUp )
		{
			attFlag2 --;
			Show(0);
		}
		else if( KeyCode == KeyPageDown)
		{
			attFlag2 ++;
			Show(0);
		}
		else if(KeyCode == KeyReturn)//return 键
		{
			//根据flagGood 装备 投资 使用
			//flagGood = 0;
			//Show(0);
			showPos=0;
			flagu = 0;
			flagd = 0;
			if(flagGood == 1)
			{
				//装备比较界面
				selectedGood = attFlag;
				attFlag  = 0;

				int t_goodType = equipList.equipInList[selectedGood][0]-1;
				int t_goodIdx = equipList.equipInList[selectedGood][1]-1;

				
				//20180826
				int canEqip = 0;
				if(fighthero[0].hp>0)
				{
					if(goodList.good[t_goodType][t_goodIdx].owner %2 == 1 && fighthero[0].no == 1)//1
					{
						canEqip = 1;
						t_selectedFightHero = 0;//20161119
					}
					else if(goodList.good[t_goodType][t_goodIdx].owner %4/2 ==1 && fighthero[0].no == 2)//2
					{
						canEqip = 1;
						t_selectedFightHero = 0;//20161119
					}
					else if(goodList.good[t_goodType][t_goodIdx].owner %8/4 == 1 && fighthero[0].no == 3)//3
					{
						canEqip = 1;
						t_selectedFightHero = 0;//20161119
					}
					else if(goodList.good[t_goodType][t_goodIdx].owner %16/8 == 1 && fighthero[0].no == 4)//4
					{
						canEqip = 1;
						t_selectedFightHero = 0;//20161119
					}
				}
				if(fighthero[1].hp>0)
				{
					if(goodList.good[t_goodType][t_goodIdx].owner %2 == 1 && fighthero[1].no == 1)//1
					{
						canEqip = 1;
						t_selectedFightHero = 1;//20161119
					}
					else if(goodList.good[t_goodType][t_goodIdx].owner %4/2 ==1 && fighthero[1].no == 2)//2
					{
						canEqip = 1;
						t_selectedFightHero = 1;//20161119
					}
					else if(goodList.good[t_goodType][t_goodIdx].owner %8/4 == 1 && fighthero[1].no == 3)//3
					{
						canEqip = 1;
						t_selectedFightHero = 1;//20161119
					}
					else if(goodList.good[t_goodType][t_goodIdx].owner %16/8 == 1 && fighthero[1].no == 4)//4
					{
						canEqip = 1;
						t_selectedFightHero = 1;//20161119
					}
				}
				if(fighthero[2].hp>0)
				{
					if(goodList.good[t_goodType][t_goodIdx].owner %2 == 1 && fighthero[2].no == 1)//1
					{
						canEqip = 1;
						t_selectedFightHero = 2;//20161119
					}
					else if(goodList.good[t_goodType][t_goodIdx].owner %4/2 ==1 && fighthero[2].no == 2)//2
					{
						canEqip = 1;
						t_selectedFightHero = 2;//20161119
					}
					else if(goodList.good[t_goodType][t_goodIdx].owner %8/4 == 1 && fighthero[2].no == 3)//3
					{
						canEqip = 1;
						t_selectedFightHero = 2;//20161119
					}
					else if(goodList.good[t_goodType][t_goodIdx].owner %16/8 == 1 && fighthero[2].no == 4)//4
					{
						canEqip = 1;
						t_selectedFightHero = 2;//20161119
					}
				}

				if(canEqip == 0)
				{
						TimerMessage("不能装备！",10,37,8,1,1000);
						Show(0);
						return 0;
				}

				
				flagShowEquipCompare = 1;
				Show(0);
			}
			else if(flagGood == 2)
			{
				//20160718增加可投掷判断.默认是可以投掷的，如果设置为1说明无法投掷
				if(throwflag == 0)//不可投掷
				{
					if(throwList.goodInList[attFlag][0] == 7)//武器
					{
						TimerMessage("无法投掷！",10,37,8,1,1000);
						Show(0);
						return 0;
					}
				}

				flagGood = 0;
				flagMenuGood = 0;
				flagMenu = 0;
				Show(0);

				selectedGood1[selectedFightHero][0] = throwList.goodInList[attFlag][0];//选择的投掷物
				selectedGood1[selectedFightHero][1] = throwList.goodInList[attFlag][1];//选择的投掷物
				attFlag  = 0;
				//已选定物品

				//选择敌人
				if(actorSum == 1)
				{
					selectedFightHero = 0;
					selectedHeroFinished = 1;
				}
				if (livedEnemySum >1 && throwList.good[selectedGood1[selectedFightHero][0]-1][selectedGood1[selectedFightHero][1]-1].all_dlfm_Flag < 16)
				{
					selectedFightStyle = 5;//投掷
					tmpselectedEnemy=livedEnemy[0];//20160630
				}
				else if (livedEnemySum >1 )
				{
					//全体 
					selectedFightStyle = 5;//投掷
					tmpselectedEnemy = livedEnemy[0];//20160706
					if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
					if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
					if(actorSum>2&&selectedHeroFinished>0)selectedFightEnemy[2] = livedEnemy[0];
					//g_selectedEnemyId[0] = livedEnemy[0];
					//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
					//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];

					//战斗动画
					selectedFightTypeConfirmed[selectedFightHero]= 5;
					//g_selectedFightStyle[selectedFightHero] = 5;
					selectedFightHero++;
					selectedHeroFinished ++;
					DealMian();//20160626

					selectedFightStyle = 0 ;//20170116
					int livedHero = actorSum;
					if(flagDied[0]||fighthero[0].mian>0)livedHero--;
					if((flagDied[1]&&actorSum>1)||fighthero[1].mian>0)livedHero--;
					if((flagDied[2]&&actorSum>2)||fighthero[2].mian>0)livedHero--;
					if(selectedHeroFinished >= (livedHero))
					{
						int ret = FightRun();
						/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
						{
						return -2;
						}
						else*/ if(ret>0)
						{
							//有结果
							int ret1 = DealResult(ret);
							if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
							{
								return GAMEOVER_FLAG;
							}
							if(fightType == 1 )
							{
								return -ret-2;
							}
							else
							{
								return -1;
							}
						}
						else if(ret == -1)
						{
							return -2;
						}
					}
				}
				else
				{
					//只有一个敌人 直接选择
					tmpselectedEnemy = livedEnemy[0];//20160706
					if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
					if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
					if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
					//g_selectedEnemyId[0] = livedEnemy[0];
					//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
					//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];

					if(actorSum == 1)//玩家1个 敌人1个20160305
					{

						//战斗动画
						selectedFightTypeConfirmed[selectedFightHero]= 5;
						//g_selectedFightStyle[selectedFightHero] = 5;
						int ret = FightRun();
						/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
						{
						return -2;
						}
						else*/ if(ret>0)
						{
							//有结果
							int ret1 = DealResult(ret);
							if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
							{
								return GAMEOVER_FLAG;
							}
							if(fightType == 1 )
							{
								return -ret-2;
							}
							else
							{
								return -1;
							}
						}
						else if(ret == -1)
						{
							return -2;
						}
					}
					else
					{
						selectedFightStyle = 5;
						//selectedHeroFinished++;
						SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
					}
				}


			}
			else if(flagGood == 3)//使用
			{
				flagGood = 0;
				flagMenuGood = 0;
				flagMenu = 0;
				//Show(0);

				int inGood[255];
				int jj =0;
				for(int i = 0 ;i<100;i++)
				{
					inGood[i]=-1;
				}
				for(int i = 0 ;i<goodAll;i++)
				{
					if( goodList.goodInList[i][0]!=13 &&  goodList.goodInList[i][0]!=14)
					{
						inGood[jj++] = i;
					}
				}

				selectedGood1[selectedFightHero][0] = goodList.goodInList[inGood[attFlag]][0];//选择的投掷物
				selectedGood1[selectedFightHero][1] = goodList.goodInList[inGood[attFlag]][1];//选择的投掷物
				attFlag  = 0;
				//已选定物品

				//选择敌人
				if(actorSum >1 && goodList.good[selectedGood1[selectedFightHero][0]-1][selectedGood1[selectedFightHero][1]-1].all_dlfm_Flag < 16 )
				{
					selectedFightStyle = 6;//使用
					tmpselectedEnemy=selectedFightHero;//20160630
				}
				else if(actorSum >1 )
				{
					selectedFightStyle = 6;//使用
					tmpselectedEnemy = selectedFightHero;//20161219 livedEnemy[0];//20160706
					if(selectedHeroFinished==0)selectedFightEnemy[0] = selectedFightHero;//20161219 livedEnemy[0];
					if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = selectedFightHero;//20161219 livedEnemy[0];
					if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = selectedFightHero;//20161219 livedEnemy[0];
					//g_selectedEnemyId[0] = livedEnemy[0];
					//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
					//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];

					selectedFightTypeConfirmed[selectedFightHero]= 6;
					//g_selectedFightStyle[selectedFightHero] = 6;
					selectedFightHero++;
					selectedHeroFinished ++;
					DealMian();//20160626
					selectedFightStyle = 0;//20170116
					int livedHero = actorSum;
					if(flagDied[0]||fighthero[0].mian>0)livedHero--;
					if((flagDied[1]&&actorSum>1)||fighthero[1].mian>0)livedHero--;
					if((flagDied[2]&&actorSum>2)||fighthero[2].mian>0)livedHero--;
					if(selectedHeroFinished >= (livedHero))
					{
						int ret = FightRun();
						/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
						{
						return -2;
						}
						else*/ if(ret>0)
						{
							//有结果
							int ret1 = DealResult(ret);
							if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
							{
								return GAMEOVER_FLAG;
							}
							if(fightType == 1 )
							{
								return -ret-2;
							}
							else
							{
								return -1;
							}
						}
						else if(ret == -1)
						{
							return -2;
						}
					}
				}
				else
				{
					//20161219转移到此
					selectedFightHero = 0;
					selectedHeroFinished = 0;
					//只有一个玩家 直接选择
					tmpselectedEnemy = selectedFightHero;//20161219 livedEnemy[0];//20160706
					if(selectedHeroFinished==0)selectedFightEnemy[0] = selectedFightHero;//20161219 livedEnemy[0];
					if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = selectedFightHero;//20161219 livedEnemy[0];
					if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = selectedFightHero;//20161219 livedEnemy[0];
					//g_selectedEnemyId[0] = livedEnemy[0];
					//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
					//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];
					selectedHeroFinished = 1;//20161219
					//战斗动画
					selectedFightTypeConfirmed[selectedFightHero]= 6;
					//g_selectedFightStyle[selectedFightHero] = 6;
					int ret = FightRun();
					/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
					{
					return -2;
					}
					else*/ if(ret>0)
					{
						//有结果
						int ret1 = DealResult(ret);
						if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
						{
							return GAMEOVER_FLAG;
						}
						if(fightType == 1 )
						{
							return -ret-2;
						}
						else
						{
							return -1;
						}
					}
					else if(ret == -1)
					{
						return -2;
					}
				}
			}
		}
	}

	else if(flagMenuGood == 1)
	{
		ret = menuGood.KeyDown(KeyCode);
		if(ret == -1)
		{
			flagMenuGood = 0;
		}
		else if(ret == 1)
		{
			if(menuGood.stat == 0)//装备
			{
				if(HasGoods(1))
				{
					attFlag = 0;
					flagGood = 1;
					Show(0);
				}
				else
				{
					flagMenuGood = 0;
					Show(0);
				}
			}
			else if(menuGood.stat == 1)//投掷
			{
				if(HasGoods(2))
				{
					attFlag = 0;
					flagGood = 2;
					Show(0);
				}
				else
				{
					flagMenuGood = 0;
					Show(0);
				}
			}
			else if(menuGood.stat == 2)//使用
			{
				if(HasGoods(3))
				{
					attFlag = 0;
					flagGood = 3;
					Show(0);
				}
				else
				{
					flagMenuGood = 0;
					Show(0);
				}
			}

		}
		Show(KeyCode);

	}
	else if(flagShowState > 0)
	{
		if(KeyCode == KeyEsc)
		{
			flagShowState = 0;
			Show(0);

		}
		else if(KeyCode == KeyUp0||KeyCode == KeyLeft0)
		{
			flagShowState --;
			if(flagShowState==0)flagShowState = 3;
			while(flagDied[flagShowState-1]||actorSum<flagShowState)
			{
				flagShowState--;
				if(flagShowState==0)flagShowState = 3;
			}
			Show(0);

		}
		else if(KeyCode == KeyDown0||KeyCode == KeyRight0)
		{
			flagShowState ++;
			if(flagShowState==4)flagShowState = 1;
			while(flagDied[flagShowState-1]||actorSum<flagShowState)
			{
				flagShowState++;
				if(flagShowState==4)flagShowState = 1;
			}
			Show(0);

		}

	}
	else if(flagSkill == 1)
	{
		if(KeyCode == KeyEsc)
		{
			keytmp = 0;
			attFlag = 1;
			flagSkill = 0;
			Show(0);

		}
		else if(KeyCode == KeyUp0 )//技能列表
		{
			if(keytmp == 1)keytmp = 0;
			attFlag2 = 0;//20160625
			attFlag --;
			Show(0);
		}
		else if(KeyCode == KeyDown0)
		{
			if(keytmp == 0)keytmp = 1;
			attFlag2 = 0;//20160625
			attFlag ++;
			Show(0);
		}
		else if(KeyCode == KeyPageUp)//技能说明
		{
			attFlag2 --;
			Show(0);
		}
		else if(KeyCode == KeyPageDown)
		{
			attFlag2 ++;
			Show(0);
		}
		else if(KeyCode == KeyReturn)//使用魔法
		{
			int tmpatt = attFlag;
			keytmp = 0;
			attFlag = 1;
			flagSkill = 0;

			Show(0);

			//处理判够用
			if(fighthero[selectedFightHero].mp <  magicList[selectedFightHero].magic[tmpatt].cost)
			{
				TimerMessage("真气不足！",10,37,8,1,1000);
				flagSkill = 1;
				attFlag = 0;//20170115
				Show(0);
				return 0;
			}


			selectedMagic[selectedFightHero] = tmpatt;//magicList[selectedFightHero].magic[attFlag].picnum;
			//g_selectedMagic[selectedFightHero] = tmpatt;
			//已选定魔法
			//selectedFightTypeConfirmed[selectedFightHero]=

			//选择敌人
			
			if(actorSum > 1 && magicList[selectedFightHero].magic[tmpatt].type != 1 && magicList[selectedFightHero].magic[tmpatt].type != 5 && magicList[selectedFightHero].magic[tmpatt].last_all < 16)
			{
				selectedFightStyle = 2;//技能
				tmpselectedEnemy=selectedFightHero;//20160627
			}
			else if(livedEnemySum >1 && (magicList[selectedFightHero].magic[tmpatt].type == 1 || magicList[selectedFightHero].magic[tmpatt].type == 5) && magicList[selectedFightHero].magic[tmpatt].last_all < 16)
			{
				selectedFightStyle = 2;//技能
				tmpselectedEnemy=livedEnemy[0];//20160627
			}
			else if(actorSum >1 && magicList[selectedFightHero].magic[tmpatt].type != 1 && magicList[selectedFightHero].magic[tmpatt].type != 5)
			{
				tmpselectedEnemy = selectedFightHero;//20161219 livedEnemy[0];//20160706
				if(selectedHeroFinished==0)selectedFightEnemy[0] = selectedFightHero;//20161219 livedEnemy[0];
				if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = selectedFightHero;//20161219 livedEnemy[0];
				if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = selectedFightHero;//20161219 livedEnemy[0];
				//g_selectedEnemyId[0] = livedEnemy[0];
				//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
				//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];

				selectedFightTypeConfirmed[selectedFightHero]= 2;
				//g_selectedFightStyle[selectedFightHero] = 2;
				selectedFightHero++;
				selectedHeroFinished ++;
				DealMian();//20160626
				selectedFightStyle = 0;//20170116
				//20160317增加
				int livedHero = actorSum;
				if(flagDied[0]||fighthero[0].mian>0)livedHero--;
				if((flagDied[1]&&actorSum>1)||fighthero[1].mian>0)livedHero--;
				if((flagDied[2]&&actorSum>2)||fighthero[2].mian>0)livedHero--;
				if(selectedHeroFinished >= (livedHero))
				{
					int ret = FightRun();
					/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
					{
					keytmp = 0;
					attFlag = 1;
					return -2;
					}
					else */if(ret>0)
					{
						//有结果
						int ret1 = DealResult(ret);
						if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
						{
							return GAMEOVER_FLAG;
						}
						if(fightType == 1 )
						{
							keytmp = 0;
							attFlag = 1;
							return -ret-2;
						}
						else
						{
							keytmp = 0;
							attFlag = 1;
							return -1;
						}
					}
					else if(ret == -1)
					{
						keytmp = 0;
						attFlag = 1;
						return -2;
					}

					//selectedFightHero = 0;
					//selectedHeroFinished = 0;//20160701
					//selectedFightStyle = 0;


					//下回合预处理

					if(livedEnemySum == 1)
					{
						tmpselectedEnemy = livedEnemy[0];//20160706
						if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
						if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
						if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
						//selectedHeroFinished ++;
					}

				}

			}
			else if(livedEnemySum >1 && (magicList[selectedFightHero].magic[tmpatt].type == 1 || magicList[selectedFightHero].magic[tmpatt].type == 5))
			{
				tmpselectedEnemy = livedEnemy[0];//20160706
				if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
				if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
				if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
				//[0] = livedEnemy[0];
				//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
				//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];

				selectedFightTypeConfirmed[selectedFightHero]= 2;
				//g_selectedFightStyle[selectedFightHero] = 2;
				selectedFightHero++;
				selectedHeroFinished ++;
				DealMian();//20160626
				selectedFightStyle = 0;//20170116
				//20160317增加
				int livedHero = actorSum;
				if(flagDied[0]||fighthero[0].mian>0)livedHero--;
				if((flagDied[1]&&actorSum>1)||fighthero[1].mian>0)livedHero--;
				if((flagDied[2]&&actorSum>2)||fighthero[2].mian>0)livedHero--;
				if(selectedHeroFinished >= (livedHero))
				{
					int ret = FightRun();
					/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
					{
					keytmp = 0;
					attFlag = 1;
					return -2;
					}
					else */if(ret>0)
					{
						//有结果
						int ret1 = DealResult(ret);
						if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
						{
							return GAMEOVER_FLAG;
						}
						if(fightType == 1 )
						{
							keytmp = 0;
							attFlag = 1;
							return -ret-2;
						}
						else
						{
							keytmp = 0;
							attFlag = 1;
							return -1;
						}
					}
					else if(ret == -1)
					{
						keytmp = 0;
						attFlag = 1;
						return -2;
					}

					//selectedFightHero = 0;
					//selectedHeroFinished = 0;//20160701
					//selectedFightStyle = 0;


					//下回合预处理

					if(livedEnemySum == 1)
					{
						tmpselectedEnemy = livedEnemy[0];//20160706
						if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
						if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
						if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
						//selectedHeroFinished ++;
					}

				}
			}
			else if(actorSum == 1 && magicList[selectedFightHero].magic[tmpatt].type != 1 && magicList[selectedFightHero].magic[tmpatt].type != 5)//20161219条件外移 //玩家1个 敌人1个20160305
			{
				//20161219转移到此
				selectedFightHero = 0;
				selectedHeroFinished = 0;

				//只有一个敌人 直接选择
				tmpselectedEnemy = selectedFightHero;//20160706
				if(selectedHeroFinished==0)selectedFightEnemy[0] = selectedFightHero;//20161219 livedEnemy[0];//20160625
				if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = selectedFightHero;//20161219 livedEnemy[0];//20160625
				if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = selectedFightHero;//20161219 livedEnemy[0];//20160625
				//g_selectedEnemyId[0] = livedEnemy[0];
				//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
				//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];
				

				if(livedEnemySum == 1)//玩家1个 敌人1个20160305
				{
					selectedHeroFinished = 1;//20170118移动
					//战斗动画
					selectedFightTypeConfirmed[selectedFightHero]= 2;
					//g_selectedFightStyle[selectedFightHero] = 2;
					int ret = FightRun();
					/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
					{
					keytmp = 0;
					attFlag = 1;
					return -2;
					}
					else */if(ret>0)
					{
						//有结果
						int ret1 = DealResult(ret);
						if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
						{
							return GAMEOVER_FLAG;
						}
						if(fightType == 1 )
						{
							keytmp = 0;
							attFlag = 1;
							return -ret-2;
						}
						else
						{
							keytmp = 0;
							attFlag = 1;
							return -1;
						}
					}
					else if(ret == -1)
					{
						keytmp = 0;
						attFlag = 1;
						return -2;
					}
				}
				else
				{
					selectedFightStyle = 2;
					//selectedHeroFinished++;
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
			
			}
			else //敌人=1 玩家未知 攻击型
			{
				//20161219转移到此 20170118修正
				//selectedFightHero = 0;
				//selectedHeroFinished = 0;

				//只有一个敌人 直接选择
				tmpselectedEnemy = livedEnemy[0];//20160706
				if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];//20160625
				if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];//20160625
				if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];//20160625
				//g_selectedEnemyId[0] = livedEnemy[0];
				//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
				//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];
				

				if(actorSum == 1)//玩家1个 敌人1个20160305
				{
					selectedHeroFinished = 1;//20170118移动
					//战斗动画
					selectedFightTypeConfirmed[selectedFightHero]= 2;
					//g_selectedFightStyle[selectedFightHero] = 2;
					int ret = FightRun();
					/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
					{
					keytmp = 0;
					attFlag = 1;
					return -2;
					}
					else */if(ret>0)
					{
						//有结果
						int ret1 = DealResult(ret);
						if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
						{
							return GAMEOVER_FLAG;
						}
						if(fightType == 1 )
						{
							keytmp = 0;
							attFlag = 1;
							return -ret-2;
						}
						else
						{
							keytmp = 0;
							attFlag = 1;
							return -1;
						}
					}
					else if(ret == -1)
					{
						keytmp = 0;
						attFlag = 1;
						return -2;
					}
				}
				else
				{
					selectedFightStyle = 2;
					//selectedHeroFinished++;
					SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
				}
			}
		}
	}
	else if(flagMenu == 1)
	{
		ret = menuChoice.KeyDown(KeyCode);

		if(ret == -1)
		{
			flagMenu = 0;
		}
		else if(ret == 1)
		{
			if(menuChoice.stat == 0)//围攻
			{
				selectedFightStyle = 4;

				flagMenu = 0;
				Show(0);
				int ret = FightRunAuto();//围攻
				/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
				{
				return -2;
				}
				else*/ if(ret>0)
				{
					//有结果
					int ret1 = DealResult(ret);
					if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
					{
						return GAMEOVER_FLAG;
					}
					if(fightType == 1 )
					{
						return -ret-2;
					}
					else
					{
						return -1;
					}
				}
				else if(ret == -1)
				{
					return -2;
				}
				selectedFightStyle = 0;

			}
			else if(menuChoice.stat == 1)//道具
			{
				//显示菜单
				//装备投掷 使用
				if(HasGoods(0))
				{
					flagMenuGood = 1;
					menuGood.Init(2,3,26,14,7,0);
				}
			}
			else if(menuChoice.stat == 2)//防御
			{
				flagDef[selectedFightHero] = 1;
				flagMenu = 0;
				selectedFightStyle = 7;
				selectedFightTypeConfirmed[selectedFightHero]= 7;
				//g_selectedFightStyle[selectedFightHero] = 7;
				selectedHeroFinished ++;
				if(actorSum == 1)
				{
					selectedFightHero = 0;
					//selectedHeroFinished ++;
				}

				selectedFightStyle = 0 ;
				selectedFightHero++;
				DealMian();//20160626
				selectedFightStyle = 0;//20170116
				Show(0);
				int livedHero = actorSum;
				if(flagDied[0]||fighthero[0].mian>0)livedHero--;
				if((flagDied[1]&&actorSum>1)||fighthero[1].mian>0)livedHero--;
				if((flagDied[2]&&actorSum>2)||fighthero[2].mian>0)livedHero--;
				if(selectedHeroFinished >= (livedHero))
				{
					//选择完战斗对象 战斗进程 
					int ret = FightRun();
					/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
					{
					return -2;
					}
					else*/ if(ret>0)
					{
						//有结果
						int ret1 = DealResult(ret);
						if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
						{
							return GAMEOVER_FLAG;
						}
						if(fightType == 1 )
						{
							return -ret-2;
						}
						else
						{
							return -1;
						}
					}
					else if(ret == -1)
					{
						return -2;
					}
					flagDef[0] = 0;
					flagDef[1] = 0;
					flagDef[2] = 0;
					//selectedFightHero = 0;
					//selectedHeroFinished = 0;//20160701
					//selectedFightStyle = 0;

					//ClearSelectedValue();
					//下回合预处理
					/*if(actorSum == 1)
					{
					selectedFightHero = 0;
					//selectedHeroFinished ++;
					selectedHeroFinished ++;
					}*/
					if(livedEnemySum == 1)
					{
						tmpselectedEnemy = livedEnemy[0];//20160706
						if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
						if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
						if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
						//selectedHeroFinished ++;
					}
				}
			}
			else if(menuChoice.stat == 3)//逃跑
			{
				flagLeave[selectedFightHero] = 0;
				flagMenu = 0;
				selectedFightStyle = 8;

				Show(0);

				for(int i = selectedFightHero ; i < 3 ;i ++)
				{
					//20160818修正 异常退出
					if(fighthero[i].hp==0)continue;
					//计算成功概率
					int rnd  = rand()%100;
					//rnd = 0;
					int spdBool = GetRunSpeed();//获取逃跑几率 速度小 30% 速度大于 80% 
					if(((rnd > 20 && spdBool == 1)||(rnd > 70 && spdBool == 0)) && fightType != 1)//20160704 增加随机战斗判断
					{
						//成功
						flagLeave[i] = 1;//1-成功
						selectedFightTypeConfirmed[i]= 8;
						//g_selectedFightStyle[i] = 8;
						int ret = FightRun();
						g_selectedFightStyle[0]= 8;//20170122
						g_selectedFightStyle[1]= 8;//20170122
						g_selectedFightStyle[2]= 8;//20170122
						/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
						{
						return -2;
						}
						else*/ if(ret>0)
						{
							//有结果
							int ret1 = DealResult(ret);
							if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
							{
								return GAMEOVER_FLAG;
							}
							if(fightType == 1 )
							{
								return -ret-2;
							}
							else
							{
								return -1;
							}
						}
						else if(ret == -1)
						{
							return -2;
						}
						//处理战斗结果
						int ret1 = DealResult(3);
						if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
						{
							return GAMEOVER_FLAG;
						}
						selectedFightStyle = 0;
						return -11;//-11 逃跑
					}
					else
					{
						//失败
						flagLeave[i] = 2;//2-失败
						selectedFightTypeConfirmed[i]= 8;
						//g_selectedFightStyle[i] = 8;

					}
					//selectedFightStyle = 0;
					//return -1;//-1 逃跑
				}
				int ret = FightRun();
				/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
				{
				return -2;
				}
				else */if(ret>0)
				{
					//有结果
					int ret1 = DealResult(ret);
					if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111)
					{
						return GAMEOVER_FLAG;
					}
					if(fightType == 1 )
					{
						return -ret-2;
					}
					else
					{
						return -1;
					}
				}
				else if(ret == -1)
				{
					return -2;
				}
				selectedFightStyle = 0;

			}
			else if(menuChoice.stat == 4)//状态
			{
				flagShowState = selectedFightHero+1;

			}
		}
		Show(KeyCode);
		//menuChoice.Show(KeyCode);

	}
	else
	{
		if(KeyCode == KeyEsc)
		{
			if(isFightRuned == 1)return 0;
			//20160301增加 回退操作
			if(selectedFightHero>0 && fighthero[(selectedFightHero-1)].mian==0)//20160718增加对眠判断
			{

				selectedHeroFinished --;
				if(selectedHeroFinished<0)selectedHeroFinished = 0;
				selectedFightHero--;
				selectedFightEnemy[selectedFightHero] = 0;
				selectedFightTypeConfirmed[selectedFightHero] = 0;
				//g_selectedFightStyle[selectedFightHero] = 1;
				//g_selectedEnemyId[selectedFightHero] = 0;
				selectedFightStyle = 0;
				flagDef[selectedFightHero]=0;

				GetTmpEnemy(4);


			}

			if(selectedFightHero==2 && fighthero[1].mian > 0 && fighthero[0].mian==0)//20160718增加对眠判断2
			{

				selectedHeroFinished = 0;
				selectedFightHero = 0;
				selectedFightEnemy[2] = 0;
				selectedFightTypeConfirmed[2] = 0;
				//g_selectedFightStyle[selectedFightHero] = 1;
				//g_selectedEnemyId[selectedFightHero] = 0;
				selectedFightStyle = 0;
				flagDef[2]=0;

				GetTmpEnemy(4);


			}


		}
		else if(KeyCode == KeyPageUp || KeyCode == KeyPageDown)
		{

			Show(0);
		}
		else if(KeyCode == KeyUp0 )
		{
			attFlag = 0;
			Show(0);
		}
		else if(KeyCode == KeyLeft0 && CanUseMagic())
		{
			attFlag = 1;
			Show(0);
		}
		else if(KeyCode == KeyDown0)
		{
			attFlag = 2;
			Show(0);
		}
		else if(KeyCode == KeyRight0)
		{
			if(hasAllAttact() == 1)//有合体技能
			{
				attFlag = 3;
			}
			Show(0);
		}
		else if(KeyCode == KeyR)//r
		{
			selectedFightTypeConfirmed[0]=g_selectedFightStyle[0];
			selectedFightTypeConfirmed[1]=g_selectedFightStyle[1];
			selectedFightTypeConfirmed[2]=g_selectedFightStyle[2];

			//默认普通
			if(selectedFightTypeConfirmed[0]==0)selectedFightTypeConfirmed[0]=1;
			if(selectedFightTypeConfirmed[1]==0)selectedFightTypeConfirmed[1]=1;
			if(selectedFightTypeConfirmed[2]==0)selectedFightTypeConfirmed[2]=1;

			selectedFightEnemy[0] = g_selectedEnemyId[0];
			selectedFightEnemy[1] = g_selectedEnemyId[1];
			selectedFightEnemy[2] = g_selectedEnemyId[2];

			selectedGood1[0][0] = g_selectedGood[0][0];
			selectedGood1[0][1] = g_selectedGood[0][1];
			selectedGood1[1][0] = g_selectedGood[1][0];
			selectedGood1[1][1] = g_selectedGood[1][1];
			selectedGood1[2][0] = g_selectedGood[2][0];
			selectedGood1[2][1] = g_selectedGood[2][1];

			selectedMagic[0] = g_selectedMagic[0];
			selectedMagic[1] = g_selectedMagic[1];
			selectedMagic[2] = g_selectedMagic[2];

			for(int i = 0 ; i < 3 ; i ++)
			{

				//20160627判断休眠
				if(fighthero[i].mian>0)
				{
					selectedFightTypeConfirmed[i]=9;
				}
			}

			for(int i = 0 ; i < 3 ; i ++)//20160818新增对已经死亡角色的判断,转换战斗方式，防止复活
			{

				if(fighthero[i].hp == 0)
				{
					selectedFightTypeConfirmed[i]=1;
				}
			}

			for(int i = 0 ; i < 3 ; i ++)
			{
				if(flagEnemyDied[selectedFightEnemy[i]]&&CheckTo(i)==0)
				{
					GetTmpEnemy(4);
					if(tmpselectedEnemy == -1)//全部死亡
					{
						tmpselectedEnemy = 0;
					}
					selectedFightEnemy[i] = tmpselectedEnemy;
				}

			}
			for(int i = 0 ; i < 3 ; i ++)
			{
				if(flagDied[selectedFightEnemy[i]]&&CheckTo(i)==1)
				{
					GetTmpEnemy(2);
					if(tmpselectedEnemy == -1)//全部死亡
					{
						tmpselectedEnemy = 0;
					}
					selectedFightEnemy[i] = tmpselectedEnemy;
				}

			}

			for(int i = 0 ; i < 3 ; i ++)
			{
				if(selectedFightTypeConfirmed[i] == 2)
				{
					if(fighthero[i].mp <  magicList[i].magic[selectedMagic[i]].cost)
					{
						selectedFightTypeConfirmed[i] = 1;
					}
				}
			}

			if(selectedFightTypeConfirmed[0]==4)
			{
				int ret = FightRunAuto();//围攻
				/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
				{
				return -2;
				}
				else */if(ret>0)
				{
					//有结果
					int ret1 = DealResult(ret);
					if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111)
					{
						return GAMEOVER_FLAG;
					}
					if(fightType == 1 )
					{
						return -ret-2;
					}
					else
					{
						return -1;
					}
				}
				else if(ret == -1)
				{
					return -2;
				}
			}
			else if(selectedFightTypeConfirmed[0]==8||selectedFightTypeConfirmed[1]==8||selectedFightTypeConfirmed[2]==8)
			{
				for(int i = 0 ; i < 3 ;i ++)//20170122
				{
					if(selectedFightTypeConfirmed[i]==8)
					{
						//计算成功概率
						int rnd  = rand()%100;
						//rnd = 0;
						int spdBool = GetRunSpeed();//获取逃跑几率 速度小 30% 速度大于 80% 
						if(((rnd > 20 && spdBool == 1)||(rnd > 70 && spdBool == 0)) && fightType != 1)//20210806 增加随机战斗判断
						{
							flagLeave[i] = 1;//1-成功
							int ret = FightRun();
							/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
							{
							return -2;
							}
							else*/ if(ret>0)
							{
								//有结果
								int ret1 = DealResult(ret);
								if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111)
								{
									return GAMEOVER_FLAG;
								}
								if(fightType == 1 )
								{
									return -ret-2;
								}
								else
								{
									return -1;
								}
							}
							else if(ret == -1)
							{
								return -2;
							}
							int ret1 = DealResult(3);
							if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
							{
								return GAMEOVER_FLAG;
							}
							//return -11;//-11 逃跑 20170122
							return -1;
						}
						else
						{
							flagLeave[i] = 2;//2-失败
							selectedFightTypeConfirmed[i]= 8;//20170122
							

						}

					}
				}
				int ret = FightRun();//20170122增加循环,移到循环外
				/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
				{
					return -2;
				}
				else */if(ret>0)
				{
					//有结果
					int ret1 = DealResult(ret);
					if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
					{
						return GAMEOVER_FLAG;
					}
					if(fightType == 1 )
					{
						return -ret-2;
					}
					else
					{
						return -1;
					}
				}
				else if(ret == -1)
				{
					return -2;
				}

			}
			else
			{
				if(selectedFightTypeConfirmed[0]==7)flagDef[0] = 1;
				if(selectedFightTypeConfirmed[1]==7)flagDef[1] = 1;
				if(selectedFightTypeConfirmed[2]==7)flagDef[2] = 1;
				int ret = FightRun();
				/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
				{
				return -2;
				}
				else*/ if(ret>0)
				{
					//有结果
					int ret1 = DealResult(ret);
					if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
					{
						return GAMEOVER_FLAG;
					}
					if(fightType == 1 )
					{
						return -ret-2;
					}
					else
					{
						return -1;
					}
				}
				else if(ret == -1)
				{
					return -2;
				}
			}
			//selectedHeroFinished = 0;
			//selectedFightStyle = 0;
			flagDef[0] = 0;
			flagDef[1] = 0;
			flagDef[2] = 0;
			//ClearSelectedValue();
			//下回合预处理
			/*if(actorSum == 1)
			{
			selectedFightHero = 0;
			selectedHeroFinished ++;
			}*/
			/*if(livedEnemySum == 1)
			{
			if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
			if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
			if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
			selectedHeroFinished ++;

			}*/
			Show(0);
		}
		else if(KeyCode == KeyReturn)
		{
			if(attFlag == 2)//进入菜单
			{
				flagMenu = 1;
				menuChoice.Init(2,5,9,4,6,0);
			}
			else if(attFlag == 1)//进入技能
			{
				if(fighthero[selectedFightHero].magicLearn==0)
				{
					attFlag = 0;
				}
				else
				{
					flagSkill = 1;
					attFlag = 0;
					keytmp = 0;
				}
				//selectedFightStyle = 2;
			}
			else if(attFlag == 0)//普通攻击 选人
			{

				//选择敌人
				if(actorSum == 1 )//玩家一个
				{
					selectedFightHero = 0;
					selectedHeroFinished = 1;
				}
				if(livedEnemySum >1 && goodList.good[6][fighthero[selectedFightHero].hand-1].all_dlfm_Flag < 16)//敌人2个以上
				{
					selectedFightStyle = 1;
				}
				else if(livedEnemySum >1)//全体
				{
										
					selectedFightStyle = 1;
					tmpselectedEnemy = livedEnemy[0];//20160706
					if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
					if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
					if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
					//g_selectedEnemyId[0] = livedEnemy[0];
					//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
					//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];

					selectedFightTypeConfirmed[selectedFightHero]= 1;
					//g_selectedFightStyle[selectedFightHero] = 1;

					selectedFightHero++;
					selectedHeroFinished ++;
					
					DealMian();//20160626
					selectedFightStyle = 0 ;//20170102

					int livedHero = actorSum;
					if(flagDied[0]||fighthero[0].mian>0)livedHero--;
					if((flagDied[1]&&actorSum>1)||fighthero[1].mian>0)livedHero--;
					if((flagDied[2]&&actorSum>2)||fighthero[2].mian>0)livedHero--;
					if(selectedHeroFinished >= (livedHero))
					{
						int ret = FightRun();
						/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
						{
						return -2;
						}
						else*/ if(ret>0)
						{
							//有结果
							int ret1 = DealResult(ret);
							if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
							{
								return GAMEOVER_FLAG;
							}
							if(fightType == 1 )
							{
								return -ret-2;
							}
							else
							{
								return -1;
							}
						}
						else if(ret == -1)
						{
							return -2;
						}
					}

				}
				else if(goodList.good[6][fighthero[selectedFightHero].hand-1].all_dlfm_Flag >= 16)//全体 敌人1个20170102
				{
										
					selectedFightStyle = 1;
					tmpselectedEnemy = livedEnemy[0];//20160706
					if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
					if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
					if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
					//g_selectedEnemyId[0] = livedEnemy[0];
					//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
					//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];

					selectedFightTypeConfirmed[selectedFightHero]= 1;
					//g_selectedFightStyle[selectedFightHero] = 1;

					selectedFightHero++;
					selectedHeroFinished ++;
					
					DealMian();//20160626
					selectedFightStyle = 0 ;//20170102
					
					int livedHero = actorSum;
					if(flagDied[0]||fighthero[0].mian>0)livedHero--;
					if((flagDied[1]&&actorSum>1)||fighthero[1].mian>0)livedHero--;
					if((flagDied[2]&&actorSum>2)||fighthero[2].mian>0)livedHero--;
					if(selectedHeroFinished >= (livedHero))
					{
						int ret = FightRun();
						/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
						{
						return -2;
						}
						else*/ if(ret>0)
						{
							//有结果
							int ret1 = DealResult(ret);
							if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
							{
								return GAMEOVER_FLAG;
							}
							if(fightType == 1 )
							{
								return -ret-2;
							}
							else
							{
								return -1;
							}
						}
						else if(ret == -1)
						{
							return -2;
						}
					}

				}
				else 
				{
					//只有一个敌人 直接选择
					tmpselectedEnemy = livedEnemy[0];//20160706
					if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
					if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
					if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
					//g_selectedEnemyId[0] = livedEnemy[0];
					//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
					//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];

					if(actorSum == 1)//玩家1个 敌人1个
					{

						//战斗动画
						selectedFightTypeConfirmed[selectedFightHero]= 1;
						//g_selectedFightStyle[selectedFightHero] = 1;

						int ret = FightRun();
						/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
						{
						return -2;
						}
						else */if(ret>0)
						{
							//有结果
							int ret1 = DealResult(ret);
							if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
							{
								return GAMEOVER_FLAG;
							}
							if(fightType == 1 )
							{
								return -ret-2;
							}
							else
							{
								return -1;
							}
						}
						else if(ret == -1)
						{
							return -2;
						}
					}
					else//玩家2个以上 敌人一个
					{

						selectedFightStyle = 1;
						//selectedHeroFinished++;
						SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
					}
				}
			}
			else if(attFlag == 3)//合击  选人
			{
				if(actorSum == 1)//只有一人 无法合击
				{
					attFlag = 0;
					Show(0);

				}
				else
				{
					//20160626选定合击伙伴
					if(fighthero[0].hp>0&&selectedFightHero!=0)all_obj = 0;
					if(fighthero[1].hp>0&&selectedFightHero!=1)all_obj = 1;
					if(fighthero[2].hp>0&&selectedFightHero!=2)all_obj = 2;
					selectedHeroFinished ++;//20170102增加一个选择完成
					if(livedEnemySum >1)
					{
						selectedFightStyle = 3;
					}
					else
					{
						//只有一个敌人 直接选择
						
						tmpselectedEnemy = livedEnemy[0];//20160706
						if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
						if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
						if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
						//g_selectedEnemyId[0] = livedEnemy[0];
						//if(actorSum>1&&selectedHeroFinished>0)g_selectedEnemyId[1] = livedEnemy[1];
						//if(actorSum>2&&selectedHeroFinished>1)g_selectedEnemyId[2] = livedEnemy[2];

						if(actorSum == 1)//玩家1个 敌人1个20160305
						{
							//战斗动画
							selectedFightTypeConfirmed[selectedFightHero]= 3;
							//g_selectedFightStyle[selectedFightHero] = 3;
							int ret = FightRun();
							/*if(ret == 1 && fightType == 1 && e_roundmax > 0)//enter
							{
							return -2;
							}
							else*/ if(ret>0)
							{
								//有结果
								int ret1 = DealResult(ret);
								if(ret1 == GAMEOVER_FLAG&& fightType != 1 )//20170111
								{
									return GAMEOVER_FLAG;
								}
								if(fightType == 1 )
								{
									return -ret-2;
								}
								else
								{
									return -1;
								}
							}
							else if(ret == -1)
							{
								return -2;
							}
						}
						else
						{
							selectedFightStyle = 3;
							//selectedHeroFinished++;
							SendMessage(hwnd,WM_KEYDOWN,KeyReturn,0);
						}
					}
				}
			}
			Show(0);

		}
	}
	return 0;
}

int Fight::UsedInit()
{
	wlogfile(1, __FUNCTION__ ,"开始",0);
	//取1-3个战斗用敌人

	int rnd;
	usedenemyType[0] = -1; 
	usedenemyType[1] = -1; 
	usedenemyType[2] = -1; 
	int j = 0;

	for(int i = 0; i< 8;i++)
	{
		if(enemyType[i]==0)
		{
			j++;
		}
	}
	if(j==8)
	{
		return -1;
	}
	for(int j = 0; j< 3 ;j++)
	{
		for(int i = 0; i< 8;i++)
		{
			rnd = rand()%8;
			if(rnd == 0)
			{
				usedenemyType[j] = enemyType[i];
			}
		}
	}
	fightType = 2;//2-随机战斗
	selectedFightHero = 0;
	selectedFightStyle =0;
	selectedHeroFinished = 0;
	for(int i = 0 ; i< 3;i++)
	{
		flagDied[i] = 0;
		flagEnemyDied[i] = 0;
		flagDef[i] =0;
	}
	return 0;
}

int Fight::hasAllAttact()
{
	if(fighthero[selectedFightHero].togethermagic>0)//20160626
	{
		int livedHero = 0;
		if(fighthero[0].hp>0)livedHero++;
		if(fighthero[1].hp>0)livedHero++;
		if(fighthero[2].hp>0)livedHero++;
		if(livedHero>=2)
		{
			return 1;
		}
	}
	return 0;
}
void Fight::randomEnemy()
{
	int rnd = 0;
	allMoney = 0;
	allExp = 0;
	memset(fightEnemy,0,sizeof(fightEnemy));
	for(int i = 0 ; i< 3;i++)
	{
		fightEnemy[i].picno = 0;
	}

	//20161030修正goodhave初始化
	for(int p_i = 0 ;p_i < 6 ;p_i ++)
	{
		for(int p_j = 0 ; p_j < 3 ; p_j ++)
		{
			goodHave[p_i][p_j] = 0;
		}
	}
	enemy[0] = 0;//20161220
	enemy[1] = 0;//20161220
	enemy[2] = 0;//20161220

	for(int i = 0 ; i< 3;i++)
	{

		if(i>0)rnd = rand()%4;//2-3 50%出怪
		if(rnd < 3)
		{
			rnd = rand()%8;//8选一
			//fightEnemy[i] = new FightEnemy();
			while(enemyType[rnd]==0  && (enemyType[0]!=0||enemyType[1]!=0||enemyType[2]!=0||enemyType[3]!=0||enemyType[4]!=0||enemyType[5]!=0||enemyType[6]!=0||enemyType[7]!=0))//20170329判断完整8个
			{
				rnd = rand()%8;//8选一
			}
			fightEnemy[i].Init(enemyType[rnd]);
			if(enemyType[rnd]!=0)
			{
				enemySum++;
				livedEnemySum++;
				livedEnemy[livedEnemySum-1] = i;
				enemy[livedEnemySum-1] = i;
				allMoney+=fightEnemy[i].money;
				allExp+=fightEnemy[i].exp;
				goodHave[i*2][0]=fightEnemy[i].goods1type;
				goodHave[i*2][1]=fightEnemy[i].goods1idx;
				goodHave[i*2][2]=fightEnemy[i].goods1num;
				goodHave[i*2+1][0]=fightEnemy[i].goods2type;
				goodHave[i*2+1][1]=fightEnemy[i].goods2idx;
				goodHave[i*2+1][2]=fightEnemy[i].goods2num;
			}
		}
		else
		{
			break;
		}


	}

	return;
}


void Fight::ShowFightActorPic(int idx,int no)//no=内编号
{

	BITMAP bwh;

	int type1 = GetType(RES_PIC,3,fighthero[idx].no);
	if(type1 == 1)
	{

		LoadPic(RES_PIC,3,fighthero[idx].no,hbmp,no);	//封装完成
		HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
		GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
		//hurtOffset = 96 - bwh.bmHeight - 55;//20160817
		BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2, 57 - 5 *(idx+1), bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
		SelectObject(hdcMem, oldhbmp);
		DeleteObject(hbmp);
	}
	else
	{
		LoadPicMask(RES_PIC,3,fighthero[idx].no,hbmp,no);//20160225修正战斗主角
		HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
		GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
		//hurtOffset = 96 - bwh.bmHeight - 55;//20160817
		BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2, 57 - 5 *(idx+1), bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCPAINT);
		SelectObject(hdcMem, oldhbmp);
		DeleteObject(hbmp);

		LoadPicTrans(RES_PIC,3,fighthero[idx].no,hbmp,no);	//封装完成
		//GetObject(hbmp, sizeof(BITMAP), &bmp);
		oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
		BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2, 57 - 5 *(idx+1), bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCAND);
		SelectObject(hdcMem, oldhbmp);
		DeleteObject(hbmp);
	}
	InvalidateRect(hwnd,&rect,false);

	return;
}


void Fight::ShowFightEnemyPic(int idx)
{

	BITMAP bwh;

	int type1 = GetType(RES_ACP,3,fightEnemy[idx].picno);
	if(type1 == 1)
	{
		LoadPic(RES_ACP,3,fightEnemy[idx].picno,hbmp);
		HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
		GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸
		//hurtOffset = 96 - bwh.bmHeight - 25 ;//20160817
		BitBlt(hdcTmp, 20 + idx * 35 - bwh.bmWidth/2, 20 - 5 * idx, bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
		SelectObject(hdcMem, oldhbmp);
		DeleteObject(hbmp);
	}
	else
	{
		LoadPicMask(RES_ACP,3,fightEnemy[idx].picno,hbmp);
		HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
		GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸
		//hurtOffset = 96 - bwh.bmHeight - 25 ;//20160817
		BitBlt(hdcTmp, 20 + idx * 35 - bwh.bmWidth/2, 20 - 5 * idx, bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCPAINT);
		SelectObject(hdcMem, oldhbmp);
		DeleteObject(hbmp);

		LoadPicTrans(RES_ACP,3,fightEnemy[idx].picno,hbmp);	//封装完成
		//GetObject(hbmp, sizeof(BITMAP), &bmp);
		oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
		BitBlt(hdcTmp, 20 + idx * 35 - bwh.bmWidth/2, 20 - 5 * idx, bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCAND);

		SelectObject(hdcMem, oldhbmp);
		DeleteObject(hbmp);
	}

	InvalidateRect(hwnd,&rect,false);

	return;
}

int Fight::HasGoods(int type)
{
	//0全部 1-装备2投资 3使用
	if(type==0)
	{
		if(goodAll+equipAll+throwAll>0)return 1;//20161218
	}
	else if(type==1)
	{
		if(equipAll>0)return 1;
	}
	else if(type==2)
	{
		//投掷 武器+暗器
		if(throwAll>0)return 1;
	}
	else if(type==3)
	{
		int goodCount = 0;
		for(int i = 0 ;i<goodAll;i++)
		{
			if( goodList.goodInList[i][0]!=13 &&  goodList.goodInList[i][0]!=14)
			{
				goodCount++;
			}
		}
		if(goodCount>0)return 1;
	}
	return 0;
}

void Fight::DelEquipUse()
{
	int tmp = 0;
	int tmp1 = 0;
	int goodType = equipList.equipInList[selectedGood][0] - 1;
	int goodIdx = equipList.equipInList[selectedGood][1] - 1;

	int s_selectedFightHero =  selectedFightHero;//20180826
	selectedFightHero = t_selectedFightHero;

	if(equipList.equipInList[selectedGood][0] == 1)
	{
		tmp = equipList.equipInList[selectedGood][1];
		if(fighthero[selectedFightHero].head != 0)
		{
			tmp1 = fighthero[selectedFightHero].head;
			//20160305增加检测是否已有该装备可重叠
			int pos = equipList.CheckGoodExistReturnPos(1,fighthero[selectedFightHero].head);
			if(pos)
			{
				pos--;
				equipList.equipInList[pos][2] ++;
			}
			else
			{
				equipList.Add(1,fighthero[selectedFightHero].head,1);
				//equipList.equipInList[equipAll][0] = 1;
				//equipList.equipInList[equipAll][1] = fighthero[selectedFightHero].head;
				//equipList.equipInList[equipAll][2] = 1;
				//equipList.equipInListCount ++;
				equipAll ++;
			}
		}
		fighthero[selectedFightHero].head = tmp;
	}
	else if(equipList.equipInList[selectedGood][0] == 2)
	{
		tmp = equipList.equipInList[selectedGood][1];
		if(fighthero[selectedFightHero].body != 0)
		{
			tmp1 = fighthero[selectedFightHero].body;
			//20160305增加检测是否已有该装备可重叠
			int pos = equipList.CheckGoodExistReturnPos(2,fighthero[selectedFightHero].body);
			if(pos)
			{
				pos--;
				equipList.equipInList[pos][2] ++;
			}
			else
			{
				equipList.Add(2,fighthero[selectedFightHero].body,1);
				//equipList.equipInList[equipAll][0] = 2;
				//equipList.equipInList[equipAll][1] = fighthero[selectedFightHero].body;
				//equipList.equipInList[equipAll][2] = 1;
				//equipList.equipInListCount ++;
				equipAll ++;
			}
		}
		fighthero[selectedFightHero].body = tmp;
	}
	else if(equipList.equipInList[selectedGood][0] == 3)
	{
		tmp = equipList.equipInList[selectedGood][1];
		if(fighthero[selectedFightHero].foot != 0)
		{
			tmp1 = fighthero[selectedFightHero].foot;
			//20160305增加检测是否已有该装备可重叠
			int pos = equipList.CheckGoodExistReturnPos(3,fighthero[selectedFightHero].foot);
			if(pos)
			{
				pos--;
				equipList.equipInList[pos][2] ++;
			}
			else
			{
				equipList.Add(3,fighthero[selectedFightHero].foot,1);
				//equipList.equipInList[equipAll][0] = 3;
				//equipList.equipInList[equipAll][1] = fighthero[selectedFightHero].foot;
				//equipList.equipInList[equipAll][2] = 1;
				//equipList.equipInListCount ++;
				equipAll ++;
			}
		}
		fighthero[selectedFightHero].foot = tmp;
	}
	else if(equipList.equipInList[selectedGood][0] == 4)
	{
		tmp = equipList.equipInList[selectedGood][1];
		if(fighthero[selectedFightHero].shoulder != 0)
		{
			tmp1 = fighthero[selectedFightHero].shoulder;
			//20160305增加检测是否已有该装备可重叠
			int pos = equipList.CheckGoodExistReturnPos(4,fighthero[selectedFightHero].shoulder);
			if(pos)
			{
				pos--;
				equipList.equipInList[pos][2] ++;
			}
			else
			{
				equipList.Add(4,fighthero[selectedFightHero].shoulder,1);
				//equipList.equipInList[equipAll][0] = 4;
				//equipList.equipInList[equipAll][1] = fighthero[selectedFightHero].shoulder;
				//equipList.equipInList[equipAll][2] = 1;
				//equipList.equipInListCount ++;
				equipAll ++;
			}
		}
		fighthero[selectedFightHero].shoulder = tmp;
	}
	else if(equipList.equipInList[selectedGood][0] == 5)
	{
		tmp = equipList.equipInList[selectedGood][1];
		if(fighthero[selectedFightHero].sleeve != 0)
		{
			tmp1 = fighthero[selectedFightHero].sleeve;
			//20160305增加检测是否已有该装备可重叠
			int pos = equipList.CheckGoodExistReturnPos(5,fighthero[selectedFightHero].sleeve);
			if(pos)
			{
				pos--;
				equipList.equipInList[pos][2] ++;
			}
			else
			{
				equipList.Add(5,fighthero[selectedFightHero].sleeve,1);
				//equipList.equipInList[equipAll][0] = 5;
				//equipList.equipInList[equipAll][1] = fighthero[selectedFightHero].sleeve;
				//equipList.equipInList[equipAll][2] = 1;
				//equipList.equipInListCount ++;
				equipAll ++;
			}
		}
		fighthero[selectedFightHero].sleeve = tmp;
	}
	else if(equipList.equipInList[selectedGood][0] == 6 && flagDecorate == 1)
	{
		tmp = equipList.equipInList[selectedGood][1];
		if(fighthero[selectedFightHero].decorate1 != 0)
		{
			tmp1 = fighthero[selectedFightHero].decorate1;
			//20160305增加检测是否已有该装备可重叠
			int pos = equipList.CheckGoodExistReturnPos(6,fighthero[selectedFightHero].decorate1);
			if(pos)
			{
				pos--;
				equipList.equipInList[pos][2] ++;
			}
			else
			{
				equipList.Add(6,fighthero[selectedFightHero].decorate1,1);
				//equipList.equipInList[equipAll][0] = 6;
				//equipList.equipInList[equipAll][1] = fighthero[selectedFightHero].decorate1;
				//equipList.equipInList[equipAll][2] = 1;
				//equipList.equipInListCount ++;
				equipAll ++;
			}
		}
		fighthero[selectedFightHero].decorate1 = tmp;

		//20161231新增设置合体法术
		if(equipList.good[5][tmp-1].allMagic >0 )
		{
			fighthero[selectedFightHero].togethermagic = equipList.good[5][tmp-1].allMagic;
		}
		

	}
	else if(equipList.equipInList[selectedGood][0] == 6 && flagDecorate == 2)
	{
		tmp = equipList.equipInList[selectedGood][1];
		if(fighthero[selectedFightHero].decorate2 != 0)
		{
			tmp1 = fighthero[selectedFightHero].decorate2;
			//20160305增加检测是否已有该装备可重叠
			int pos = equipList.CheckGoodExistReturnPos(6,fighthero[selectedFightHero].decorate2);
			if(pos)
			{
				pos--;
				equipList.equipInList[pos][2] ++;
			}
			else
			{
				equipList.Add(6,fighthero[selectedFightHero].decorate2,1);
				//equipList.equipInList[equipAll][0] = 6;
				//equipList.equipInList[equipAll][1] = fighthero[selectedFightHero].decorate2;
				//equipList.equipInList[equipAll][2] = 1;
				//equipList.equipInListCount ++;
				equipAll ++;
			}
		}
		fighthero[selectedFightHero].decorate2 = tmp;

		//20161231新增设置合体法术
		if(equipList.good[5][tmp-1].allMagic >0 )
		{
			fighthero[selectedFightHero].togethermagic = equipList.good[5][tmp-1].allMagic;
		}
		
	}
	else if(equipList.equipInList[selectedGood][0] == 7)
	{
		tmp = equipList.equipInList[selectedGood][1];
		if(fighthero[selectedFightHero].hand != 0)
		{
			tmp1 = fighthero[selectedFightHero].hand;
			//20160305增加检测是否已有该装备可重叠
			int pos = equipList.CheckGoodExistReturnPos(7,fighthero[selectedFightHero].hand);
			if(pos)
			{
				pos--;
				equipList.equipInList[pos][2] ++;
			}
			else
			{
				equipList.Add(7,fighthero[selectedFightHero].hand,1);
				//equipList.equipInList[equipAll][0] = 7;
				//equipList.equipInList[equipAll][1] = fighthero[selectedFightHero].hand;
				//equipList.equipInList[equipAll][2] = 1;
				//equipList.equipInListCount ++;
				equipAll ++;
			}
		}
		fighthero[selectedFightHero].hand = tmp;

	}
	//人物属性改变
	tmp--;
	tmp1--;
	if(goodType == 6 )//武器
	{
		fighthero[selectedFightHero].hpMax -= goodList.good[goodType][tmp1].hpmax;
		fighthero[selectedFightHero].hpMax = CheckFit(fighthero[selectedFightHero].hpMax,HPMAX);//20170111
		fighthero[selectedFightHero].mpMax -= goodList.good[goodType][tmp1].mpmax;
		fighthero[selectedFightHero].mpMax = CheckFit(fighthero[selectedFightHero].mpMax,MPMAX);//20170111
		fighthero[selectedFightHero].att -= goodList.good[goodType][tmp1].at;
		fighthero[selectedFightHero].att = CheckFit(fighthero[selectedFightHero].att,ATMAX);//20170111
		fighthero[selectedFightHero].def -= goodList.good[goodType][tmp1].df;
		fighthero[selectedFightHero].def = CheckFit(fighthero[selectedFightHero].def,DFMAX);//20170111
		fighthero[selectedFightHero].speed -= goodList.good[goodType][tmp1].speed;
		fighthero[selectedFightHero].speed = CheckFit(fighthero[selectedFightHero].speed,SPEEDMAX);//20170111
		fighthero[selectedFightHero].anima -= goodList.good[goodType][tmp1].anima;
		fighthero[selectedFightHero].anima = CheckFit(fighthero[selectedFightHero].anima,ANIMAMAX);//20170111
		fighthero[selectedFightHero].lucky -= goodList.good[goodType][tmp1].lucky;
		fighthero[selectedFightHero].lucky = CheckFit(fighthero[selectedFightHero].lucky,LUCKMAX);//20170111
		fighthero[selectedFightHero].atcause -= goodList.good[goodType][tmp1].all_dlfm_Flag;//免疫

		fighthero[selectedFightHero].hpMax += goodList.good[goodType][tmp].hpmax;
		fighthero[selectedFightHero].hpMax = CheckFit(fighthero[selectedFightHero].hpMax,HPMAX);//20170111
		fighthero[selectedFightHero].mpMax += goodList.good[goodType][tmp].mpmax;
		fighthero[selectedFightHero].mpMax = CheckFit(fighthero[selectedFightHero].mpMax,MPMAX);//20170111
		fighthero[selectedFightHero].att += goodList.good[goodType][tmp].at;
		fighthero[selectedFightHero].att = CheckFit(fighthero[selectedFightHero].att,ATMAX);//20170111
		fighthero[selectedFightHero].def += goodList.good[goodType][tmp].df;
		fighthero[selectedFightHero].def = CheckFit(fighthero[selectedFightHero].def,DFMAX);//20170111
		fighthero[selectedFightHero].speed += goodList.good[goodType][tmp].speed;
		fighthero[selectedFightHero].speed = CheckFit(fighthero[selectedFightHero].speed,SPEEDMAX);//20170111
		fighthero[selectedFightHero].anima += goodList.good[goodType][tmp].anima;
		fighthero[selectedFightHero].anima = CheckFit(fighthero[selectedFightHero].anima,ANIMAMAX);//20170111
		fighthero[selectedFightHero].lucky += goodList.good[goodType][tmp].lucky;
		fighthero[selectedFightHero].lucky = CheckFit(fighthero[selectedFightHero].lucky,LUCKMAX);//20170111
		fighthero[selectedFightHero].atcause += goodList.good[goodType][tmp].all_dlfm_Flag;//免疫
	}
	else if(goodType == 5 )//饰品
	{
		fighthero[selectedFightHero].hpAdd -= goodList.good[goodType][tmp1].hp;
		fighthero[selectedFightHero].hpAdd = CheckFit(fighthero[selectedFightHero].hpAdd,HPMAX);//20170111
		fighthero[selectedFightHero].mpAdd -= goodList.good[goodType][tmp1].mp;
		fighthero[selectedFightHero].mpAdd = CheckFit(fighthero[selectedFightHero].mpAdd,MPMAX);//20170111
		fighthero[selectedFightHero].att -= goodList.good[goodType][tmp1].at;
		fighthero[selectedFightHero].att = CheckFit(fighthero[selectedFightHero].att,ATMAX);//20170111
		fighthero[selectedFightHero].def -= goodList.good[goodType][tmp1].df;
		fighthero[selectedFightHero].def = CheckFit(fighthero[selectedFightHero].def,DFMAX);//20170111
		fighthero[selectedFightHero].speed -= goodList.good[goodType][tmp1].speed;
		fighthero[selectedFightHero].speed = CheckFit(fighthero[selectedFightHero].speed,SPEEDMAX);//20170111
		fighthero[selectedFightHero].anima -= goodList.good[goodType][tmp1].anima;
		fighthero[selectedFightHero].anima = CheckFit(fighthero[selectedFightHero].anima,ANIMAMAX);//20170111
		fighthero[selectedFightHero].lucky -= goodList.good[goodType][tmp1].lucky;
		fighthero[selectedFightHero].lucky = CheckFit(fighthero[selectedFightHero].lucky,LUCKMAX);//20170111
		fighthero[selectedFightHero].togethermagic = goodList.good[goodType][tmp1].allMagic;

		fighthero[selectedFightHero].hpAdd += goodList.good[goodType][tmp].hp;
		fighthero[selectedFightHero].hpAdd = CheckFit(fighthero[selectedFightHero].hpAdd,HPMAX);//20170111
		fighthero[selectedFightHero].mpAdd += goodList.good[goodType][tmp].mp;
		fighthero[selectedFightHero].mpAdd = CheckFit(fighthero[selectedFightHero].mpAdd,MPMAX);//20170111
		fighthero[selectedFightHero].att += goodList.good[goodType][tmp].at;
		fighthero[selectedFightHero].att = CheckFit(fighthero[selectedFightHero].att,ATMAX);//20170111
		fighthero[selectedFightHero].def += goodList.good[goodType][tmp].df;
		fighthero[selectedFightHero].def = CheckFit(fighthero[selectedFightHero].def,DFMAX);//20170111
		fighthero[selectedFightHero].speed += goodList.good[goodType][tmp].speed;
		fighthero[selectedFightHero].speed = CheckFit(fighthero[selectedFightHero].speed,SPEEDMAX);//20170111
		fighthero[selectedFightHero].anima += goodList.good[goodType][tmp].anima;
		fighthero[selectedFightHero].anima = CheckFit(fighthero[selectedFightHero].anima,ANIMAMAX);//20170111
		fighthero[selectedFightHero].lucky += goodList.good[goodType][tmp].lucky;
		fighthero[selectedFightHero].lucky = CheckFit(fighthero[selectedFightHero].lucky,LUCKMAX);//20170111
		fighthero[selectedFightHero].togethermagic = goodList.good[goodType][tmp].allMagic;
	}
	else
	{
		fighthero[selectedFightHero].hpMax -= goodList.good[goodType][tmp1].hpmax;
		fighthero[selectedFightHero].hpMax = CheckFit(fighthero[selectedFightHero].hpMax,HPMAX);//20170111
		fighthero[selectedFightHero].mpMax -= goodList.good[goodType][tmp1].mpmax;
		fighthero[selectedFightHero].mpMax = CheckFit(fighthero[selectedFightHero].mpMax,MPMAX);//20170111
		fighthero[selectedFightHero].att -= goodList.good[goodType][tmp1].at;
		fighthero[selectedFightHero].att = CheckFit(fighthero[selectedFightHero].att,ATMAX);//20170111
		fighthero[selectedFightHero].def -= goodList.good[goodType][tmp1].df;
		fighthero[selectedFightHero].def = CheckFit(fighthero[selectedFightHero].def,DFMAX);//20170111
		fighthero[selectedFightHero].speed -= goodList.good[goodType][tmp1].speed;
		fighthero[selectedFightHero].speed = CheckFit(fighthero[selectedFightHero].speed,SPEEDMAX);//20170111
		fighthero[selectedFightHero].anima -= goodList.good[goodType][tmp1].anima;
		fighthero[selectedFightHero].anima = CheckFit(fighthero[selectedFightHero].anima,ANIMAMAX);//20170111
		fighthero[selectedFightHero].lucky -= goodList.good[goodType][tmp1].lucky;
		fighthero[selectedFightHero].lucky = CheckFit(fighthero[selectedFightHero].lucky,LUCKMAX);//20170111
		fighthero[selectedFightHero].anti -= goodList.good[goodType][tmp1].all_dlfm_Flag;//免疫

		fighthero[selectedFightHero].hpMax += goodList.good[goodType][tmp].hpmax;
		fighthero[selectedFightHero].hpMax = CheckFit(fighthero[selectedFightHero].hpMax,HPMAX);//20170111
		fighthero[selectedFightHero].mpMax += goodList.good[goodType][tmp].mpmax;
		fighthero[selectedFightHero].mpMax = CheckFit(fighthero[selectedFightHero].mpMax,MPMAX);//20170111
		fighthero[selectedFightHero].att += goodList.good[goodType][tmp].at;
		fighthero[selectedFightHero].att = CheckFit(fighthero[selectedFightHero].att,ATMAX);//20170111
		fighthero[selectedFightHero].def += goodList.good[goodType][tmp].df;
		fighthero[selectedFightHero].def = CheckFit(fighthero[selectedFightHero].def,DFMAX);//20170111
		fighthero[selectedFightHero].speed += goodList.good[goodType][tmp].speed;
		fighthero[selectedFightHero].speed = CheckFit(fighthero[selectedFightHero].speed,SPEEDMAX);//20170111
		fighthero[selectedFightHero].anima += goodList.good[goodType][tmp].anima;
		fighthero[selectedFightHero].anima = CheckFit(fighthero[selectedFightHero].anima,ANIMAMAX);//20170111
		fighthero[selectedFightHero].lucky += goodList.good[goodType][tmp].lucky;
		fighthero[selectedFightHero].lucky = CheckFit(fighthero[selectedFightHero].lucky,LUCKMAX);//20170111
		fighthero[selectedFightHero].anti += goodList.good[goodType][tmp].all_dlfm_Flag;//免疫
	}

	//roleList.actor[selectedRole].att += goodList.good[1][selectedGood].at;

	int ret = equipList.Del_t(goodType+1,goodIdx+1,1);
	if(ret == 1)equipAll--;
	if(goodType == 6)//武器
	{
		ret = throwList.Del_t(goodType+1,goodIdx+1,1);
		if(ret == 1)throwAll --;
	}


	/*for(int i = selectedGood ; i<equipAll;i++)//删除链中道具
	{
	equipList.equipInList[i][0] = equipList.equipInList[i+1][0];
	equipList.equipInList[i][1] = equipList.equipInList[i+1][1];
	equipList.equipInList[i][2] = equipList.equipInList[i+1][2];
	}

	equipAll --;*/

	selectedFightHero = s_selectedFightHero;
}

int Fight::FightRun()
{
	wlogfile(1, __FUNCTION__ ,"开始",0);
	int fightObjectMax = 0;
	int tmpOrder[6];//从小到大
	int tmpSpeed[6];//从小到大
	int fightSpeed[6];//从大到小 有效
	int fightIdxOrder[6];//从大到小 有效
	int tmp = 0;
	int hurt = 0;//伤害值
	int attObjId=0;//selectedFightEnemy+3;//0;//攻击对象id 6个;
	int hurtFlag = 0;
	int recoverFlag = 0;
	int buffFlag = 0;//持续时间
	int debuffFlag = 0;//持续时间
	int buffFlag1 = 0;//20160317  全攻2防2速2 1999999
	int debuffFlag1 = 0;//20160317 全毒乱封眠11111
	int reverse = 0;//20160625 用于区分buffFlag1的作用为我方增益还是敌方减弱
	int reverse1 = 0;//20160702 用于区分debuffFlag1的作用为我方异常清除还是敌方减弱

	int rndComp = 50;//获得异常效果的概率

	//需注意。玩家最多3个 怪物也是3个，因此要对整体做处理
	//根据身法判断先手
	//循环进行排序 取6个身法值

	int returnValue = 0;
	isFightRuned = 1;
	currentRound++;
	for(int i = 0 ;i< 6;i++)
	{
		tmpSpeed[i] = -1;//20161126
		fightSpeed[i]= 0;
		tmpOrder[i]=0;
	}

	//初始化值
	for(int i = 0 ;i< actorSum;i++)
	{
		tmpSpeed[i] = fighthero[i].speed;
		if(fighthero[i].speedeffect%100>0)
		{
			tmpSpeed[i] = tmpSpeed[i]*(100+fighthero[i].speedeffect%100)/100;
			fighthero[i].speedeffect-=100;
			if(fighthero[i].speedeffect<0)fighthero[i].speedeffect=0;
		}
		if(fighthero[i].speedeffect%100<0)
		{
			tmpSpeed[i] = tmpSpeed[i]*(100-fighthero[i].speedeffect%100)/100;
			fighthero[i].speedeffect+=100;
			if(fighthero[i].speedeffect>0)fighthero[i].speedeffect=0;
		}
		tmpOrder[i] = i;
	}
	for(int i = 0 ;i< 3;i++)
	{
		tmpSpeed[i+3] = fightEnemy[i].speed;
		if(fightEnemy[i].speedeffect%100>0)
		{
			tmpSpeed[i+3] = tmpSpeed[i+3]*(100+fightEnemy[i].speedeffect%100)/100;//20181230 i->i+3
			fightEnemy[i].speedeffect-=100;
			if(fighthero[i].speedeffect<0)fightEnemy[i].speedeffect=0;
		}
		if(fightEnemy[i].speedeffect%100<0)
		{
			tmpSpeed[i+3] = tmpSpeed[i+3]*(100-fightEnemy[i].speedeffect%100)/100;//20181230 i->i+3
			fightEnemy[i].speedeffect+=100;
			if(fighthero[i].speedeffect>0)fightEnemy[i].speedeffect=0;
		}
		tmpOrder[i+3] = i+3;
	}

	for(int i=0;i<5;i++)
	{
		for(int j=i+1;j<6;j++)   
			if(tmpSpeed[i]>tmpSpeed[j])
			{
				tmp=tmpSpeed[i];
				tmpSpeed[i]=tmpSpeed[j];
				tmpSpeed[j]=tmp;

				tmp=tmpOrder[i];
				tmpOrder[i]=tmpOrder[j];
				tmpOrder[j]=tmp;
			}

	} 
	int k = 0;
	fightObjectMax = 6;
	for(int i = 5 ; i >= 0 ;i--)
	{
		if(tmpSpeed[i] < 0)
		{
			fightObjectMax = 5-i;
			break;
		}
		fightSpeed[5-i] = tmpSpeed[i];
		fightIdxOrder[5-i] = tmpOrder[i];
	}

	//20160305增加 对g_型变量操作
	for(int i = 0 ; i < 3 ;i ++)
	{
		g_selectedFightStyle[i] = selectedFightTypeConfirmed[i];
		g_selectedEnemyId[i] = selectedFightEnemy[i];
		g_selectedGood[i][0] = selectedGood1[i][0];
		g_selectedGood[i][1] = selectedGood1[i][1];
		g_selectedMagic[i]= selectedMagic[i];

	}

	//循环执行下面代码
	for(int i = 0 ;i < fightObjectMax;i++)
	{
		hurt = 0;//伤害值
		attObjId=0;//selectedFightEnemy+3;//0;//攻击对象id 6个;
		hurtFlag = 0;
		recoverFlag = 0;
		buffFlag = 0;//持续时间
		debuffFlag = 0;//持续时间
		buffFlag1 = 0;//20160317  全攻2防2速2 1999999
		debuffFlag1 = 0;//20160317 全毒乱封眠11111
		reverse = 0;//20160625 0-我方 1-敌方
		int j = 0;
		/*for(j = 0 ;j< 6 ; j++)
		{
		if(fightSpeed[i] == originalSpeed[j])break;//获取到对应是哪个obj
		}*/

		int ret = CheckWinLose();//1-赢 2-输 -1-到回合//20170107增加检查输赢
		if(ret)
		{
			returnValue = ret;
			isFightRuned = 0;
			return returnValue;
		}

		j = fightIdxOrder[i];

		//if(j>=3&&(j-3)>=enemySum)continue;
		if( j< 3)//0-2玩家
		{


			//20160317增加对
			if(flagDied[j])continue; 


			//at玩家
			attObjId=selectedFightEnemy[j]+3;//包含玩家和敌人 0-2需进行区分

			CountSpecialRecover(j);//20160702每回合恢复处理
			CountDLFMStatusHurt(j);//计算特殊状态伤害并显示


			//伤害计算
			if(selectedFightTypeConfirmed[j] == 9)//休眠20160626下一个
			{
				continue;
			}
			if(fighthero[j].mian>0)//休眠20160630
			{
				selectedFightTypeConfirmed[j] = 9;
				continue;
			}
			if(fighthero[j].ruan>0)
			{
				selectedFightTypeConfirmed[j] = 10;//乱
			}

			if(fighthero[j].feng>0&&selectedFightTypeConfirmed[j]==2)//20160627
			{
				selectedFightTypeConfirmed[j] = 1;//封禁转普通攻击
				if(attObjId<3)//20160719增加玩家判断
				{
					GetTmpEnemy(4);
					attObjId = tmpselectedEnemy;
				}

			}

			if(selectedFightTypeConfirmed[j] == 8 && flagLeave[j] == 1)//逃跑无攻击伤害 成功
			{
				ShowAct(j,attObjId,6);
				selectedFightTypeConfirmed[j] = 0;
				isFightRuned = 0;
				return 0 ;
			}
			if(selectedFightTypeConfirmed[j] == 8 && flagLeave[j] == 2)//逃跑无攻击伤害 失败
			{
				ShowAct(j,attObjId,7);
				selectedFightTypeConfirmed[j] = 0;
			}

			if(fightEnemy[attObjId-3].hp == 0 && CheckTo(j)==0)//选择新目标  CheckTo()==0敌人  CheckTo()==1 补给
			{
				GetTmpEnemy(4);
				if(tmpselectedEnemy == -1)//全部死亡,胜利
				{
					int ret = CheckWinLose();//1-赢 2-输 -1-到回合
					if(ret)
					{
						returnValue = ret;
						isFightRuned = 0;
						return returnValue;
					}
				}
				attObjId = tmpselectedEnemy + 3;
			}

			//20160701检测道具可用
			if(selectedFightTypeConfirmed[j] == 5)//投掷
			{
				if(!throwList.CheckGoodExistReturnPos(selectedGood1[j][0],selectedGood1[j][1]))
				{
					if(fightEnemy[attObjId-3].hp<=0)//20160701//20170116修正attObjId-3
					{
						attObjId = livedEnemy[0]+3;//20170116修正+3
						selectedFightEnemy[j] = livedEnemy[0];//20160701
					}
				}
			}
			if(selectedFightTypeConfirmed[j] == 6)//使用
			{
				if(!goodList.CheckGoodExistReturnPos(selectedGood1[j][0],selectedGood1[j][1]))
				{
					selectedFightEnemy[j] = livedEnemy[0];//20160701
					attObjId = livedEnemy[0]+3;//20160701
				}
			}

			for(int i = 0 ;i< 3;i++)//20160718移动
			{
				s_hurt[i] = 0;
				//c_hurt[i] = 0;
			}

			hurt = CountHurt(j,attObjId,selectedFightTypeConfirmed[j]);//玩家
			s_hurt[attObjId%3]=hurt;//20160718

			//玩家行为图片播放 攻打 施法等等
			int tret = 0;
			if(selectedFightTypeConfirmed[j]==1 && returnValue ==0)tret = ShowAct(j,attObjId,0);//j att 1-6
			if(selectedFightTypeConfirmed[j]==2 && returnValue ==0)tret = ShowAct(j,attObjId,1);//j att 1-6
			if(selectedFightTypeConfirmed[j]==3 && returnValue ==0)tret = ShowAct(j,attObjId,9);//j att 1-6 9-合击位置
			if(selectedFightTypeConfirmed[j]==4 && returnValue ==0)tret = ShowAct(j,attObjId,0);//j att 1-6
			if(selectedFightTypeConfirmed[j]==5 && returnValue ==0)tret = ShowAct(j,attObjId,1);//j att 1-6
			if(selectedFightTypeConfirmed[j]==6 && returnValue ==0)tret = ShowAct(j,attObjId,1);//j att 1-6
			if(selectedFightTypeConfirmed[j]==7 && returnValue ==0)tret = ShowAct(j,attObjId,2);//20160818 防御
			if(selectedFightTypeConfirmed[j]==10 && returnValue ==0)tret = ShowAct(j,attObjId,8);//j att 1-6
			if(tret == -1)returnValue = -10;
			//法术行为CG播放
			if(selectedFightTypeConfirmed[j] == 2)
			{
				int tpMagicPic = magicList[j].magic[selectedMagic[j]].picnum;
				ShowFightActorPic(j);
				int offsetx = 0;
				int offsety = 0;


				if(magicList[j].magic[selectedMagic[j]].type == 1||magicList[j].magic[selectedMagic[j]].type == 5 )
				{
					if(magicList[j].magic[selectedMagic[j]].last_all>127)//20160704全体
					{
						offsetx = -15;
						offsety = -30;
					}
					else
					{
						offsetx = (attObjId - 3)*35-50;
						offsety = -30-(attObjId%3)*5;
					}
				}
				else
				{
					if(magicList[j].magic[selectedMagic[j]].last_all>127)//20160704全体
					{
						offsetx = 35;
						offsety = 0;
					}
					else
					{
						offsetx = selectedFightEnemy[j]*35;
						offsety = -j*5;//20160818
					}
				}

				ShowCG(2,tpMagicPic,0,0,9,offsetx,offsety);

			}
			if(selectedFightTypeConfirmed[j] == 3)
			{
				int tpMagicPic = magicList[j].magic[fighthero[j].togethermagic].picnum;
				ShowFightActorPic(j);
				if(tpMagicPic>0)//20181103
				{
					ShowCG(2,tpMagicPic,0,0,9,-30,-20);
				}
			}
			if(selectedFightTypeConfirmed[j] == 5)//投掷
			{
				int tp = selectedGood1[j][0]-1;//20160704
				int id = selectedGood1[j][1]-1;
				int tpMagicPic = throwList.good[tp][id].movieNo;
				//ShowFightActorPic(j);
				int offsetx = 0;
				int offsety = 0;

				if(throwList.good[tp][id].all_dlfm_Flag>127)//20160704全体
				{
					offsetx = -15;
					offsety = -30;
				}
				else
				{
					offsetx = (attObjId - 3)*35-50;
					offsety = -30;
				}
				ShowCG(2,tpMagicPic,0,0,9,offsetx,offsety);
			}

			//判断攻击 回血 buff 异常标志
			if(selectedFightTypeConfirmed[j] == 1||selectedFightTypeConfirmed[j] == 4)
			{
				hurtFlag = 1;
				if(goodList.good[6][fighthero[j].hand-1].all_dlfm_Flag > 15)
				{
					hurtFlag = 2;
				}
				//20160829增加判断武器异常效果
				if(goodList.good[6][fighthero[j].hand-1].all_dlfm_Flag)
				{
					debuffFlag1 = 0;
					if(goodList.good[6][fighthero[j].hand-1].all_dlfm_Flag>15)
					{
						debuffFlag1 =10000;
					}

					//20181021 将角色anti的判断转移到givebuff中
                    if(goodList.good[6][fighthero[j].hand-1].all_dlfm_Flag%16/8==1)//20170110
					{
						if(rand()%100>rndComp)debuffFlag1+=1000;
					}
                    if(goodList.good[6][fighthero[j].hand-1].all_dlfm_Flag%8/4==1)//20170110
					{
						if(rand()%100>rndComp)debuffFlag1+=100;
					}
                    if(goodList.good[6][fighthero[j].hand-1].all_dlfm_Flag%4/2==1)//20170110
					{
						if(rand()%100>rndComp)debuffFlag1+=10;
					}
                    if(goodList.good[6][fighthero[j].hand-1].all_dlfm_Flag%2==1)//20170110
					{
						if(rand()%100>rndComp)debuffFlag1+=1;
					}
					debuffFlag = goodList.good[6][fighthero[j].hand-1].last;//持续回合
				}
			}
			else if(selectedFightTypeConfirmed[j] == 10)
			{
				hurtFlag = 1;
				attObjId = j;
			}
			else if(selectedFightTypeConfirmed[j] == 2)
			{
				if(magicList[j].magic[selectedMagic[j]].type == 1)
				{
					hurtFlag = 1;
					if(magicList[j].magic[selectedMagic[j]].last_all>127)//20160317 15->127
					{
						hurtFlag = 2;
					}
					if(magicList[j].magic[selectedMagic[j]].hp<0)
					{
						recoverFlag = 11;//20181230
					}
					if(magicList[j].magic[selectedMagic[j]].dlfmFlag)
					{
						debuffFlag1 = 0;//20160317
						if(magicList[j].magic[selectedMagic[j]].last_all>127)
						{
							debuffFlag1 =10000;
						}

						//20181021 将角色anti的判断转移到givebuff中
						//20160317 对效果的描述   20160627修正错误
						if(magicList[j].magic[selectedMagic[j]].dlfmFlag%16/8==1)//20170107
						{
							if(rand()%100>rndComp)debuffFlag1+=1000;
						}
                        if(magicList[j].magic[selectedMagic[j]].dlfmFlag%8/4==1)//20170107
						{
							if(rand()%100>rndComp)debuffFlag1+=100;
						}
                        if(magicList[j].magic[selectedMagic[j]].dlfmFlag%4/2==1)//20170107
						{
							if(rand()%100>rndComp)debuffFlag1+=10;
						}
                        if(magicList[j].magic[selectedMagic[j]].dlfmFlag%2==1)//20170107
						{
							if(rand()%100>rndComp)debuffFlag1+=1;
						}
						debuffFlag = magicList[j].magic[selectedMagic[j]].last_all%128;//持续回合数
					}
					//20160625 攻速防
					if(magicList[j].magic[selectedMagic[j]].last_all>127)
					{
						reverse = 1;
						buffFlag1 = 1000000;
					}
					if(magicList[j].magic[selectedMagic[j]].at>0)
					{
						reverse = 1;
						buffFlag1+=(magicList[j].magic[selectedMagic[j]].at==100?99:magicList[j].magic[selectedMagic[j]].at)*10000;
					}
					if(magicList[j].magic[selectedMagic[j]].df>0)
					{
						reverse = 1;
						buffFlag1+=(magicList[j].magic[selectedMagic[j]].df==100?99:magicList[j].magic[selectedMagic[j]].df)*100;
					}
					if(magicList[j].magic[selectedMagic[j]].speed>0)
					{
						reverse = 1;
						buffFlag1+=(magicList[j].magic[selectedMagic[j]].speed==100?99:magicList[j].magic[selectedMagic[j]].speed)*1;

					}
					buffFlag = magicList[j].magic[selectedMagic[j]].last_all%128;//持续回合数//20181021修改debufflag为buffflag



				}
				if(magicList[j].magic[selectedMagic[j]].type == 2)//增强
				{
					buffFlag1 = 0;//20160317 
					//攻防速
					if(magicList[j].magic[selectedMagic[j]].last_all>127)
					{
						buffFlag1 = 1000000;
					}
					//20160317 对效果的描述 
					if(magicList[j].magic[selectedMagic[j]].at>0)
					{
						buffFlag1+=(magicList[j].magic[selectedMagic[j]].at==100?99:magicList[j].magic[selectedMagic[j]].at)*10000;
					}
					if(magicList[j].magic[selectedMagic[j]].df>0)
					{
						buffFlag1+=(magicList[j].magic[selectedMagic[j]].df==100?99:magicList[j].magic[selectedMagic[j]].df)*100;
					}
					if(magicList[j].magic[selectedMagic[j]].speed>0)
					{
						buffFlag1+=(magicList[j].magic[selectedMagic[j]].speed==100?99:magicList[j].magic[selectedMagic[j]].speed)*1;
					}

					buffFlag = magicList[j].magic[selectedMagic[j]].last_all%128;//持续回合数
				}
				if(magicList[j].magic[selectedMagic[j]].type == 3)//恢复
				{

					recoverFlag = 1;
					if(magicList[j].magic[selectedMagic[j]].last_all > 127)//20160718 修正bug
					{
						recoverFlag = 2;
					}

					buffFlag1 = 0;//20160317 
					if(magicList[j].magic[selectedMagic[j]].dlfmFlag)//20160702 设置是否消除自身异常状态
					{
						debuffFlag1 = 0;//20160317
						if(magicList[j].magic[selectedMagic[j]].last_all>127)
						{
							debuffFlag1 =10000;
							reverse1 = 1;
						}

						//20160317 对效果的描述   20160627修正错误
						if(magicList[j].magic[selectedMagic[j]].dlfmFlag%16/8==1)
						{
							debuffFlag1+=1000;
							reverse1 = 1;
						}
						if(magicList[j].magic[selectedMagic[j]].dlfmFlag%8/4==1)
						{
							debuffFlag1+=100;
							reverse1 = 1;
						}
						if(magicList[j].magic[selectedMagic[j]].dlfmFlag%4/2==1)
						{
							debuffFlag1+=10;
							reverse1 = 1;
						}
						if(magicList[j].magic[selectedMagic[j]].dlfmFlag%2==1)
						{
							debuffFlag1+=1;
							reverse1 = 1;
						}
						debuffFlag = magicList[j].magic[selectedMagic[j]].last_all%128;//持续回合数
					}



				}
				if(magicList[j].magic[selectedMagic[j]].type == 4)//辅助
				{
					recoverFlag = 1;
					if(magicList[j].magic[selectedMagic[j]].last_all>127)
					{
						recoverFlag = 2;
					}
				}
				//20160704妙手空空 20170110移动
				if(magicList[j].magic[selectedMagic[j]].type == 5)
				{
					selectedMagic[j] = 0;
					hurt = 0;
					//检测敌人所带物品
					if(fightEnemy[attObjId-3].goods1idx>0&&fightEnemy[attObjId-3].goods1num>0&&fightEnemy[attObjId-3].goods1type>0)
					{
						int maxlucky = fighthero[j].lucky;
						int rnd = rand()%100;
						if(rnd < maxlucky)
						{
							if(goodHave[(attObjId-3)*2][0]>8)//20170110修正物品不合并
							{
								goodList.Add(goodHave[(attObjId-3)*2][0],goodHave[(attObjId-3)*2][1],1);
							}
							else if(goodHave[(attObjId-3)*2][0] == 8)
							{
								throwList.Add(goodHave[(attObjId-3)*2][0],goodHave[(attObjId-3)*2][1],1);
							}
							else
							{
								equipList.Add(goodHave[(attObjId-3)*2][0],goodHave[(attObjId-3)*2][1],1);
							}

						
							char tmp[20];
							sprintf_s(tmp,"得到  %s×1",goodList.good[goodHave[(attObjId-3)*2][0]-1][goodHave[(attObjId-3)*2][1]-1].name);
							TimerMessage(tmp,12,37,8,1,3000);
							goodHave[(attObjId-3)*2][2]--;
							fightEnemy[attObjId-3].goods1num--;
						}
					}
				}

			}
			else if(selectedFightTypeConfirmed[j] == 3)//合击
			{
				hurtFlag = 1;
			}
			else if(selectedFightTypeConfirmed[j] == 5)//投掷
			{
				hurtFlag = 1;
				int tp = selectedGood1[j][0]-1;
				int id = selectedGood1[j][1]-1;
				if(throwList.good[tp][id].all_dlfm_Flag > 15)
				{
					hurtFlag = 2;
				}
				if(throwList.good[tp][id].hp < 0)
				{
					recoverFlag = 1;

				}
				if(throwList.good[tp][id].all_dlfm_Flag%16>0)//20160702
				{
					debuffFlag1 = 0;//20160317
					if(throwList.good[tp][id].all_dlfm_Flag > 15)
					{
						debuffFlag1 =10000;

					}
					//20181021 将角色anti的判断转移到givebuff中
					//20160317 对效果的描述   20160627修正错误
					if(throwList.good[tp][id].all_dlfm_Flag%16/8==1)
					{
						debuffFlag1+=1000;
					}
                    if(throwList.good[tp][id].all_dlfm_Flag%8/4==1)
					{
						debuffFlag1+=100;
					}
                    if(throwList.good[tp][id].all_dlfm_Flag%4/2==1)
					{
						debuffFlag1+=10;
					}
                    if(throwList.good[tp][id].all_dlfm_Flag%2==1)
					{
						debuffFlag1+=1;
					}
					debuffFlag = throwList.good[tp][id].last;//持续回合数
				}

			}
			else if(selectedFightTypeConfirmed[j] == 6)//补给自己
			{

				int tp = selectedGood1[j][0]-1;
				int id = selectedGood1[j][1]-1;

				if(tp==11)//兴奋剂 20160702
				{
					buffFlag1 = 0;//20160317 
					if(goodList.good[tp][id].last>0)
					{
						buffFlag1 = 1000000;
					}
					//20160317 对效果的描述 
					if(goodList.good[tp][id].at>0)
					{
						buffFlag1+=(goodList.good[tp][id].at==100?99:goodList.good[tp][id].at)*10000;
					}
					if(magicList[j].magic[selectedMagic[j]].df>0)
					{
						buffFlag1+=(goodList.good[tp][id].df==100?99:goodList.good[tp][id].df)*100;
					}
					if(magicList[j].magic[selectedMagic[j]].speed>0)
					{
						buffFlag1+=(goodList.good[tp][id].speed==100?99:goodList.good[tp][id].speed)*1;
					}

					buffFlag = goodList.good[tp][id].last;//持续回合数
				}
				else if(tp==10)//仙药加上限 20160702
				{
					fighthero[j].hpMax+=goodList.good[tp][id].hp;
					fighthero[j].mpMax+=goodList.good[tp][id].mp;
					fighthero[j].att+=goodList.good[tp][id].at;
					fighthero[j].def+=goodList.good[tp][id].df;
					fighthero[j].speed+=goodList.good[tp][id].speed;
					fighthero[j].anima+=goodList.good[tp][id].anima;
					fighthero[j].lucky+=goodList.good[tp][id].lucky;
				}
				else if(tp==9)//灵药  20160702
				{
					recoverFlag = 1;
					if(goodList.good[tp][id].all_dlfm_Flag>15)
					{
						recoverFlag = 2;
					}
				}
				else if(tp==8)//药品
				{
					recoverFlag = 1;
					if(goodList.good[tp][id].all_dlfm_Flag > 15)
					{
						recoverFlag = 2;
					}

					//20170319
					debuffFlag1 = 0;//20160317
					if(goodList.good[tp][id].all_dlfm_Flag > 15)
					{
						debuffFlag1 =10000;
						reverse1 = 1;
					}

					//20160317 对效果的描述   20160627修正错误
					if(goodList.good[tp][id].all_dlfm_Flag %16/8==1)
					{
						debuffFlag1+=1000;
						reverse1 = 1;
					}
					if(goodList.good[tp][id].all_dlfm_Flag%8/4==1)
					{
						debuffFlag1+=100;
						reverse1 = 1;
					}
					if(goodList.good[tp][id].all_dlfm_Flag%4/2==1)
					{
						debuffFlag1+=10;
						reverse1 = 1;
					}
					if(goodList.good[tp][id].all_dlfm_Flag%2==1)
					{
						debuffFlag1+=1;
						reverse1 = 1;
					}
					debuffFlag = 0;//持续回合数

				}
			}


			//伤害值显示或回血值、状态显示

			if(hurtFlag == 1)//攻击型//selectedFightStyle
			{
				ShowHurt(attObjId,hurt);//attObjId=对象编号 确定位置 hurt值
				CopyToHdc();
				Delay(500);
			}
			if(hurtFlag == 2)//全体攻击型//selectedFightStyle
			{
				for(int i = 0; i < 3;i ++)//20160706修正为3
				{
					if(flagEnemyDied[i])continue;
					if( i != (attObjId-3))
					{
						hurt = CountHurt(j,(i+3),selectedFightTypeConfirmed[j]);//玩家
						s_hurt[i] = hurt;
					}
					ShowHurt((i+3),s_hurt[i]);
				}
				CopyToHdc();
				Delay(500);
				//ShowHurt(-1,hurt);//attObjId=对象编号 确定位置 hurt值
			}
			if(recoverFlag == 11)//攻击吸血
            {
                ShowHurt(j,-abs(hurt));
                CopyToHdc();
                Delay(500);
            }
			if(recoverFlag == 1)//回血
			{
				int tp = selectedGood1[j][0]-1;
				if((attObjId-3)<0)attObjId = 3;
				if(tp == 9)//20170115
				{
					ShowHurt(attObjId-3,-abs(hurt));
				}
				else
				{
					ShowHurt(attObjId-3,-abs(hurt));//j=我方编号 确定位置 hurt值为负//20160625//20161030修正selectedFightEnemy[j]-》j//20170119修正j->attobj-3
				}
				//ShowHurt(attObjId-3,-abs(hurt));//j=我方编号 确定位置 hurt值为负
				CopyToHdc();
				Delay(500);
			}
			if(recoverFlag == 2)//全体回血
			{

				for(int i = 0; i < 3;i ++)//20160706修正为3
				{
					if(flagDied[i])continue;
					if(i != attObjId )
					{
						hurt = CountHurt(j,(i+3),selectedFightTypeConfirmed[j]);//玩家
						s_hurt[i] = hurt;
					}
					ShowHurt(i,-abs(s_hurt[i]));

				}
				CopyToHdc();
				Delay(500);
				//AddHurt(2,j);
				//ShowHurt(-1,-abs(hurt));//j=我方编号 确定位置 hurt值为负
			}
			if(buffFlag1>1000000&&reverse==0)//全体增强
			{
				GiveBuff(-1,0,buffFlag1,buffFlag);
				//20181125ShowBuff(-1,0,buffFlag1);//j=我方编号 确定位置 hurt值为负
			}
			else if(buffFlag1<1000000&&reverse==0&&buffFlag1)//增强
			{
				if((attObjId-3)<0)attObjId = 3;
				GiveBuff(attObjId-3,0,buffFlag1,buffFlag);//20161030修正selectedFightEnemy[j]-》j..20170119修正j->attObjId-3
				//20181125ShowBuff(attObjId-3,0,buffFlag1);//j=我方编号 确定位置 hurt值为负//20160625//20161030修正selectedFightEnemy[j]-》j
			}
			if(debuffFlag1>10000&&reverse1==0)//敌方全体减弱
			{
				GiveBuff(-1,1,debuffFlag1,debuffFlag);
				//20181125ShowBuff(-1,1,debuffFlag1);//j=我方编号 确定位置 hurt值为负
			}
			else if(debuffFlag1<10000&&reverse1==0&&debuffFlag1)//敌方减弱
			{
				GiveBuff(attObjId,1,debuffFlag1,debuffFlag);
				//20181125ShowBuff(attObjId,1,debuffFlag1);//j=我方编号 确定位置 hurt值为负
			}
			if(reverse==1&&buffFlag1>1000000)//敌方全体减弱
			{
				GiveBuff(-1,2,buffFlag1,debuffFlag);
				//20181125ShowBuff(-1,2,buffFlag1);//j=我方编号 确定位置 hurt值为负
			}
			else if(reverse==1&&buffFlag1<1000000&&buffFlag1)//敌方减弱
			{
				GiveBuff(attObjId,2,buffFlag1,debuffFlag);
				//20181125ShowBuff(attObjId,2,buffFlag1);//j=我方编号 确定位置 hurt值为负
			}
			if(reverse1==1&&debuffFlag1>10000)//敌方全体减弱
			{
				GiveBuff(-1,3,debuffFlag1,debuffFlag);
				//20181125ShowBuff(-1,3,debuffFlag1);//j=我方编号 确定位置 hurt值为负
			}
			else if(reverse1==1&&debuffFlag1<10000&&debuffFlag1)//敌方减弱
			{
				GiveBuff(selectedFightEnemy[j],3,debuffFlag1,debuffFlag);
				//20181125ShowBuff(selectedFightEnemy[j],3,debuffFlag1);//j=我方编号 确定位置 hurt值为负
			}

			

			//消耗处理
			if(selectedFightTypeConfirmed[j] == 2)//魔法
			{
				//前导已判够用，此处不处理
				fighthero[j].mp -= magicList[j].magic[selectedMagic[j]].cost;
			}
			if(selectedFightTypeConfirmed[j] == 5)//投掷
			{
				//前导已判够用，此处不处理
				int tp = selectedGood1[j][0];
				int id = selectedGood1[j][1];
				int ret = throwList.Del_t(tp,id,1);
				if(ret == 1)
				{
					throwAll--;
				}
				if(tp == 7)//武器
				{
					ret = equipList.Del_t(tp,id,1);
					if(ret == 1)
					{
						equipAll--;
					}
				}

			}
			if(selectedFightTypeConfirmed[j] == 6)//补给
			{
				//前导已判够用，此处不处理
				int tp = selectedGood1[j][0];
				int id = selectedGood1[j][1];
				goodList.Del(tp,id,1);
				if(!goodList.CheckGoodExist(tp,id))
				{
					goodAll--;
				}
			}

			//hp为0处理
			//20160818增加乱死亡处理
			if(fighthero[0].hp <= 0&&actorSum>0)
			{
				//死亡
				flagDied[0]=1;
				int ret = CheckWinLose();//1-赢 2-输 -1-到回合
				if(ret)
				{
					returnValue = ret;
					isFightRuned = 0;
					return returnValue;
				}
			}
			if(fighthero[1].hp <= 0&&actorSum>1)
			{
				//死亡
				flagDied[1]=1;
				int ret = CheckWinLose();//1-赢 2-输 -1-到回合
				if(ret)
				{
					returnValue = ret;
					isFightRuned = 0;
					return returnValue;
				}
			}
			if(fighthero[2].hp <= 0&&actorSum>2)
			{
				//死亡
				flagDied[2]=1;
				int ret = CheckWinLose();//1-赢 2-输 -1-到回合
				if(ret)
				{
					returnValue = ret;
					isFightRuned = 0;
					return returnValue;
				}
			}

			for(int s = 0 ; s < 3 ;s ++)//20170107增加循环
			{
				if(CheckTo(j)==0&&attObjId>=3&&fightEnemy[s].no > 0 && fightEnemy[s].hp <= 0)//20160627修正玩家在乱的情况下无故死亡
				{
					//死亡
					flagEnemyDied[s] = 1;
					livedEnemy[0]=0;
					livedEnemy[1]=0;
					livedEnemy[2]=0;
					livedEnemySum = enemySum;
					int tp = 0;

					if(flagEnemyDied[0])
					{
						livedEnemySum--;
					}
					else
					{
						livedEnemy[tp++] = 0;
					}
					if(flagEnemyDied[1])
					{
						livedEnemySum--;
					}
					else if(enemySum > 1)
					{
						livedEnemy[tp++] = 1;
					}
					if(flagEnemyDied[2])
					{
						livedEnemySum--;
					}
					else if(enemySum > 2)
					{
						livedEnemy[tp++] = 2;
					}
					int ret = CheckWinLose();//1-赢 2-输 -1-到回合
					if(ret)returnValue = ret;
				}
			}


		}
		else
		{
			if(flagEnemyDied[j-3])continue; 
			if(fightEnemy[j-3].hp == 0)continue;
			//at怪物
			if(CountDLFMStatusHurt(j)==-1)//返回值-1说明死亡
			{

			}
			//ai及伤害计算
			//随机一个玩家选择目标
			int ret = CheckWinLose();//1-赢 2-输 -1-到回合
			if(ret)
			{
				returnValue = ret;
				isFightRuned = 0;
				return returnValue;
			}
			AISelectedFightStyle = AISelectedFight(j);
			if(AISelectedFightStyle == 2 && magicList[j].magic[AISelectedMagic[j-3]].type != 1 && magicList[j].magic[AISelectedMagic[j-3]].type != 5 )
			{
				attObjId = AISelectTarget(j,1);//选择目标
			}
			else
			{
				attObjId = AISelectTarget(j,0);//选择目标
			}


			if(AISelectedFightStyle == 9)//休眠20160626下一个
			{
				continue;
			}
			if(fightEnemy[j-3].ruan>0)
			{
				AISelectedFightStyle = 10;//乱
			}
			if(fightEnemy[j-3].feng>0&&AISelectedFightStyle==2)//20160627
			{
				AISelectedFightStyle = 1;//封禁转普通攻击
			}

			for(int i = 0 ;i< 3;i++)//20160718移动
			{
				s_hurt[i] = 0;
				//c_hurt[i] = 0;
			}
			hurt = AICountHurt(j,attObjId,AISelectedFightStyle);//敌人
			showNoHp=0;//20160706
			//怪物行为图片播放 攻打 施法等等
			int tret = 0;
			if(AISelectedFightStyle==1 && returnValue ==0)tret = ShowAct(j,attObjId,0);//j att 1-6
			if(AISelectedFightStyle==2 && returnValue ==0)tret = ShowAct(j,attObjId,1);//j att 1-6
			if(AISelectedFightStyle==3 && returnValue ==0)tret = ShowAct(j,attObjId,1);//j att 1-6
			if(AISelectedFightStyle==4 && returnValue ==0)tret = ShowAct(j,attObjId,0);//j att 1-6
			if(AISelectedFightStyle==5 && returnValue ==0)tret = ShowAct(j,attObjId,1);//j att 1-6
			if(AISelectedFightStyle==6 && returnValue ==0)tret = ShowAct(j,attObjId,1);//j att 1-6
			if(AISelectedFightStyle==10 && returnValue ==0)tret = ShowAct(j,attObjId,8);//j att 1-6
			if(tret == -1)returnValue = -10;

			//法术行为CG播放
			if(AISelectedFightStyle == 2)
			{
				int tpMagicPic = magicList[j].magic[AISelectedMagic[j-3]].picnum;
				ShowFightEnemyPic(j);
				int offsetx = 0;
				int offsety = 0;
				if(magicList[j].magic[AISelectedMagic[j-3]].type == 1||magicList[j].magic[AISelectedMagic[j-3]].type == 5 )
				{
					//offsetx = attObjId *40;
					//offsety = 0;
					if(magicList[j].magic[AISelectedMagic[j-3]].last_all>127)//20160704全体
					{
						offsetx = 35;
						offsety = 0;//20160818
					}
					else
					{
						offsetx = attObjId * 35;
						offsety = -attObjId*5;
					}

				}
				else
				{
					//offsetx = (j-3)*40 - 20;
					//offsety = -30;
					if(magicList[j].magic[AISelectedMagic[j-3]].last_all>127)//20160704全体
					{
						offsetx = -15;
						offsety = -30;//20160818
					}
					else
					{
						offsetx = attObjId*35 -50;
						offsety = -30-(attObjId%3)*5;//20160818
					}
				}
				ShowCG(2,tpMagicPic,0,0,9,offsetx,offsety);
			}
			showNoHp=1;//20160706
			//判断攻击 回血 buff 异常标志20160626
			if(AISelectedFightStyle == 1)
			{
				hurtFlag = 1;
				//20160816增加敌人本身特殊攻击效果
				//20181021 将角色anti的判断转移到aigivebuff中
				if(fightEnemy[j-3].atcause>0)
				{
					debuffFlag1 = 0;//20160317


					//20160317 对效果的描述   20160627修正错误
					if(fightEnemy[j-3].atcause%16/8==1)//20160817增加装备免疫
					{
						if(rand()%100>rndComp)debuffFlag1+=1000;
					}
                    if(fightEnemy[j-3].atcause%8/4==1)
					{
						if(rand()%100>rndComp)debuffFlag1+=100;
					}
                    if(fightEnemy[j-3].atcause%4/2==1)
					{
						if(rand()%100>rndComp)debuffFlag1+=10;
					}
                    if(fightEnemy[j-3].atcause%2==1)
					{
						if(rand()%100>rndComp)debuffFlag1+=1;
					}
					debuffFlag = fightEnemy[j-3].last;//持续回合数
				}

			}
			else if(AISelectedFightStyle == 10)
			{
				hurtFlag = 1;
				attObjId = j;
			}
			else if(AISelectedFightStyle == 2)
			{
				if(magicList[j].magic[AISelectedMagic[j-3]].type == 1)
				{
					hurtFlag = 1;
					if(magicList[j].magic[AISelectedMagic[j-3]].last_all>127)//20160317 15->127
					{
						hurtFlag = 2;
					}
					if(magicList[j].magic[AISelectedMagic[j-3]].hp<0)
					{
						recoverFlag = 1;
					}
					if(magicList[j].magic[AISelectedMagic[j-3]].dlfmFlag)
					{
						debuffFlag1 = 0;//20160317
						if(magicList[j].magic[AISelectedMagic[j-3]].last_all>127)
						{
							debuffFlag1 =10000;

						}

						//20160317 对效果的描述  20160627
						//20181021 将角色anti的判断转移到aigivebuff中
                        if(magicList[j].magic[AISelectedMagic[j-3]].dlfmFlag%16/8==1)//20170110
						{
							if(rand()%100>rndComp)debuffFlag1+=1000;
						}
                        if(magicList[j].magic[AISelectedMagic[j-3]].dlfmFlag%8/4==1)//20170110
						{
							if(rand()%100>rndComp)debuffFlag1+=100;
						}
                        if(magicList[j].magic[AISelectedMagic[j-3]].dlfmFlag%4/2==1)//20170110
						{
							if(rand()%100>rndComp)debuffFlag1+=10;
						}
                        if(magicList[j].magic[AISelectedMagic[j-3]].dlfmFlag%2==1)//20170110
						{
							if(rand()%100>rndComp)debuffFlag1+=1;
						}
						debuffFlag = magicList[j].magic[AISelectedMagic[j-3]].last_all%128;//持续回合数
					}
					//20160625 攻速防
					if(magicList[j].magic[AISelectedMagic[j-3]].last_all>127)
					{
						reverse = 1;
						buffFlag1 = 1000000;
					}
					if(magicList[j].magic[AISelectedMagic[j-3]].at>0)
					{
						reverse = 1;
						buffFlag1+=(magicList[j].magic[AISelectedMagic[j-3]].at==100?99:magicList[j].magic[AISelectedMagic[j-3]].at)*10000;
					}
					if(magicList[j].magic[AISelectedMagic[j-3]].df>0)
					{
						reverse = 1;
						buffFlag1+=(magicList[j].magic[AISelectedMagic[j-3]].df==100?99:magicList[j].magic[AISelectedMagic[j-3]].df)*100;
					}
					if(magicList[j].magic[AISelectedMagic[j-3]].speed>0)
					{
						reverse = 1;
						buffFlag1+=(magicList[j].magic[AISelectedMagic[j-3]].speed==100?99:magicList[j].magic[AISelectedMagic[j-3]].speed)*1;

					}
					buffFlag = magicList[j].magic[AISelectedMagic[j-3]].last_all%128;//持续回合数//20181021更改debuffflag为buffflag



				}
				if(magicList[j].magic[AISelectedMagic[j-3]].type == 2)
				{
					buffFlag1 = 0;//20160317 
					if(magicList[j].magic[AISelectedMagic[j-3]].last_all>127)
					{
						buffFlag1 = 1000000;
					}
					//20160317 对效果的描述 
					if(magicList[j].magic[AISelectedMagic[j-3]].at>0)
					{
						buffFlag1+=(magicList[j].magic[AISelectedMagic[j-3]].at==100?99:magicList[j].magic[AISelectedMagic[j-3]].at)*10000;
					}
					if(magicList[j].magic[AISelectedMagic[j-3]].df>0)
					{
						buffFlag1+=(magicList[j].magic[AISelectedMagic[j-3]].df==100?99:magicList[j].magic[AISelectedMagic[j-3]].df)*100;
					}
					if(magicList[j].magic[AISelectedMagic[j-3]].speed>0)
					{
						buffFlag1+=(magicList[j].magic[AISelectedMagic[j-3]].speed==100?99:magicList[j].magic[AISelectedMagic[j-3]].speed)*1;
					}

					buffFlag = magicList[j].magic[AISelectedMagic[j-3]].last_all%128;//持续回合数
				}
				if(magicList[j].magic[AISelectedMagic[j-3]].type == 3)//辅助
				{
					recoverFlag = 1;
					if(magicList[j].magic[AISelectedMagic[j-3]].last_all>127)
					{
						recoverFlag = 2;
					}
					//20160704
					buffFlag1 = 0;//20160317 
					if(magicList[j].magic[selectedMagic[j-3]].dlfmFlag)//20160702 设置是否消除自身异常状态
					{
						debuffFlag1 = 0;//20160317
						if(magicList[j].magic[selectedMagic[j-3]].last_all>127)
						{
							debuffFlag1 =10000;
							reverse1 = 1;
						}

						//20160317 对效果的描述   20160627修正错误
						if(magicList[j].magic[selectedMagic[j-3]].dlfmFlag%16/8==1)
						{
							if(rand()%100>rndComp)debuffFlag1+=1000;
							reverse1 = 1;
						}
						if(magicList[j].magic[selectedMagic[j-3]].dlfmFlag%8/4==1)
						{
							if(rand()%100>rndComp)debuffFlag1+=100;
							reverse1 = 1;
						}
						if(magicList[j].magic[selectedMagic[j-3]].dlfmFlag%4/2==1)
						{
							if(rand()%100>rndComp)debuffFlag1+=10;
							reverse1 = 1;
						}
						if(magicList[j].magic[selectedMagic[j-3]].dlfmFlag%2==1)
						{
							if(rand()%100>rndComp)debuffFlag1+=1;
							reverse1 = 1;
						}
						debuffFlag = magicList[j].magic[selectedMagic[j-3]].last_all%128;//持续回合数
					}
				}

			}


			//伤害值显示
			if(hurtFlag == 1)//攻击型//selectedFightStyle
			{
				ShowHurt(attObjId,hurt);//attObjId=对象编号 确定位置 hurt值
				CopyToHdc();
				Delay(500);
			}
			if(hurtFlag == 2)//全体攻击型//selectedFightStyle
			{
				for(int i = 0; i < 3;i ++)//20160706修正为3
				{
					if(flagDied[i])continue;
					if(i != attObjId)
					{
						hurt = AICountHurt(j,i,AISelectedFightStyle);//敌人
						s_hurt[i] = hurt;
					}
					ShowHurt(i,s_hurt[i]);
				}
				CopyToHdc();
				Delay(500);
				//AddHurt(3,attObjId);
				//ShowHurt(-2,hurt);//attObjId=对象编号 确定位置 hurt值
			}
			if(recoverFlag == 1)//回血
			{
				ShowHurt((attObjId+3),-abs(hurt));//j=我方编号 确定位置 hurt值为负//20160625
				CopyToHdc();
				Delay(500);
				//ShowHurt(attObjId-3,-abs(hurt));//j=我方编号 确定位置 hurt值为负
			}
			if(recoverFlag == 2)//全体回血
			{
				for(int i = 0; i < 3;i ++)//20160706修正为3
				{
					if( flagEnemyDied[i])continue;
					if(i != attObjId)
					{
						hurt = AICountHurt(j,i,AISelectedFightStyle);//敌人
						s_hurt[i] = hurt;
					}
					ShowHurt(i+3,-abs(s_hurt[i]));
				}
				CopyToHdc();
				Delay(500);
				//AddHurt(4,j);
				//ShowHurt(-2,-abs(hurt));//j=我方编号 确定位置 hurt值为负
			}
			if(buffFlag1>1000000&&reverse==0)//全体增强
			{
				AIGiveBuff(-1,0,buffFlag1,buffFlag);
				//20181125AIShowBuff(-1,0,buffFlag1);//j=我方编号 确定位置 hurt值为负
			}
			else if(buffFlag1<1000000&&reverse==0&&buffFlag1)//增强
			{
				AIGiveBuff(j,0,buffFlag1,buffFlag);
				//20181125AIShowBuff(j,0,buffFlag1);//j=我方编号 确定位置 hurt值为负//20160625
			}
			if(debuffFlag1>10000)//敌方全体减弱
			{
				AIGiveBuff(-1,1,debuffFlag1,debuffFlag);
				//20181125AIShowBuff(-1,1,debuffFlag1);//j=我方编号 确定位置 hurt值为负
			}
			else if(debuffFlag1<10000&&debuffFlag1)//敌方减弱
			{
				AIGiveBuff(attObjId,1,debuffFlag1,debuffFlag);
				//20181125AIShowBuff(attObjId,1,debuffFlag1);//j=我方编号 确定位置 hurt值为负
			}
			if(reverse==1&&buffFlag1>1000000)//敌方全体减弱
			{
				AIGiveBuff(-1,2,buffFlag1,debuffFlag);
				//20181125AIShowBuff(-1,2,buffFlag1);//j=我方编号 确定位置 hurt值为负
			}
			else if(reverse==1&&buffFlag1<1000000&&buffFlag1)//敌方减弱
			{
				AIGiveBuff(attObjId,2,buffFlag1,debuffFlag);
				//20181125AIShowBuff(attObjId,2,buffFlag1);//j=我方编号 确定位置 hurt值为负
			}

			//消耗处理
			if(AISelectedFightStyle == 2)//魔法
			{
				//前导已判够用，此处不处理
				fightEnemy[j].mp -= magicList[j].magic[AISelectedMagic[j-3]].cost;
			}

			//hp为0处理
			if(fighthero[0].hp <= 0&&actorSum>0)
			{
				//死亡
				flagDied[0]=1;
				int ret = CheckWinLose();//1-赢 2-输 -1-到回合
				if(ret)
				{
					returnValue = ret;
					isFightRuned = 0;
					return returnValue;
				}
			}
			if(fighthero[1].hp <= 0&&actorSum>1)
			{
				//死亡
				flagDied[1]=1;
				int ret = CheckWinLose();//1-赢 2-输 -1-到回合
				if(ret)
				{
					returnValue = ret;
					isFightRuned = 0;
					return returnValue;
				}
			}
			if(fighthero[2].hp <= 0&&actorSum>2)
			{
				//死亡
				flagDied[2]=1;
				int ret = CheckWinLose();//1-赢 2-输 -1-到回合
				if(ret)
				{
					returnValue = ret;
					isFightRuned = 0;
					return returnValue;
				}
			}
		}
	}
	GetTmpEnemy(4);
	if(tmpselectedEnemy == -1)//全部死亡,胜利
	{
		int ret = CheckWinLose();//1-赢 2-输 -1-到回合
		if(ret)
		{
			returnValue = ret;
			isFightRuned = 0;
			return returnValue;
		}
	}
	flagDef[0] = 0;
	flagDef[1] = 0;
	flagDef[2] = 0;

	int ret = CheckWinLose(1);//1-赢 2-输 -1-到回合20170219
	if(ret)
	{
		returnValue = ret;
		isFightRuned = 0;
		return returnValue;
	}

	//20160626 下回合预处理检测mian
	if(returnValue <=0)//returnValue <=0说明无结果
	{
		int livedHero = actorSum;
		if(flagDied[0]||fighthero[0].mian>0)livedHero--;
		if((flagDied[1]&&actorSum>1)||fighthero[1].mian>0)livedHero--;
		if((flagDied[2]&&actorSum>2)||fighthero[2].mian>0)livedHero--;
		if(fighthero[0].mian>0)
		{
			selectedFightEnemy[0] = 0;
			selectedFightTypeConfirmed[0] = 9;
		}
		if(fighthero[1].mian>0)
		{
			selectedFightEnemy[1] = 0;
			selectedFightTypeConfirmed[1] = 9;
		}
		if(fighthero[2].mian>0)
		{
			selectedFightEnemy[2] = 0;
			selectedFightTypeConfirmed[2] = 9;
		}
		selectedFightHero=0;
		selectedHeroFinished=0;
		DealMian();
		if(flagDied[selectedFightHero])//判断玩家角色死亡20160627
		{
			selectedHeroFinished ++;
			selectedFightEnemy[selectedFightHero] = 0;
			selectedFightTypeConfirmed[selectedFightHero] = -1;
			selectedFightHero++;
		}
		if(flagDied[selectedFightHero])//判断玩家角色死亡20160627
		{
			selectedHeroFinished ++;
			selectedFightEnemy[selectedFightHero] = 0;
			selectedFightTypeConfirmed[selectedFightHero] = -1;
			selectedFightHero++;
		}

		if(livedHero == 0)
		{


			//选择完战斗对象 战斗进程 
			int ret = FightRun();
			if(ret>0)
			{
				isFightRuned = 0;
				return ret;
			}
			else if(ret == -1)
			{
				isFightRuned = 0;
				return -1;
			}
			//selectedFightHero = 0;
			//selectedHeroFinished = 0;//20160701
			//selectedFightStyle = 0;


			if(livedEnemySum == 1)
			{
				tmpselectedEnemy = livedEnemy[0];//20160706
				if(selectedHeroFinished==0)selectedFightEnemy[0] = livedEnemy[0];
				if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
				if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
				//selectedHeroFinished ++;
			}
		}
		isFightRuned = 0;
		return 0;

	}
	isFightRuned = 0;
	return returnValue;
}

void Fight::ShowHurt(int i,int hurt)
{
	//if(hurtOffset <= 0)hurtOffset = 0;
	if(i!=-1&&i!=-2)
	{
		if(hurt>0)
		{
			int posX = 16+(i%3)*35+50*(1-i/3);
			int posY = 55 -(i/3)*37 - 5 *((i%3)+1);//20160817
			ShowNumInPic(posX,posY,hurt,2,8);
			//CopyToHdc();
			//char temp[10];
			//memset(temp,0,sizeof(temp));
			//sprintf_s(temp,"-%d",hurt);
			//ShowTextDirect(temp,posX,posY,8);
			//Delay(500);
		}
		else if(hurt<0)
		{
			int posX = 16+(i%3)*35+50*(1-i/3);
			int posY = 55 -(i/3)*37 - 5 *((i%3)+1);
			ShowNumInPic(posX,posY,-hurt,1,8);
			//CopyToHdc();

			//char temp[10];
			//memset(temp,0,sizeof(temp));
			//sprintf_s(temp,"+%d",-hurt);
			//ShowTextDirect(temp,posX,posY,8);
			//Delay(500);
		}
		else if(isMissed == 1)//20160718
		{
			int posX = 16+(i%3)*35+50*(1-i/3);
			int posY = 55 -(i/3)*37 - 5 *((i%3)+1);
			BITMAP bwh;
			LoadPic(RES_PIC,2,18,hbmp);
			HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
			GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
			BitBlt(hdcTmp, posX, posY+2, bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
			SelectObject(hdcMem, oldhbmp);
			DeleteObject(hbmp);
			//CopyToHdc();

		}
	}
	else if(i==-1)
	{
		if(hurt>0)
		{
			for(int j = 0 ;j < enemySum ;j++)
			{
				int ii = livedEnemy[j]+3;
				int posX = 16+(ii%3)*35+50*(1-ii/3);
				int posY = 55 -(ii/3)*37 - 5 *((i%3)+1);
				ShowNumInPic(posX,posY,s_hurt[ii-3],2,8);
			}
			CopyToHdc();
			Delay(500);
		}
		else if(hurt<0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||actorSum<=j)continue;
				int ii = j;
				int posX = 16+(ii%3)*35+50*(1-ii/3);
				int posY = 55 -(ii/3)*37 - 5 *((i%3)+1);
				ShowNumInPic(posX,posY,-s_hurt[ii],1,8);
			}
			CopyToHdc();
			Delay(500);
		}
		else //20160718
		{
			for(int j = 0 ;j < enemySum ;j++)
			{
				int ii = livedEnemy[j]+3;
				if(isMissed==1)
				{
					int posX = 16+(ii%3)*35+50*(1-ii/3);
					int posY = 55 -(ii/3)*37 - 5 *((i%3)+1);

					BITMAP bwh;
					LoadPic(RES_PIC,2,18,hbmp);
					HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
					GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
					BitBlt(hdcTmp, posX, posY+2, bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
					SelectObject(hdcMem, oldhbmp);
					DeleteObject(hbmp);

				}
			}
			CopyToHdc();
			Delay(500);


		}
	}
	else if(i==-2)
	{
		if(hurt<0)
		{
			for(int j = 0 ;j < enemySum ;j++)
			{
				int ii = livedEnemy[j]+3;
				int posX = 16+(ii%3)*35+50*(1-ii/3);
				int posY = 55 -(ii/3)*37 - 5 *((i%3)+1);
				ShowNumInPic(posX,posY,-s_hurt[ii-3],1,8);
			}
			CopyToHdc();
			Delay(500);
		}
		else if(hurt>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||actorSum<=j)continue;
				int ii = j;
				int posX = 16+(ii%3)*35+50*(1-ii/3);
				int posY = 55 -(ii/3)*37 - 5 *((i%3)+1);
				ShowNumInPic(posX,posY,s_hurt[ii],2,8);
			}
			CopyToHdc();
			Delay(500);
		}
		else//20160718
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||actorSum<=j)continue;
				int ii = j;
				if(isMissed==1)
				{
					int posX = 16+(ii%3)*35+50*(1-ii/3);
					int posY = 55 -(ii/3)*37 - 5 *((i%3)+1);

					BITMAP bwh;
					LoadPic(RES_PIC,2,18,hbmp);
					HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
					GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
					BitBlt(hdcTmp, posX, posY+2, bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
					SelectObject(hdcMem, oldhbmp);
					DeleteObject(hbmp);

				}
			}
			CopyToHdc();
			Delay(500);
		}
	}
}


int Fight::CountHurt(int player,int enemy,int selectedFightStyle)//返回值为显示伤害值 负数为吸血
{
	/*for(int i = 0 ;i< 3;i++)
	{
	s_hurt[i] = 0;
	//c_hurt[i] = 0;
	}*/

	//20160718新增miss 
	if((selectedFightStyle == 1 || selectedFightStyle == 2 || selectedFightStyle == 4 ) && missflag == 1 && GetMissResult(0,player,enemy-3))//20170130修正 20170420修正为只对普工及魔法做MISS判定
	{
		isMissed = 1;
		s_hurt[enemy-3] = 0;
		return 0;
	}
	else
	{
		isMissed = 0;
	}

	if(selectedFightStyle == 1||selectedFightStyle == 4)
	{
		int tatt= fighthero[player].att;
		int tdef = fightEnemy[enemy-3].def;
		if(fighthero[player].ateffect%100>0)
		{
			tatt = tatt*(100+fighthero[player].ateffect%100)/100;
			fighthero[player].ateffect-=100;
			if(fighthero[player].ateffect<0)fighthero[player].ateffect = 0;
		}
		if(fightEnemy[enemy-3].dfeffect%100>0)
		{
			tdef = tdef*(100+fightEnemy[enemy-3].dfeffect%100)/100;
			fightEnemy[enemy-3].dfeffect-=100;
			if(fightEnemy[enemy-3].dfeffect<0)fightEnemy[enemy-3].dfeffect = 0;
		}
		if(fighthero[player].ateffect%100<0)
		{
			tatt = tatt*(100-fighthero[player].ateffect%100)/100;
			fighthero[player].ateffect+=100;
			if(fighthero[player].ateffect>0)fighthero[player].ateffect = 0;
		}
		if(fightEnemy[enemy-3].dfeffect%100<0)
		{
			tdef = tdef*(100+fightEnemy[enemy-3].dfeffect%100)/100;//20170110修正降防实际为升防
			fightEnemy[enemy-3].dfeffect+=100;
			if(fightEnemy[enemy-3].dfeffect>0)fightEnemy[enemy-3].dfeffect = 0;
		}

		//int hurt = (( tatt-tdef)>0?(tatt-tdef):1) + rand()%(fighthero[player].degree+10);
		int hurt = CountNormalHurt(0,tatt,tdef);//20170125 0-我方打敌人 1-敌人打我
		if(fgtDebug == 1)
		{
			hurt = 999999;
		}
		if(g_debugFlag == 1 && dghurt >0)
		{
			hurt = dghurt;
			dghurt = 0;
		}
		t_hurt = hurt;
		//if(hurt<0)hurt = 1;
		if(fightEnemy[enemy-3].hp - hurt > 0)
		{
			fightEnemy[enemy-3].hp-=hurt;

		}
		else
		{
			hurt = fightEnemy[enemy-3].hp;
			fightEnemy[enemy-3].hp = 0;
		}
		s_hurt[enemy-3] = hurt;
		return hurt;
	}
	else if(selectedFightStyle == 2)
	{
		
		int enanima= fightEnemy[enemy-3].anima;
		int myanima= fighthero[player].anima;
		int hurt =  magicList[player].magic[selectedMagic[player]].hp;
		int recoverhurt = 0;

		if(g_debugFlag == 1 && dghurt >0)
		{
			hurt = dghurt;
			dghurt = 0;
		}
		t_hurt = hurt;
		if(magicList[player].magic[selectedMagic[player]].type == 1)
		{
			//吸血也受灵力影响20170125
			//20181230add 吸血
            if(hurt < 0)
            {
                hurt = - hurt;
                recoverhurt = 1;//20181230
            }

			//hurt = magicList[player].magic[selectedMagic[player]].hp * ((63-tanima)*80/64+20)/100;//20170110增加灵力因素影响技能伤害的效果 20170111转移至此并修正
			hurt = CountSkillHurt(magicList[player].magic[selectedMagic[player]].hp,myanima,enanima);//20170125
			if(fightEnemy[enemy-3].hp - hurt > 0)
			{
				fightEnemy[enemy-3].hp -= hurt;
			}
			else
			{
				hurt = fightEnemy[enemy-3].hp;
				fightEnemy[enemy-3].hp = 0;
			}
			if(recoverhurt == 1)//20181230
            {
                fighthero[player].hp+=hurt;
                if(fighthero[player].hp>fighthero[player].hpMax)
                {
                    fighthero[player].hp = fighthero[player].hpMax;
                }
            }
			s_hurt[enemy-3] = hurt;
		}
		if(magicList[player].magic[selectedMagic[player]].type == 3)
		{
			hurt = -hurt;
			fighthero[enemy-3].hp-=hurt;
			if(fighthero[enemy-3].hp>fighthero[enemy-3].hpMax)
			{
				fighthero[enemy-3].hp = fighthero[enemy-3].hpMax;
			}
			//c_hurt[enemy-3] = hurt;
		}
		if(magicList[player].magic[selectedMagic[player]].type == 4 && flagDied[enemy-3])
		{
			hurt = -fighthero[enemy-3].hpMax * hurt / 100;
			fighthero[enemy-3].hp-=hurt;
			flagDied[enemy-3]=0;
			//c_hurt[enemy-3] = hurt;
		}

		return hurt;

	}
	else if(selectedFightStyle == 3)//合击
	{ 
		int hurt =  GetAllMagicHP(fighthero[player].togethermagic);//magicList[player].magic[fighthero[player].togethermagic].hp;
		if(g_debugFlag == 1 && dghurt >0)
		{
			hurt = dghurt;
			dghurt = 0;
		}
		t_hurt = hurt;
		if(hurt<0)hurt = 1;
		if(fightEnemy[enemy-3].hp - hurt > 0)
		{
			fightEnemy[enemy-3].hp -= hurt;
		}
		else
		{
			hurt = fightEnemy[enemy-3].hp;
			fightEnemy[enemy-3].hp = 0;
		}
		s_hurt[enemy-3] = hurt;
		return hurt;

	}
	else if(selectedFightStyle == 5)//投掷
	{	

		int hurt =  0;
		//20150305先检测物品是否存在
		if(!throwList.CheckGoodExistReturnPos(selectedGood1[player][0],selectedGood1[player][1]))
		{
			//不存在

			hurt = CountHurt(player,enemy,1);//按普通攻击计算
			selectedFightTypeConfirmed[player] = 1;
			return hurt;
		}

		if(selectedGood1[player][0] == 7)
		{
			hurt = throwList.good[selectedGood1[player][0]-1][selectedGood1[player][1]-1].at*100;
		}
		else
		{
			hurt = throwList.good[selectedGood1[player][0]-1][selectedGood1[player][1]-1].hp;
		}
		t_hurt = hurt;
		if(fightEnemy[enemy-3].hp - abs(hurt) > 0)
		{
			fightEnemy[enemy-3].hp -= abs(hurt);
		}
		else
		{
			if(hurt>0)
			{
				hurt = fightEnemy[enemy-3].hp;
			}
			else
			{
				hurt = -fightEnemy[enemy-3].hp;
			}
			fightEnemy[enemy-3].hp = 0;
		}
		//随机概率产生副效果

		s_hurt[enemy-3] = hurt;
		return hurt;

	}
	else if(selectedFightStyle == 6)//使用
	{	
		int ttype =  selectedGood1[player][0]-1;
		int tid = selectedGood1[player][1]-1;
		int hurt = 0;
		//20150305先检测物品是否存在
		if(!goodList.CheckGoodExistReturnPos(selectedGood1[player][0],selectedGood1[player][1]))
		{
			//不存在

			hurt = CountHurt(player,enemy,1);//按普通攻击计算
			selectedFightTypeConfirmed[player] = 1;
			return hurt;
		}

		hurt =  goodList.good[ttype][tid].hp;
		t_hurt = hurt;
		if(ttype == 8)//药物
		{
			if( goodList.good[ttype][tid].all_dlfm_Flag > 15)
			{
				for(int i = 0 ; i < 3 ; i ++)
				{
					if(fighthero[i].hp > 0 && flagDied[i] == 0)
					{
						fighthero[i].hp+=goodList.good[ttype][tid].hp;
						fighthero[i].mp+=goodList.good[ttype][tid].mp;//20161219
						if(fighthero[i].hp>fighthero[i].hpMax)
						{
							fighthero[i].hp = fighthero[i].hpMax;
						}
						if(fighthero[i].mp>fighthero[i].mpMax)//20161219
						{
							fighthero[i].mp = fighthero[i].mpMax;
						}
					}
				}
			}
			else
			{
				fighthero[enemy-3].hp+=goodList.good[ttype][tid].hp;
				fighthero[enemy-3].mp+=goodList.good[ttype][tid].mp;//20161219
				if(fighthero[enemy-3].hp>fighthero[enemy-3].hpMax)
				{
					fighthero[enemy-3].hp = fighthero[enemy-3].hpMax;
				}
				if(fighthero[enemy-3].mp>fighthero[enemy-3].mpMax)//20161219
				{
					fighthero[enemy-3].mp = fighthero[enemy-3].mpMax;
				}
			}
			//c_hurt[enemy-3] = hurt;
		}
		else if(ttype == 9)//复活灵药
		{

			fighthero[enemy-3].hp=fighthero[enemy-3].hpMax*hurt/100;
			flagDied[enemy-3] = 0;
		}
		else if(ttype == 10)//仙药 加身法等
		{
			if( goodList.good[ttype][tid].all_dlfm_Flag > 15)
			{
				for(int i = 0 ; i < 3 ; i ++)
				{
					if(fighthero[i].hp > 0 && flagDied[i] == 0)
					{
						fighthero[i].hpMax += goodList.good[ttype][tid].hpmax;
						fighthero[i].mpMax += goodList.good[ttype][tid].mpmax;
						fighthero[i].att += goodList.good[ttype][tid].at;
						fighthero[i].def += goodList.good[ttype][tid].df;
						fighthero[i].speed += goodList.good[ttype][tid].speed;
						fighthero[i].anima += goodList.good[ttype][tid].anima;
						fighthero[i].lucky += goodList.good[ttype][tid].lucky;
					}
				}
			}
			else
			{
				fighthero[enemy-3].hpMax += goodList.good[ttype][tid].hpmax;
				fighthero[enemy-3].mpMax += goodList.good[ttype][tid].mpmax;
				fighthero[enemy-3].att += goodList.good[ttype][tid].at;
				fighthero[enemy-3].def += goodList.good[ttype][tid].df;
				fighthero[enemy-3].speed += goodList.good[ttype][tid].speed;
				fighthero[enemy-3].anima += goodList.good[ttype][tid].anima;
				fighthero[enemy-3].lucky += goodList.good[ttype][tid].lucky;
			}
		}
		else if(ttype == 11)//兴奋剂
		{
			if( goodList.good[ttype][tid].all_dlfm_Flag > 15)
			{
				for(int i = 0 ; i < 3 ; i ++)
				{
					if(fighthero[i].hp > 0 && flagDied[i] == 0)
					{
						fighthero[i].speed += fighthero[i].speed*goodList.good[ttype][tid].speed/100;
						fighthero[i].att += fighthero[i].att*goodList.good[ttype][tid].at/100;
						fighthero[i].def += fighthero[i].def*goodList.good[ttype][tid].df/100;
					}
				}
			}
			else
			{
				fighthero[enemy-3].speed += fighthero[enemy-3].speed*goodList.good[ttype][tid].speed/100;
				fighthero[enemy-3].att += fighthero[enemy-3].att*goodList.good[ttype][tid].at/100;
				fighthero[enemy-3].def += fighthero[enemy-3].def*goodList.good[ttype][tid].df/100;
			}
		}


		return hurt;

	}
	else if(selectedFightStyle == 10)
	{

		int hurt = ((fighthero[player].att-fighthero[player].def)>0?(fighthero[player].att-fighthero[player].def):1) + rand()%(fighthero[player].degree+10);
		if(g_debugFlag == 1 && dghurt >0)
		{
			hurt = dghurt;
			dghurt = 0;
		}
		t_hurt = hurt;
		//if(hurt<0)hurt = 1;
		if(fighthero[player].hp - hurt > 0)
		{
			fighthero[player].hp-=hurt;
		}
		else
		{
			hurt = fighthero[player].hp;
			fighthero[player].hp = 0;
		}
		return hurt;
	}
	return 0;
}

int Fight::AICountHurt(int enemy,int player,int selectedFightStyle)//返回值为显示伤害值 负数为吸血
{
	//20160718新增miss 
	if(missflag == 1 && GetMissResult(1,enemy-3,player))//20170130修正
	{
		isMissed = 1;
		s_hurt[player] = 0;
		return 0;
	}
	else
	{
		isMissed = 0;
	}


	if(selectedFightStyle == 1)
	{
		int tatt= fightEnemy[enemy-3].att;
		int tdef = fighthero[player].def;

		if(fightEnemy[enemy-3].ateffect%100>0)
		{
			tatt = tatt*(100+fightEnemy[enemy-3].ateffect%100)/100;
			fightEnemy[enemy-3].ateffect-=100;
			if(fightEnemy[enemy-3].ateffect<0)fightEnemy[enemy-3].ateffect = 0;
		}
		if(fighthero[player].dfeffect%100>0)
		{
			tdef = tdef*(100+fighthero[player].dfeffect%100)/100;
			fighthero[player].dfeffect-=100;
			if(fighthero[player].dfeffect<0)fighthero[player].dfeffect = 0;
		}
		if(fightEnemy[enemy-3].ateffect%100<0)
		{
			tatt = tatt*(100-fightEnemy[enemy-3].ateffect%100)/100;
			fightEnemy[enemy-3].ateffect+=100;
			if(fightEnemy[enemy-3].ateffect>0)fightEnemy[enemy-3].ateffect = 0;
		}
		if(fighthero[player].dfeffect%100<0)
		{
			tdef = tdef*(100-fighthero[player].dfeffect%100)/100;
			fighthero[player].dfeffect+=100;
			if(fighthero[player].dfeffect>0)fighthero[player].dfeffect = 0;
		}

		//20170130一定几率的抵挡
		isResisted = 0;
		int rnd1 = rand()%150;
		if(rnd1 < fighthero[player].lucky)
		{
			isResisted = 1;
		}

		int hurt = CountNormalHurt(1,tatt,tdef);//20170125 0-我方打敌人 1-敌人打我
		
		//int hurt = ((tatt-tdef)>0?(tatt-tdef):1) + rand()%((fightEnemy[enemy-3].degree/50+1)*5)   ;
		if(g_debugFlag == 1 && dghurt >0)
		{
			hurt = dghurt;
			dghurt = 0;
		}
		t_hurt = hurt;
		//防御状态减半
		if(flagDef[player]==1 || isResisted == 1)
		{
			hurt = hurt/2;
			//flagDef[player]=0;//201160818修正
		}

		if(fighthero[player].hp - hurt > 0)
		{
			fighthero[player].hp-=hurt;

		}
		else
		{
			hurt = fighthero[player].hp;
			fighthero[player].hp = 0;
		}
		return hurt;
	}
	else if(selectedFightStyle == 2)
	{
		int hurt =  magicList[enemy].magic[AISelectedMagic[enemy-3]].hp;
		if(g_debugFlag == 1 && dghurt >0)
		{
			hurt = dghurt;
			dghurt = 0;
		}
		t_hurt = hurt;
		if(magicList[enemy].magic[AISelectedMagic[enemy-3]].type == 1)
		{
			int enanima = fighthero[player].anima;
			int myanima = fightEnemy[enemy-3].anima;
			//hurt =  magicList[enemy].magic[AISelectedMagic[enemy-3]].hp * ((63-tanima)*80/64+20)/100;//20170110增加灵力因素影响技能伤害的效果 20170111移到此并修正
			//if(tanima > 63)hurt = 999999;
			
			hurt = CountSkillHurt(magicList[enemy].magic[AISelectedMagic[enemy-3]].hp,myanima,enanima);//20170125
			if(fgtDebug == 1)
		{
			hurt = 1;
		}
			if(fighthero[player].hp - hurt > 0)
			{
				fighthero[player].hp -= hurt;
			}
			else
			{
				hurt = fighthero[player].hp;
				fighthero[player].hp = 0;
			}
			s_hurt[player] = hurt;
		}
		if(magicList[enemy].magic[AISelectedMagic[enemy-3]].type == 3)
		{
			hurt = -hurt;
			fightEnemy[enemy-3].hp-=hurt;
			if(fightEnemy[enemy-3].hp>fightEnemy[enemy-3].hpMax)
			{
				fightEnemy[enemy-3].hp = fightEnemy[enemy-3].hpMax;
			}
			//c_hurt[enemy-3] = hurt;
		}


		return hurt;

	}
	else if(selectedFightStyle == 10)
	{

		int hurt = ((fightEnemy[enemy-3].att-fightEnemy[enemy-3].def)>0?(fightEnemy[enemy-3].att-fightEnemy[enemy-3].def):1) + rand()%(fightEnemy[enemy-3].degree+10);
		if(g_debugFlag == 1 && dghurt >0)
		{
			hurt = dghurt;
			dghurt = 0;
		}
		t_hurt = hurt;
		//if(hurt<0)hurt = 1;
		if(fightEnemy[enemy-3].hp - hurt > 0)
		{
			fightEnemy[enemy-3].hp-=hurt;
		}
		else
		{
			hurt = fightEnemy[enemy-3].hp;
			fightEnemy[enemy-3].hp = 0;
		}
		return hurt;
	}
	return 0;
}

int Fight::ShowAct(int j,int attObjId,int fightType)
{
	if(j < 3)//我方动
	{
		return ShowFightActorPicDirect(j,attObjId-3,fightType);
	}
	else //敌人动
	{
		return ShowFightEnemyPicDirect(j-3,attObjId,fightType);
	}
}

int Fight::CountDLFMStatusHurt(int j)
{
	if(j<3)//玩家
	{
		if(fighthero[j].du>0)//减血25%
		{
			fighthero[j].du--;
			int hurt = fighthero[j].hp / 4;
			fighthero[j].hp -= hurt;
			if(fighthero[j].hp==0)
			{
				fighthero[j].hp=1;
				hurt = 0;
			}
			ShowHurt(j,hurt);
			CopyToHdc();
			Delay(500);
		}
		else if(fighthero[j].ruan>0)//打自己人
		{
			fighthero[j].ruan--;

		}
		else if(fighthero[j].feng>0)//无法使用技能，前面设标志
		{
			fighthero[j].feng--;
		}
		else if(fighthero[j].mian>0)//眠。前面跳过回合
		{
			fighthero[j].mian--;
		}
	}
	else
	{
		if(fightEnemy[j-3].du>0)//减血25%
		{
			fightEnemy[j-3].du--;
			int hurt = fightEnemy[j-3].hp / 4;
			fightEnemy[j-3].hp -= hurt;
			ShowHurt(j,hurt);
			CopyToHdc();//20170102
			Delay(500);//20170102
		}
		else if(fightEnemy[j-3].ruan>0)//打自己人
		{
			fightEnemy[j-3].ruan--;
		}
		else if(fightEnemy[j-3].feng>0)//无法使用技能，设标志
		{
			fightEnemy[j-3].feng--;
		}
		else if(fightEnemy[j-3].mian>0)//眠。跳过回合
		{
			fightEnemy[j-3].mian--;
		}
	}
	return 0;
}

int Fight::AISelectTarget(int j,int type)//20160718新增type用于恢复选择
{
	//选择值为0-2，如果为0 则再重新选择
	//srand((unsigned)time(0)); 
	int k = 0;
	if(type == 0)//攻击
	{

		k = rand()%actorSum;
		while(fighthero[k].hp==0||flagDied[k]==1)//无hp,无法选择//20160719修正 flagDied[k]==1
		{
			k = rand()%actorSum;
		}
	}
	else
	{
		k = rand()%3;
		while(fightEnemy[k].hp==0)//无hp,无法选择
		{
			k = rand()%3;
		}
	}
	return k;
}

int Fight::ShowFightActorPicDirect(int idx,int att,int fightType)//att确定攻击图片显示位置,fightType 确定类型0-普通打 1-法术 2-防御 3-被攻击 4-缺血 5-死亡 6-逃跑 7-逃跑失败 8-乱 9-合击位置
{
	int startPos = 0;
	int sum = 0;
	int returnValue = 0;
	
	if(fightType == 1||fightType == 9||(fightType == 4 && showNoHp == 0))
	{
		startPos = 5;
		sum = 3;
	}
	else if(fightType == 2)
	{
		startPos = 8;
		sum = 1;
	}
	else if(fightType == 3)
	{
		startPos = 9;
		sum = 1;
	}
	else if(fightType == 4 && showNoHp == 1)
	{
		startPos = 10;
		sum = 1;
	}
	else if(fightType == 5)
	{
		startPos = 11;
		sum = 1;
	}
	else if(fightType == 8)
	{
		startPos = 3;
		sum = 2;
	}

	if(fightType == 0)
	{
		for(int i = 1; i<5;i++)//100需改
		{
			BITMAP bwh;
			Show(100+idx);
			//BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);

			int type1 = GetType(RES_PIC,3,fighthero[idx].no);
			if(type1 == 1)
			{
				LoadPic(RES_PIC,3,fighthero[idx].no,hbmp,i);//20160225
				HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2 + (att-idx-1)*35*(i-1)/4 , 57 - 5 *(idx+1) - 8*i , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);
			}
			else
			{
				LoadPicMask(RES_PIC,3,fighthero[idx].no,hbmp,i);//20160225
				HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2 + (att-idx-1)*35*(i-1)/4 , 57 - 5 *(idx+1) - 8*i , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCPAINT);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);

				LoadPicTrans(RES_PIC,3,fighthero[idx].no,hbmp,i);	//封装完成
				//GetObject(hbmp, sizeof(BITMAP), &bmp);
				oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2 + (att-idx-1)*35*(i-1)/4 , 57 - 5 *(idx+1) - 8*i , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCAND);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);
			}
			InvalidateRect(hwnd,&rect,false);

			/*ShowFightChoice(attFlag);//轮盘
			ShowHeadPic(0,fighthero[idx].no,50,63);

			ShowNumInPic(79,72,fighthero[idx].hp,0);
			//sprintf_s(tmp,"%d",fighthero[selectedFightHero].hp);
			//ShowText(tmp,79,72,8);
			ShowNumInPic(104,72,fighthero[idx].hpMax,0);
			//sprintf_s(tmp,"%d",fighthero[selectedFightHero].hpMax);
			//ShowText(tmp,104,72,8);

			ShowNumInPic(79,83,fighthero[idx].mp,0);
			//sprintf_s(tmp,"%d",fighthero[selectedFightHero].mp);
			//ShowText(tmp,79,83,8);
			ShowNumInPic(104,83,fighthero[idx].mpMax,0);
			//sprintf_s(tmp,"%d",fighthero[selectedFightHero].mpMax);
			//ShowText(tmp,104,83,8);*/
			CopyToHdc();

			if(Delay(100))returnValue = -1;
		}
	}
	else if(fightType == 6)//逃跑
	{
		for(int i = 0; i<5;i++)//100需改
		{
			BITMAP bwh;
			Show(200+idx);//200+ 逃跑
			//BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);

			int type1 = GetType(RES_PIC,3,fighthero[idx].no);
			if(type1 == 1)
			{
				LoadPic(RES_PIC,3,fighthero[idx].no,hbmp,0);
				HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2  , 57 - 5 *(idx+1)+i*5 , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);
			}
			else
			{
				LoadPicMask(RES_PIC,3,fighthero[idx].no,hbmp,0);
				HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2  , 57 - 5 *(idx+1)+i*5 , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCPAINT);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);

				LoadPicTrans(RES_PIC,3,fighthero[idx].no,hbmp,0);	//封装完成
				//GetObject(hbmp, sizeof(BITMAP), &bmp);
				oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2  , 57 - 5 *(idx+1)+i*5 , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCAND);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);
			}
			InvalidateRect(hwnd,&rect,false);

			CopyToHdc();
			Delay(100);
		}
		/*ShowFightChoice(attFlag);//轮盘
		ShowHeadPic(0,1,50,63);
		char tmp[30];
		sprintf_s(tmp,"%d",fighthero[0].hp);
		ShowText(tmp,79,72,8);
		sprintf_s(tmp,"%d",fighthero[0].hpMax);
		ShowText(tmp,104,72,8);

		sprintf_s(tmp,"%d",fighthero[0].mp);
		ShowText(tmp,79,83,8);
		sprintf_s(tmp,"%d",fighthero[0].mpMax);
		ShowText(tmp,104,83,8);
		BitBlt(hdc,0,60,160,96,hdcTmp,0,60,SRCCOPY);*/

	}
	else if(fightType == 7)//逃跑失败
	{
		for(int i = 0; i<4;i++)//100需改
		{
			BITMAP bwh;
			Show(200+idx);//200+ 逃跑
			//BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);

			int type1 = GetType(RES_PIC,3,fighthero[idx].no);
			if(type1 == 1)
			{
				LoadPic(RES_PIC,3,fighthero[idx].no,hbmp,0);
				HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2  , 57 - 5 *(idx+1)+i*5 , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);
			}
			else
			{
				LoadPicMask(RES_PIC,3,fighthero[idx].no,hbmp,0);
				HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2  , 57 - 5 *(idx+1)+i*5 , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCPAINT);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);

				LoadPicTrans(RES_PIC,3,fighthero[idx].no,hbmp,0);	//封装完成
				//GetObject(hbmp, sizeof(BITMAP), &bmp);
				oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2  , 57 - 5 *(idx+1)+i*5 , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCAND);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);
			}

			InvalidateRect(hwnd,&rect,false);
			CopyToHdc();
			Delay(100);
		}
		BITMAP bwh;
		Show(200+idx);//200+ 逃跑
		//BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);

		int type1 = GetType(RES_PIC,3,fighthero[idx].no);
		if(type1 == 1)
		{
			LoadPic(RES_PIC,3,fighthero[idx].no,hbmp,10);
			HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
			GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
			BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2  , 57 - 5 *(idx+1)+4*5 , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
			SelectObject(hdcMem, oldhbmp);
			DeleteObject(hbmp);
		}
		else
		{
			LoadPicMask(RES_PIC,3,fighthero[idx].no,hbmp,10);
			HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
			GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
			BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2  , 57 - 5 *(idx+1)+4*5 , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCPAINT);
			SelectObject(hdcMem, oldhbmp);
			DeleteObject(hbmp);

			LoadPicTrans(RES_PIC,3,fighthero[idx].no,hbmp,10);	//封装完成
			//GetObject(hbmp, sizeof(BITMAP), &bmp);
			oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
			BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2  , 57 - 5 *(idx+1)+4*5 , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCAND);
			SelectObject(hdcMem, oldhbmp);
			DeleteObject(hbmp);
		}
		InvalidateRect(hwnd,&rect,false);
		CopyToHdc();

		Delay(100);

	}
	else if(fightType == 9)//合击
	{
		for(int i = startPos; i<startPos+sum;i++)//100需改
		{
			BITMAP bwh;
			BITMAP bwh1;
			if(idx ==0 && all_obj == 1)Show(300+2);
			if(idx ==0 && all_obj == 2)Show(300+1);
			if(idx ==1 && all_obj == 2)Show(300+0);
			if(idx ==1 && all_obj == 0)Show(300+2);
			if(idx ==2 && all_obj == 0)Show(300+1);
			if(idx ==2 && all_obj == 1)Show(300+0);
			//BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);

			int type1 = GetType(RES_PIC,3,fighthero[idx].no);
			if(type1 == 1)
			{
				LoadPic(RES_PIC,3,fighthero[idx].no,hbmp,i);
				HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
				BitBlt(hdcTmp, 90 - bwh.bmWidth/2 , 57 - 30  , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);

				HBITMAP hbmp1;
				LoadPic(RES_PIC,3,fighthero[all_obj].no,hbmp1,i);
				HBITMAP oldhbmp1=(HBITMAP)SelectObject(hdcMem, hbmp1);
				GetObject(hbmp1, sizeof (BITMAP), &bwh1) ;//获取位图尺寸	
				BitBlt(hdcTmp, 100 - bwh1.bmWidth/2 , 57 - 10  , bwh1.bmWidth, bwh1.bmHeight, hdcMem, 0, 0, SRCCOPY);
				SelectObject(hdcMem, oldhbmp1);
				DeleteObject(hbmp1);

			}
			else
			{
				LoadPicMask(RES_PIC,3,fighthero[idx].no,hbmp,i);
				HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
				BitBlt(hdcTmp, 90 - bwh.bmWidth/2 , 57 - 30  , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCPAINT);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);

				LoadPicTrans(RES_PIC,3,fighthero[idx].no,hbmp,i);	//封装完成
				//GetObject(hbmp, sizeof(BITMAP), &bmp);
				oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				BitBlt(hdcTmp, 90 - bwh.bmWidth/2  , 57 - 30 , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCAND);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);

				HBITMAP hbmp1;
				LoadPicMask(RES_PIC,3,fighthero[all_obj].no,hbmp1,i);
				HBITMAP oldhbmp1=(HBITMAP)SelectObject(hdcMem, hbmp1);
				GetObject(hbmp1, sizeof (BITMAP), &bwh1) ;//获取位图尺寸	
				BitBlt(hdcTmp, 100 - bwh1.bmWidth/2 , 57 - 10  , bwh1.bmWidth, bwh1.bmHeight, hdcMem, 0, 0, SRCPAINT);
				SelectObject(hdcMem, oldhbmp1);
				DeleteObject(hbmp1);

				LoadPicTrans(RES_PIC,3,fighthero[all_obj].no,hbmp1,i);	//封装完成
				//GetObject(hbmp, sizeof(BITMAP), &bmp);
				oldhbmp1=(HBITMAP)SelectObject(hdcMem, hbmp1);
				BitBlt(hdcTmp, 100 - bwh1.bmWidth/2  , 57 - 10 , bwh1.bmWidth, bwh1.bmHeight, hdcMem, 0, 0, SRCAND);
				SelectObject(hdcMem, oldhbmp1);
				DeleteObject(hbmp1);
			}

			InvalidateRect(hwnd,&rect,false);

			CopyToHdc();

			Delay(100);
		}
	}

	else
	{

		for(int i = startPos; i<startPos+sum;i++)//100需改
		{
			BITMAP bwh;
			Show(100+idx);
			//BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);

			int type1 = GetType(RES_PIC,3,fighthero[idx].no);
			if(type1 == 1)
			{
				LoadPic(RES_PIC,3,fighthero[idx].no,hbmp,i);
				HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2 , 57 - 5 *(idx+1)  , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);

			}
			else
			{
				LoadPicMask(RES_PIC,3,fighthero[idx].no,hbmp,i);
				HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸	
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2 , 57 - 5 *(idx+1)  , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCPAINT);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);

				LoadPicTrans(RES_PIC,3,fighthero[idx].no,hbmp,i);	//封装完成
				//GetObject(hbmp, sizeof(BITMAP), &bmp);
				oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
				BitBlt(hdcTmp, 78 + idx * 35 - bwh.bmWidth/2  , 57 - 5 *(idx+1), bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCAND);
				SelectObject(hdcMem, oldhbmp);
				DeleteObject(hbmp);
			}

			InvalidateRect(hwnd,&rect,false);

			/*ShowFightChoice(attFlag);//轮盘
			ShowHeadPic(0,fighthero[idx].no,50,63);

			ShowNumInPic(79,72,fighthero[idx].hp,0);
			//sprintf_s(tmp,"%d",fighthero[idx].hp);
			//ShowText(tmp,79,72,8);
			ShowNumInPic(104,72,fighthero[idx].hpMax,0);
			//sprintf_s(tmp,"%d",fighthero[selectedFightHero].hpMax);
			//ShowText(tmp,104,72,8);

			ShowNumInPic(79,83,fighthero[idx].mp,0);
			//sprintf_s(tmp,"%d",fighthero[selectedFightHero].mp);
			//ShowText(tmp,79,83,8);
			ShowNumInPic(104,83,fighthero[idx].mpMax,0);
			//sprintf_s(tmp,"%d",fighthero[selectedFightHero].mpMax);
			//ShowText(tmp,104,83,8);*/
			CopyToHdc();

			Delay(100);
		}
	}
	return returnValue;

}

int Fight::ShowFightEnemyPicDirect(int idx,int att,int fightType)//att确定攻击图片显示位置,fightType 确定类型0-普通打 1-法术 2-防御 3-被攻击 8-乱
{
	int returnValue = 0;
	int max = GetMaxPicNumber(RES_ACP,3,fightEnemy[idx].picno);
	if(max == 0)max = 1;
	int delay_t = 500/max;
	for(int i = 0; i<max;i++)//100需改
	{
		BITMAP bwh;
		Show(100+3+idx);
		//BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);

		int type1 = GetType(RES_ACP,3,fightEnemy[idx].picno);
		if(type1==1)
		{
			LoadPic(RES_ACP,3,fightEnemy[idx].picno,hbmp,i);
			HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
			GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸

			if(fightType == 0)//普通打
			{
				BitBlt(hdcTmp, 20 + idx * 35 - bwh.bmWidth/2 + (att-idx+1)*35*(i+1)/max, 20 - 5 * idx + (40/max)*(i+1), bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
			}
			else 
			{
				BitBlt(hdcTmp, 20 + idx * 35 - bwh.bmWidth/2 , 30 - 5 * idx , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCCOPY);
			}
			SelectObject(hdcMem, oldhbmp);
			DeleteObject(hbmp);
		}
		else
		{
			LoadPicMask(RES_ACP,3,fightEnemy[idx].picno,hbmp,i);
			HBITMAP oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
			GetObject(hbmp, sizeof (BITMAP), &bwh) ;//获取位图尺寸

			if(fightType == 0)//普通打
			{
				BitBlt(hdcTmp, 20 + idx * 35 - bwh.bmWidth/2 + (att-idx+1)*35*(i+1)/max, 20 - 5 * idx + (40/max)*(i+1), bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCPAINT);
			}
			else 
			{
				BitBlt(hdcTmp, 20 + idx * 35 - bwh.bmWidth/2 , 30 - 5 * idx , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCPAINT);
			}
			SelectObject(hdcMem, oldhbmp);
			DeleteObject(hbmp);

			LoadPicTrans(RES_ACP,3,fightEnemy[idx].picno,hbmp,i);	//封装完成
			//GetObject(hbmp, sizeof(BITMAP), &bmp);
			oldhbmp=(HBITMAP)SelectObject(hdcMem, hbmp);
			//20160626根据type确定位置
			if(fightType == 0)//普通打
			{
				BitBlt(hdcTmp, 20 + idx * 35 - bwh.bmWidth/2 + (att-idx+1)*35*(i+1)/max, 20 - 5 * idx + (40/max)*(i+1), bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCAND);
			}
			else
			{
				BitBlt(hdcTmp, 20 + idx * 35 - bwh.bmWidth/2 , 30 - 5 * idx , bwh.bmWidth, bwh.bmHeight, hdcMem, 0, 0, SRCAND);
			}

			SelectObject(hdcMem, oldhbmp);
			DeleteObject(hbmp);
		}
		//InvalidateRect(hwnd,&rect,false);


		CopyToHdc();

		if(Delay(delay_t))returnValue = -1;
	}
	return returnValue;
}

int Fight::AISelectedFight(int j)
{
	wlogfile(1, __FUNCTION__ ,"开始",0);
	//20160626 敌人选择攻击类型
	//1-普通 2-技能 9-休眠 10-乱
	int rnd = rand()%100;
	int cmp = fightEnemy[j-3].cleaver;
	int retvalue;
	if(rnd>cmp||fightEnemy[j-3].feng >0)//普通攻击
	{
		retvalue = 1;
	}
	else//魔法
	{
		//选择魔法
		if(fightEnemy[j-3].learnmagic==0)//20160730修正
		{
			retvalue = 1;
		}
		else
		{
			rnd = rand()%fightEnemy[j-3].learnmagic;//学会魔法数
			if(fightEnemy[j-3].mp>=magicList[j].magic[rnd].cost)
			{
				AISelectedMagic[j-3] = rnd;
				fightEnemy[j-3].mp -= magicList[j].magic[rnd].cost;//20181230
				retvalue = 2;
			}
			else//mp不够
			{
				retvalue = 1;
			}
		}

	}
	if(fightEnemy[j-3].mian)
	{
		return 9;
	}
	if(fightEnemy[j-3].ruan)
	{
		return 10;
	}
	return retvalue;
}

int Fight::FightRunAuto()
{
	wlogfile(1, __FUNCTION__ ,"开始",0);
	//GetAutoEnemy();//获取当前第一默认选择敌人
	//selectedFightEnemy[0] = livedEnemy[0];//默认情况
	//if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = livedEnemy[0];
	//if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = livedEnemy[0];
	selectedFightTypeConfirmed[0]=4;
	selectedFightTypeConfirmed[1]=4;
	selectedFightTypeConfirmed[2]=4;
	//g_selectedFightStyle[0] = 4;
	//g_selectedFightStyle[1] = 4;
	//g_selectedFightStyle[2] = 4;

	while(fightEnemy[0].hp||fightEnemy[1].hp||fightEnemy[2].hp)
	{
		GetAutoEnemy();//获取当前第一默认选择敌人
		int ret = FightRun();
		if(ret!=0&&ret!=-10)
		{
			return ret;
		}

		if(ret == -10)break;
		if(Delay(300))break;
	}
	return 0;
}

void Fight::GetAutoEnemy()
{
	tmpselectedEnemy = -1;
	for(int i = 0 ;i <3 ;i++)
	{
		if(fightEnemy[i].hp>0)
		{
			selectedFightEnemy[0] = i;
			if(actorSum>1&&selectedHeroFinished<2)selectedFightEnemy[1] = i;
			if(actorSum>2&&selectedHeroFinished<3)selectedFightEnemy[2] = i;
			tmpselectedEnemy = selectedFightEnemy[0];
			break;
		}
	}

}

void Fight::GetTmpEnemy(int type)
{
	tmpselectedEnemy = -1;
	if(type == 1)//反序 emeny
	{
		for(int i = 2 ;i > -1 ;i--)
		{
			if(fightEnemy[i].hp>0)
			{
				tmpselectedEnemy = i;
				break;
			}
		}
	}
	else if(type == 2)//正序 actor
	{
		for(int i = 0 ;i <3 ;i++)
		{
			if(fighthero[i].hp>0)
			{
				tmpselectedEnemy = i;
				break;
			}
		}
	}
	else if(type == 3)//反序 actor
	{
		for(int i = 2 ;i > -1 ;i--)
		{
			if(fighthero[i].hp>0)
			{
				tmpselectedEnemy = i;
				break;
			}
		}
	}
	else if(type == 4)//正序 emeny
	{
		for(int i = 0 ;i <3 ;i++)
		{
			if(fightEnemy[i].hp>0)
			{
				tmpselectedEnemy = i;
				break;
			}
		}
	}



}

int Fight::CheckWinLose(int type)//20170219增加type
{
	if(fightEnemy[0].hp == 0  &&fightEnemy[1].hp == 0 &&fightEnemy[2].hp == 0)
	{
		return 1;
	}
	if(fighthero[0].hp == 0  && fighthero[1].hp == 0 && fighthero[2].hp == 0)
	{
		return 2;
	}
	if(type == 1)
	{
		if(fightType == 1 && e_roundmax>0 && currentRound >= e_roundmax)//boss战到回合
		{
			return -1;
		}
	}
	return 0;
}

int Fight::DealResult(int result)//1赢2输3逃跑
{
	wlogfile(1, __FUNCTION__ ,"result = ",result);
	//判断结果（胜利/失败）
	if(result == 2)//死亡
	{
		ShowPicDirect(0,RES_PIC,2,13,-1,-1);
		ShowCG(1,249,0,0,2,0,0);
		Sleep(3000);
		//PostQuitMessage(0);//暂时直接退游戏
		return GAMEOVER_FLAG;
	}
	else if(result == 1)
	{
		//钱 经验
		Show(210);//210用于不显示轮盘
		TimerMessageFight(allExp,allMoney,3000);

		//判断是否升级
		for(int i = 0 ;i <3 ;i ++)
		{
			if(flagDied[i]||(actorSum-1)<i)
			{
				continue;
			}
			fighthero[i].exp+=allExp;
			//allMoney
			if(fighthero[i].exp >fighthero[i].expMax&&fighthero[i].expMax>0)//升级//20160816修正经验上限为0升级问题
			{
				fighthero[i].exp -= fighthero[i].expMax;
				fighthero[i].degree++;
				if(fighthero[i].degree>degreeList[i].degreeMax)//20170708修正为升级链最大等级上限
				{
					fighthero[i].degree = degreeList[i].degreeMax;
					fighthero[i].exp += fighthero[i].expMax;
					continue;
				}
				DelHeroLevelUp(i,fighthero[i].degree-1);
				//判断有无技能升级
				if(degreeList[i].learnedMagic[fighthero[i].degree-1] - degreeList[i].learnedMagic[fighthero[i].degree-2]>0)//学会一个
				{
					int tno = degreeList[i].learnedMagic[fighthero[i].degree-1]-1;
					DelMagicLearn(i,tno);
				}
				if(degreeList[i].learnedMagic[fighthero[i].degree-1] - degreeList[i].learnedMagic[fighthero[i].degree-2] - 1 > 0)//学会2个
				{
					int tno = degreeList[i].learnedMagic[fighthero[i].degree-1]-2;
					DelMagicLearn(i,tno);
				}
				if(degreeList[i].learnedMagic[fighthero[i].degree-1] - degreeList[i].learnedMagic[fighthero[i].degree-2] - 2 > 0)//学会3个
				{
					int tno = degreeList[i].learnedMagic[fighthero[i].degree-1]-3;
					DelMagicLearn(i,tno);
				}
				if(degreeList[i].learnedMagic[fighthero[i].degree-1] - degreeList[i].learnedMagic[fighthero[i].degree-2] - 3 > 0)//学会4个
				{
					int tno = degreeList[i].learnedMagic[fighthero[i].degree-1]-4;
					DelMagicLearn(i,tno);
				}
				if(degreeList[i].learnedMagic[fighthero[i].degree-1] - degreeList[i].learnedMagic[fighthero[i].degree-2] - 4 > 0)//学会5个
				{
					int tno = degreeList[i].learnedMagic[fighthero[i].degree-1]-5;
					DelMagicLearn(i,tno);
				}

			}
		}




		//得物品
		char tmp[20];
		int flag = 0;
		int maxlucky = fighthero[0].lucky;
		int degree = fighthero[0].degree;
		if( fighthero[1].lucky > maxlucky)
		{
			maxlucky = fighthero[1].lucky;
			degree = fighthero[1].degree;
		}
		if( fighthero[2].lucky > maxlucky)
		{
			maxlucky = fighthero[2].lucky;
			degree = fighthero[2].degree;
		}
		maxlucky+=(50-degree/2);//20161216增加概率

		int rnd = rand()%100;
		int t_good1 = enemy[0]*2+1;//20161218
		int t_good2 = enemy[1]*2+1;
		int t_good3 = enemy[2]*2+1;
		if(rnd < maxlucky&&enemySum>0&&goodHave[t_good1][0]>0)
		{
			if(goodHave[t_good1][0]>0&&goodList.good[goodHave[t_good1][0]-1][goodHave[t_good1][1]-1].no!=0)//20160901增加0 0 1 物品越界修正
			{
				if(goodHave[t_good1][0]>8)
				{
					goodList.Add(goodHave[t_good1][0],goodHave[t_good1][1],goodHave[t_good1][2]);
				}
				else if(goodHave[t_good1][0] == 8)
				{
					throwList.Add(goodHave[t_good1][0],goodHave[t_good1][1],goodHave[t_good1][2]);
				}
				else 
				{
					equipList.Add(goodHave[t_good1][0],goodHave[t_good1][1],goodHave[t_good1][2]);
				}
				flag++;
			}
		}
		rnd = rand()%100;
		if(rnd < maxlucky&&enemySum>1&&goodHave[t_good2][0]>0)
		{
			if(goodHave[t_good2][0]>0&&goodList.good[goodHave[t_good2][0]-1][goodHave[t_good2][1]-1].no!=0)//20160901增加0 0 1 物品越界修正
			{
				if(goodHave[t_good2][0]>8)
				{
					goodList.Add(goodHave[t_good2][0],goodHave[t_good2][1],goodHave[t_good2][2]);
				}
				else if(goodHave[t_good2][0] == 8)
				{
					throwList.Add(goodHave[t_good2][0],goodHave[t_good2][1],goodHave[t_good2][2]);
				}
				else
				{
					equipList.Add(goodHave[t_good2][0],goodHave[t_good2][1],goodHave[t_good2][2]);
				}
				flag+=2;
			}
		}
		rnd = rand()%100;
		if(rnd < maxlucky&&enemySum>2&&goodHave[t_good3][0]>0)
		{
			if(goodHave[t_good3][0]>0&&goodList.good[goodHave[t_good3][0]-1][goodHave[t_good3][1]-1].no!=0)//20160901增加0 0 1 物品越界修正
			{
				if(goodHave[t_good3][0]>8)
				{
					goodList.Add(goodHave[t_good3][0],goodHave[t_good3][1],goodHave[t_good3][2]);
				}
				else if(goodHave[t_good3][0] == 8)
				{
					throwList.Add(goodHave[t_good3][0],goodHave[t_good3][1],goodHave[t_good3][2]);
				}
				else
				{
					equipList.Add(goodHave[t_good3][0],goodHave[t_good3][1],goodHave[t_good3][2]);
				}
				flag+=4;
			}
		}

		//判断显示
#if 1
		if(flag == 1)
		{
			sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good1][0]-1][goodHave[t_good1][1]-1].name,1);
			TimerMessage(tmp,12,37,8,1,1000);
		}
		if(flag == 2)
		{
			sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good2][0]-1][goodHave[t_good2][1]-1].name,1);
			TimerMessage(tmp,12,37,8,1,1000);
		}
		if(flag == 4)
		{
			sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good3][0]-1][goodHave[t_good3][1]-1].name,1);
			TimerMessage(tmp,12,37,8,1,1000);
		}
		if(flag == 3)
		{
			if((goodHave[t_good1][0]!=goodHave[t_good2][0])&&(goodHave[t_good1][1]!=goodHave[t_good2][1]))
			{
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good1][0]-1][goodHave[t_good1][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good2][0]-1][goodHave[t_good2][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
			}
			else
			{
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good1][0]-1][goodHave[t_good1][1]-1].name,2);
				TimerMessage(tmp,12,37,8,1,1000);
			}
		}
		if(flag == 5)
		{
			if((goodHave[t_good1][0]!=goodHave[t_good3][0])&&(goodHave[t_good1][1]!=goodHave[t_good3][1]))
			{
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good1][0]-1][goodHave[t_good1][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good3][0]-1][goodHave[t_good3][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
			}
			else
			{
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good1][0]-1][goodHave[t_good1][1]-1].name,2);
				TimerMessage(tmp,12,37,8,1,1000);
			}
		}
		if(flag == 6)
		{
			if((goodHave[t_good2][0]!=goodHave[t_good3][0])&&(goodHave[t_good2][1]!=goodHave[t_good3][1]))
			{
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good2][0]-1][goodHave[t_good2][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good3][0]-1][goodHave[t_good3][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
			}
			else
			{
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good2][0]-1][goodHave[t_good2][1]-1].name,2);
				TimerMessage(tmp,12,37,8,1,1000);
			}
		}
		if(flag == 7)
		{
			if((goodHave[t_good1][0]!=goodHave[t_good2][0])&&(goodHave[t_good1][1]!=goodHave[t_good2][1])&&(goodHave[t_good1][0]!=goodHave[t_good3][0])&&(goodHave[t_good1][1]!=goodHave[t_good3][1]))
			{
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good1][0]-1][goodHave[t_good1][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good2][0]-1][goodHave[t_good2][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good3][0]-1][goodHave[t_good3][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
			}
			else if((goodHave[t_good1][0]==goodHave[t_good2][0])&&(goodHave[t_good1][1]==goodHave[t_good2][1])&&(goodHave[t_good1][0]==goodHave[t_good3][0])&&(goodHave[t_good1][1]==goodHave[t_good3][1]))
			{
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good1][0]-1][goodHave[t_good1][1]-1].name,3);
				TimerMessage(tmp,12,37,8,1,1000);
			}
			else if((goodHave[t_good1][0]==goodHave[t_good2][0])&&(goodHave[t_good1][1]==goodHave[t_good2][1]))
			{
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good1][0]-1][goodHave[t_good1][1]-1].name,2);
				TimerMessage(tmp,12,37,8,1,1000);
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good3][0]-1][goodHave[t_good3][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
			}
			else if((goodHave[t_good1][0]==goodHave[t_good3][0])&&(goodHave[t_good1][1]==goodHave[t_good3][1]))
			{
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good1][0]-1][goodHave[t_good1][1]-1].name,2);
				TimerMessage(tmp,12,37,8,1,1000);
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good2][0]-1][goodHave[t_good2][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
			}
			else if((goodHave[t_good2][0]==goodHave[t_good3][0])&&(goodHave[t_good2][1]==goodHave[t_good3][1]))
			{
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good2][0]-1][goodHave[t_good2][1]-1].name,2);
				TimerMessage(tmp,12,37,8,1,1000);
				sprintf_s(tmp,"得到  %s×%d",goodList.good[goodHave[t_good1][0]-1][goodHave[t_good1][1]-1].name,1);
				TimerMessage(tmp,12,37,8,1,1000);
			}
#endif

		}


		//数据到scripteng

	}

	return 0;

}

int Fight::GetRunSpeed()
{
	int herospeed = fighthero[selectedFightHero].speed;
	int enemyspeed = fightEnemy[0].speed;
	if(fightEnemy[1].speed > enemyspeed)enemyspeed = fightEnemy[1].speed ;
	if(fightEnemy[2].speed > enemyspeed)enemyspeed = fightEnemy[2].speed ;
	if((herospeed-enemyspeed)>0)
	{
		return 1;
	}
	else
	{
		return 0;
	}
	return 0;
}

int Fight::DelHeroLevelUp(int i,int degree)
{
	char word[50];
	sprintf_s(word,"%s修行提升！",fighthero[i].name);
	TimerMessage(word,10,37,8,1,1000);

	ShowPic(0,RES_PIC,2,9,-1,-1);
	int val = 0;
	int num = 0;

	/*num = fighthero[i].hp;
	ShowNumInPic(36+16,8,num,0,8);
	fighthero[i].hp = fighthero[i].hpMax - degreeList[i].hpMax[degree-1] + degreeList[i].hpMax[degree] ;
	if(fighthero[i].hp>HPMAX)fighthero[i].hp = HPMAX;
	num = fighthero[i].hp;
	ShowNumInPic(84+16,8,num,0,8);*/

	num = fighthero[i].hpMax;
	ShowNumInPic(56+16,8,num,0,8);
	fighthero[i].hpMax = fighthero[i].hpMax - degreeList[i].hpMax[degree-1] + degreeList[i].hpMax[degree] ;
	if(fighthero[i].hpMax>HPMAX)fighthero[i].hpMax = HPMAX;
	num = fighthero[i].hpMax;
	ShowNumInPic(104+16,8,num,0,8);

	num = fighthero[i].hp;
	ShowNumInPic(36+16,8,num,0,8);
	fighthero[i].hp = fighthero[i].hpMax;//20181007
	if(fighthero[i].hp>HPMAX)fighthero[i].hp = HPMAX;
	num = fighthero[i].hp;
	ShowNumInPic(84+16,8,num,0,8);

	/*num = fighthero[i].mp;
	ShowNumInPic(36+16,20,num,0,8);
	fighthero[i].mp = fighthero[i].mpMax - degreeList[i].mpMax[degree-1] + degreeList[i].mpMax[degree] ;
	if(fighthero[i].mp>MPMAX)fighthero[i].mp = MPMAX;
	num = fighthero[i].mp;
	ShowNumInPic(84+16,20,num,0,8);*/


	num = fighthero[i].mpMax;
	ShowNumInPic(56+16,20,num,0,8);
	fighthero[i].mpMax = fighthero[i].mpMax - degreeList[i].mpMax[degree-1] + degreeList[i].mpMax[degree] ;
	if(fighthero[i].mpMax>MPMAX)fighthero[i].mpMax = MPMAX;
	num = fighthero[i].mpMax;
	ShowNumInPic(104+16,20,num,0,8);

	num = fighthero[i].mp;
	ShowNumInPic(36+16,20,num,0,8);
	fighthero[i].mp = fighthero[i].mpMax;//20181007
	if(fighthero[i].mp>MPMAX)fighthero[i].mp = MPMAX;
	num = fighthero[i].mp;
	ShowNumInPic(84+16,20,num,0,8);


	num = fighthero[i].att ;
	ShowNumInPic(52+16,32,num,0,8);
	fighthero[i].att =  fighthero[i].att - degreeList[i].at[degree-1] + degreeList[i].at[degree];
	if(fighthero[i].att>ATMAX)fighthero[i].att = ATMAX;
	num = fighthero[i].att ;
	ShowNumInPic(100+16,32,num,0,8);

	num = fighthero[i].def;
	ShowNumInPic(52+16,44,num,0,8);
	fighthero[i].def = fighthero[i].def - degreeList[i].df[degree-1] + degreeList[i].df[degree];
	if(fighthero[i].def>DFMAX)fighthero[i].def = DFMAX;
	num = fighthero[i].def;
	ShowNumInPic(100+16,44,num,0,8);

	num = fighthero[i].speed;
	ShowNumInPic(52+16,56,num,0,8);
	fighthero[i].speed = fighthero[i].speed - degreeList[i].speed[degree-1] + degreeList[i].speed[degree];
	if(fighthero[i].speed>SPEEDMAX)fighthero[i].speed = SPEEDMAX;
	num = fighthero[i].speed;
	ShowNumInPic(100+16,56,num,0,8);

	num = fighthero[i].lucky;
	ShowNumInPic(52+16,80,num,0,8);
	fighthero[i].lucky = fighthero[i].lucky - degreeList[i].lucky[degree-1] + degreeList[i].lucky[degree];
	if(fighthero[i].lucky>LUCKMAX)fighthero[i].lucky = LUCKMAX;
	num = fighthero[i].lucky;
	ShowNumInPic(100+16,80,num,0,8);

	num = fighthero[i].anima;
	ShowNumInPic(52+16,68,num,0,8);
	fighthero[i].anima = fighthero[i].anima - degreeList[i].anima[degree-1] + degreeList[i].anima[degree];
	if(fighthero[i].anima>ANIMAMAX)fighthero[i].anima = ANIMAMAX;
	num = fighthero[i].anima;
	ShowNumInPic(100+16,68,num,0,8);

	fighthero[i].expMax = fighthero[i].expMax - degreeList[i].exp[degree-1] + degreeList[i].exp[degree];
	if(degreeList[i].learnedMagic[degree]>= degreeList[i].learnedMagic[degree-1])//20170820
	{
		fighthero[i].magicLearn = fighthero[i].magicLearn - degreeList[i].learnedMagic[degree-1] + degreeList[i].learnedMagic[degree];
	}
	BitBlt(hdc,0,0,800,600,hdcTmp,0,0,SRCCOPY);
	Delay(2000);
	return 0;
}


int Fight::DelMagicLearn(int i,int no)
{
	//fighthero[i].magicLearn++;
	ShowPic(0,RES_PIC,2,10,-1,-1);
	int showPosAdd = strlen(fighthero[i].name);//20160816
	ShowText(fighthero[i].name,80-showPosAdd*4,20);
	showPosAdd = strlen(magicList[i].magic[no+magicList[i].exLearned].name);
	ShowText(magicList[i].magic[no+magicList[i].exLearned].name,80-showPosAdd*4,32+24);//20160729


	CopyToHdc();
	Delay(2000);
	return 0;
}

int Fight::AddHurt(int type,int attObjId)//后续全体法术 增加伤害 1-攻击 2-恢复 3-敌人攻击 4-敌人恢复
{
	if(type == 1)
	{
		for(int i = 0; i < 3;i ++)//20160706修正为3
		{
			if( i == attObjId || flagEnemyDied[i])continue;
			/*fightEnemy[i].hp -= t_hurt;
			s_hurt[i] = t_hurt;
			if(fightEnemy[i].hp<0)
			{
			s_hurt[i] += fightEnemy[i].hp;
			fightEnemy[i].hp = 0;
			flagEnemyDied[i]= 1;
			}*/


		}
	}
	else if(type == 2)
	{
		for(int i = 0; i < 3;i ++)
		{
			if(i == attObjId || flagDied[i])continue;
			fighthero[i].hp += t_hurt;
			//c_hurt[i] = t_hurt;
			if(fighthero[i].hp>fighthero[i].hpMax)
			{
				//c_hurt[i] -=  fighthero[i].hp - fighthero[i].hpMax;
				fighthero[i].hp = fighthero[i].hpMax;
			}
		}
	}
	else if(type == 3)
	{
		for(int i = 0; i < 3;i ++)
		{
			if(i == attObjId || flagDied[i])continue;
			fighthero[i].hp -= t_hurt;
			s_hurt[i] = t_hurt;
			if(fighthero[i].hp<0)
			{
				s_hurt[i] += fighthero[i].hp;
				fighthero[i].hp = 0;
			}

		}
	}
	else if(type == 4)
	{
		for(int i = 0; i < 3;i ++)
		{
			if(i == attObjId || flagEnemyDied[i])continue;
			fightEnemy[i].hp += t_hurt;
			//c_hurt[i] = t_hurt;
			if(fightEnemy[i].hp>fightEnemy[i].hpMax)
			{
				//c_hurt[i] -=  fighthero[i].hp - fighthero[i].hpMax;
				fightEnemy[i].hp = fightEnemy[i].hpMax;
			}
		}
	}
	return 0;
}

void Fight::ShowBuff(int i,int type,int flag1)//0-我方增益 1-敌方毒 2-敌方减
{
	int posX = -50+(i%3)*35+50*(1-i/3);//20160625
	int posY = -(i/3)*30;
	if(i!=-1)//单体
	{
		if(type== 0 && flag1%1000000/10000>0)
		{
			ShowCG(1,MOVIE_FIGHT_GONG,0,0,2,posX,posY);
			//ShowTextDirect("攻",posX,posY,8);
			//Delay(100);
		}
		if(type== 0 && flag1%10000/100>0)
		{
			ShowCG(1,MOVIE_FIGHT_FANG,0,0,2,posX,posY);
			//ShowTextDirect("防",posX,posY,8);
			//(100);
		}
		if(type== 0 && flag1%100>0)
		{
			ShowCG(1,MOVIE_FIGHT_SHU,0,0,2,posX,posY);
			//ShowTextDirect("速",posX,posY,8);
			//Delay(100);
		}
		if(type== 2 && flag1%1000000/10000>0)
		{
			ShowCG(1,MOVIE_FIGHT_GONG,0,0,2,posX,posY);
			//ShowTextDirect("攻",posX,posY,8);
			//Delay(100);
		}
		if(type== 2 && flag1%10000/100>0)
		{
			ShowCG(1,MOVIE_FIGHT_FANG,0,0,2,posX,posY);
			//ShowTextDirect("防",posX,posY,8);
			//Delay(100);
		}
		if(type== 2 && flag1%100>0)
		{
			ShowCG(1,MOVIE_FIGHT_SHU,0,0,2,posX,posY);
			//ShowTextDirect("速",posX,posY,8);
			//Delay(100);
		}
		if(type== 1 && flag1%10000/1000>0)
		{
			ShowCG(1,MOVIE_FIGHT_DU,0,0,2,posX,posY);
			//ShowTextDirect("毒",posX,posY,8);
			//Delay(100);
		}
		if(type== 1 && flag1%1000/100>0)
		{
			ShowCG(1,MOVIE_FIGHT_RUAN,0,0,2,posX,posY);
			//ShowTextDirect("乱",posX,posY,8);
			//Delay(100);
		}
		if(type== 1 && flag1%100/10>0)
		{
			ShowCG(1,MOVIE_FIGHT_FENG,0,0,2,posX,posY);
			//ShowTextDirect("封",posX,posY,8);
			//Delay(100);
		}
		if(type== 1 && flag1%10>0)
		{
			ShowCG(1,MOVIE_FIGHT_MIAN,0,0,2,posX,posY);
			//ShowTextDirect("眠",posX,posY,8);
			//Delay(100);
		}
	}
	else
	{
		if(type== 0 && flag1%1000000/10000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				int ii = j;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_GONG,0,0,2,posX,posY);
				//ShowTextDirect("攻",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 0 && flag1%10000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				int ii = j;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_FANG,0,0,2,posX,posY);
				//ShowTextDirect("防",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 0 && flag1%100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				int ii = j;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_SHU,0,0,2,posX,posY);
				//ShowTextDirect("速",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 2 && flag1%1000000/10000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				int ii = j+3;//livedEnemy[j]+3;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_GONG,0,0,2,posX,posY);
				//ShowTextDirect("攻",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 2 && flag1%10000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				int ii = j+3;//livedEnemy[j]+3;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_FANG,0,0,2,posX,posY);
				//ShowTextDirect("防",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 2 && flag1%100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				int ii = j+3;//livedEnemy[j]+3;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_SHU,0,0,2,posX,posY);
				//ShowTextDirect("速",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 1 && flag1%10000/1000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				int ii = j+3;//livedEnemy[j]+3;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_DU,0,0,2,posX,posY);
				//ShowTextDirect("毒",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 1 && flag1%1000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				int ii = j+3;//livedEnemy[j]+3;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_RUAN,0,0,2,posX,posY);
				//ShowTextDirect("乱",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 1 && flag1%100/10>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				int ii = j+3;//livedEnemy[j]+3;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_FENG,0,0,2,posX,posY);
				//ShowTextDirect("封",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 1 && flag1%10>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				int ii = j+3;//livedEnemy[j]+3;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_MIAN,0,0,2,posX,posY);
				//ShowTextDirect("眠",posX,posY,8);
			}
			//Delay(100);
		}
	}
}

void Fight::GiveBuff(int i,int type,int flag1,int round)//20160625
{
	if(i!=-1)//单体
	{
		if(type== 0 && flag1%1000000/10000>0)//我方攻击增强
		{
			fighthero[i].ateffect=round*100+flag1%1000000/10000;
			ShowBuff(i,type,flag1);//20181125
		}
		if(type== 0 && flag1%10000/100>0)//我方防御增强
		{
			fighthero[i].dfeffect=round*100+flag1%10000/100;
			ShowBuff(i,type,flag1);//20181125
		}
		if(type== 0 && flag1%100>0)//我方速度增强
		{
			fighthero[i].speedeffect=round*100+flag1%100;
			ShowBuff(i,type,flag1);//20181125
		}
		if(type== 2 && flag1%1000000/10000>0)//敌方攻击减弱
		{
			fightEnemy[i-3].ateffect=-round*100-flag1%1000000/10000;
			ShowBuff(i,type,flag1);//20181125
		}
		if(type== 2 && flag1%10000/100>0)//敌方防御减弱
		{
			fightEnemy[i-3].dfeffect=-round*100-flag1%10000/100;
			ShowBuff(i,type,flag1);//20181125
		}
		if(type== 2 && flag1%100>0)//敌方速度减弱
		{
			fightEnemy[i-3].speedeffect=-round*100-flag1%100;
			ShowBuff(i,type,flag1);//20181125
		}
		if(type== 1 && flag1%10000/1000>0)//敌方毒
		{
            if(fightEnemy[i-3].anti%16/8==0)
            {
                fightEnemy[i-3].du=round+1;//20160627 +1用于补足顺序
                ShowBuff(i,type,flag1);//20181125
            }
		}
		if(type== 1 && flag1%1000/100>0)//敌方乱
		{
            if(fightEnemy[i-3].anti%8/4==0)
            {
                fightEnemy[i-3].ruan=round+1;//20160627 +1用于补足顺序
                ShowBuff(i,type,flag1);//20181125
            }
		}
		if(type== 1 && flag1%100/10>0)//敌方封
		{
            if(fightEnemy[i-3].anti%4/2==0)
            {
                fightEnemy[i-3].feng=round+1;//20160627 +1用于补足顺序
                ShowBuff(i,type,flag1);//20181125
            }
		}
		if(type== 1 && flag1%10>0)//敌方眠
		{
            if(fightEnemy[i-3].anti%2==0)
            {
                fightEnemy[i-3].mian=round;
                ShowBuff(i,type,flag1);//20181125
            }
		}

		if(type== 3 && flag1%10000/1000>0)//敌方毒
		{
			fighthero[i].du=0;//20160702
		}
		if(type== 3 && flag1%1000/100>0)//敌方乱
		{
			fighthero[i].ruan=0;//20160702
		}
		if(type== 3 && flag1%100/10>0)//敌方封
		{
			fighthero[i].feng=0;//20160702
		}
		if(type== 3 && flag1%10>0)//敌方眠
		{
			fighthero[i].mian=0;//20160702
		}
	}
	else
	{
		if(type== 0 && flag1%1000000/10000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				fighthero[j].ateffect=round*100+flag1%1000000/10000;
				ShowBuff(j,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 0 && flag1%10000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				fighthero[j].dfeffect=round*100+flag1%10000/100;
				ShowBuff(j,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 0 && flag1%100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				fighthero[j].speedeffect=round*100+flag1%100;
				ShowBuff(j,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 2 && flag1%1000000/10000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				fightEnemy[j].ateffect=-round*100-flag1%1000000/10000;
				ShowBuff(j+3,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 2 && flag1%10000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				fightEnemy[j].dfeffect=-round*100-flag1%10000/100;
				ShowBuff(j+3,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 2 && flag1%100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				fightEnemy[j].speedeffect=-round*100-flag1%100;
				ShowBuff(j+3,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 1 && flag1%10000/1000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
                if(fightEnemy[j].anti%16/8==0)
                {
                    fightEnemy[j].du=round+1;//20160627 +1用于补足顺序
                    ShowBuff(j+3,type,flag1);//20181125
                }
			}
			//Delay(100);
		}
		if(type== 1 && flag1%1000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
                if(fightEnemy[j].anti%8/4==0)
                {
                    fightEnemy[j].ruan=round+1;//20160627 +1用于补足顺序
                    ShowBuff(j+3,type,flag1);//20181125
                }
			}
			//Delay(100);
		}
		if(type== 1 && flag1%100/10>0)
		{
			for(int j = 0 ;j < 3 ;j++)//20160627 改3
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
                if(fightEnemy[j].anti%4/2==0)
                {
                    fightEnemy[j].feng=round+1;//20160627 +1用于补足顺序
                    ShowBuff(j+3,type,flag1);//20181125
                }
			}
			//Delay(100);
		}
		if(type== 1 && flag1%10>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
                if(fightEnemy[j].anti%2==0)
                {
                    fightEnemy[j].mian=round;
                    ShowBuff(j+3,type,flag1);//20181125
                }
			}
			//Delay(100);
		}
		if(type== 3 && flag1%10000/1000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				fighthero[j].du=0;//20160702
			}
			//Delay(100);
		}
		if(type== 3 && flag1%1000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				fighthero[j].ruan=0;//20160702
			}
			//Delay(100);
		}
		if(type== 3 && flag1%100/10>0)
		{
			for(int j = 0 ;j < 3 ;j++)//20160627 改3
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				fighthero[j].feng=0;//20160702
			}
			//Delay(100);
		}
		if(type== 3 && flag1%10>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				fighthero[j].mian=0;//20160702
			}
			//Delay(100);
		}
	}
}

int Fight::CanUseMagic()
{
	if(fighthero[selectedFightHero].feng>0)
	{
		return 0;
	}
	return 1;
}

void Fight::DealMian()//20160626
{
	if(fighthero[selectedFightHero].mian>0)//20160626眠
	{
		selectedFightStyle = 9;
		selectedHeroFinished ++;
		selectedFightEnemy[selectedFightHero] = 0;
		selectedFightTypeConfirmed[selectedFightHero] = selectedFightStyle;
		selectedFightStyle = 0 ;
		selectedFightHero++;
	}
	if(fighthero[selectedFightHero].mian>0)//20160626眠 2次判断
	{
		selectedFightStyle = 9;
		selectedHeroFinished ++;
		selectedFightEnemy[selectedFightHero] = 0;
		selectedFightTypeConfirmed[selectedFightHero] = selectedFightStyle;
		selectedFightStyle = 0 ;
		selectedFightHero++;
	}
}

void Fight::AIGiveBuff(int i,int type,int flag1,int round)//20160626
{
	if(i!=-1)//单体
	{
		if(type== 0 && flag1%1000000/10000>0)//我方攻击增强
		{
			fightEnemy[i-3].ateffect=round*100+flag1%1000000/10000;
			AIShowBuff(i,type,flag1);//20181125
		}
		if(type== 0 && flag1%10000/100>0)//我方防御增强
		{
			fightEnemy[i-3].dfeffect=round*100+flag1%10000/100;
			AIShowBuff(i,type,flag1);//20181125
		}
		if(type== 0 && flag1%100>0)//我方速度增强
		{
			fightEnemy[i-3].speedeffect=round*100+flag1%100;
			AIShowBuff(i,type,flag1);//20181125
		}
		if(type== 2 && flag1%1000000/10000>0)//敌方攻击减弱
		{
			fighthero[i].ateffect=-round*100-flag1%1000000/10000;
			AIShowBuff(i,type,flag1);//20181125
		}
		if(type== 2 && flag1%10000/100>0)//敌方防御减弱
		{
			fighthero[i].dfeffect=-round*100-flag1%10000/100;
			AIShowBuff(i,type,flag1);//20181125
		}
		if(type== 2 && flag1%100>0)//敌方速度减弱
		{
			fighthero[i].speedeffect=-round*100-flag1%100;
			AIShowBuff(i,type,flag1);//20181125
		}
		if(type== 1 && flag1%10000/1000>0)//敌方毒
		{
			//20181021add fightheroaniti判断
            if(fighthero[i].anti%16/8==0)
            {
                fighthero[i].du=round+1;//20160627 +1用于补足顺序
				AIShowBuff(i,type,flag1);//20181125
            }
		}
		if(type== 1 && flag1%1000/100>0)//敌方乱
		{
			//20181021add fightheroaniti判断
            if(fighthero[i].anti%8/4==0)
            {
                fighthero[i].ruan=round+1;//20160627 +1用于补足顺序
				AIShowBuff(i,type,flag1);//20181125
            }
		}
		if(type== 1 && flag1%100/10>0)//敌方封
		{
			//20181021add fightheroaniti判断
            if(fighthero[i].anti%4/2==0)
            {
                fighthero[i].feng=round+1;//20160627 +1用于补足顺序
				AIShowBuff(i,type,flag1);//20181125
            }
		}
		if(type== 1 && flag1%10>0)//敌方眠
		{
			//20181021add fightheroaniti判断
            if(fighthero[i].anti%2==0)
            {
                fighthero[i].mian=round;
				AIShowBuff(i,type,flag1);//20181125
            }
		}
	}
	else
	{
		if(type== 0 && flag1%1000000/10000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				fightEnemy[j].ateffect=round*100+flag1%1000000/10000;
				AIShowBuff(j+3,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 0 && flag1%10000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				fightEnemy[j].dfeffect=round*100+flag1%10000/100;
				AIShowBuff(j+3,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 0 && flag1%100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				fightEnemy[j].speedeffect=round*100+flag1%100;
				AIShowBuff(j+3,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 2 && flag1%1000000/10000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				fighthero[j].ateffect=-round*100-flag1%1000000/10000;
				AIShowBuff(j,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 2 && flag1%10000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				fighthero[j].dfeffect=-round*100-flag1%10000/100;
				AIShowBuff(j,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 2 && flag1%100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				fighthero[j].speedeffect=-round*100-flag1%100;
				AIShowBuff(j,type,flag1);//20181125
			}
			//Delay(100);
		}
		if(type== 1 && flag1%10000/1000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				//20181021add fightheroaniti判断
                if(fighthero[j].anti%16/8==0)
                {
                    fighthero[j].du=round+1;//20160627 +1用于补足顺序
					AIShowBuff(j,type,flag1);//20181125
                }
			}
			//Delay(100);
		}
		if(type== 1 && flag1%1000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				//20181021add fightheroaniti判断
				if(fighthero[j].anti%8/4==0)
                {
                    fighthero[j].ruan=round+1;//20160627 +1用于补足顺序
					AIShowBuff(j,type,flag1);//20181125
                }
			}
			//Delay(100);
		}
		if(type== 1 && flag1%100/10>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				//20181021add fightheroaniti判断
				if(fighthero[j].anti%4/2==0)
                {
                    fighthero[j].feng=round+1;//20160627 +1用于补足顺序
					AIShowBuff(j,type,flag1);//20181125
                }
			}
			//Delay(100);
		}
		if(type== 1 && flag1%10>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				//20181021add fightheroaniti判断
                if(fighthero[j].anti%2==0)
                {
                    fighthero[j].mian=round;
					AIShowBuff(j,type,flag1);//20181125
                }
			}
			//Delay(100);
		}
	}
}

void Fight::AIShowBuff(int i,int type,int flag1)//0-我方增益 1-敌方毒 2-敌方减
{
	wlogfile(1, __FUNCTION__ ,"开始",0);
	int posX = -50+(i%3)*35+50*(1-i/3);//20160625
	int posY = -(i/3)*30;
	if(i!=-1)//单体
	{
		if(type== 0 && flag1%1000000/10000>0)
		{
			ShowCG(1,MOVIE_FIGHT_GONG,0,0,2,posX,posY);
			//ShowTextDirect("攻",posX,posY,8);
			//Delay(100);
		}
		if(type== 0 && flag1%10000/100>0)
		{
			ShowCG(1,MOVIE_FIGHT_FANG,0,0,2,posX,posY);
			//ShowTextDirect("防",posX,posY,8);
			//(100);
		}
		if(type== 0 && flag1%100>0)
		{
			ShowCG(1,MOVIE_FIGHT_SHU,0,0,2,posX,posY);
			//ShowTextDirect("速",posX,posY,8);
			//Delay(100);
		}
		if(type== 2 && flag1%1000000/10000>0)
		{
			ShowCG(1,MOVIE_FIGHT_GONG,0,0,2,posX,posY);
			//ShowTextDirect("攻",posX,posY,8);
			//Delay(100);
		}
		if(type== 2 && flag1%10000/100>0)
		{
			ShowCG(1,MOVIE_FIGHT_FANG,0,0,2,posX,posY);
			//ShowTextDirect("防",posX,posY,8);
			//Delay(100);
		}
		if(type== 2 && flag1%100>0)
		{
			ShowCG(1,MOVIE_FIGHT_SHU,0,0,2,posX,posY);
			//ShowTextDirect("速",posX,posY,8);
			//Delay(100);
		}
		if(type== 1 && flag1%10000/1000>0)
		{
			ShowCG(1,MOVIE_FIGHT_DU,0,0,2,posX,posY);
			//ShowTextDirect("毒",posX,posY,8);
			//Delay(100);
		}
		if(type== 1 && flag1%1000/100>0)
		{
			ShowCG(1,MOVIE_FIGHT_RUAN,0,0,2,posX,posY);
			//ShowTextDirect("乱",posX,posY,8);
			//Delay(100);
		}
		if(type== 1 && flag1%100/10>0)
		{
			ShowCG(1,MOVIE_FIGHT_FENG,0,0,2,posX,posY);
			//ShowTextDirect("封",posX,posY,8);
			//Delay(100);
		}
		if(type== 1 && flag1%10>0)
		{
			ShowCG(1,MOVIE_FIGHT_MIAN,0,0,2,posX,posY);
			//ShowTextDirect("眠",posX,posY,8);
			//Delay(100);
		}
	}
	else
	{
		if(type== 0 && flag1%1000000/10000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				int ii = j+3;//20160627
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_GONG,0,0,2,posX,posY);
				//ShowTextDirect("攻",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 0 && flag1%10000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				int ii = j+3;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_FANG,0,0,2,posX,posY);
				//ShowTextDirect("防",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 0 && flag1%100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				int ii = j+3;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_SHU,0,0,2,posX,posY);
				//ShowTextDirect("速",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 2 && flag1%1000000/10000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagEnemyDied[j]||fightEnemy[j].no==0)continue;
				int ii = j+3;
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_GONG,0,0,2,posX,posY);
				//ShowTextDirect("攻",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 2 && flag1%10000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				int ii = j;//20160627
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_FANG,0,0,2,posX,posY);
				//ShowTextDirect("防",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 2 && flag1%100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				int ii = j;//20160627
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_SHU,0,0,2,posX,posY);
				//ShowTextDirect("速",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 1 && flag1%10000/1000>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				int ii = j;//20160627
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_DU,0,0,2,posX,posY);
				//ShowTextDirect("毒",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 1 && flag1%1000/100>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				int ii = j;//20160627
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_RUAN,0,0,2,posX,posY);
				//ShowTextDirect("乱",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 1 && flag1%100/10>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				int ii = j;//20160627
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_FENG,0,0,2,posX,posY);
				//ShowTextDirect("封",posX,posY,8);
			}
			//Delay(100);
		}
		if(type== 1 && flag1%10>0)
		{
			for(int j = 0 ;j < 3 ;j++)
			{
				if(flagDied[j]||fighthero[j].no==0)continue;
				int ii = j;//20160627
				posX = -50+(ii%3)*35+50*(1-ii/3);
				posY = -(ii/3)*30;
				ShowCG(1,MOVIE_FIGHT_MIAN,0,0,2,posX,posY);
				//ShowTextDirect("眠",posX,posY,8);
			}
			//Delay(100);
		}
	}
}

int Fight::CheckTo(int j)//1-普通 2-技能 3-合击 4-围攻 5-投掷  6-补给自己 7-防御 8-逃跑 9-休眠 10-乱
{
	if(selectedFightTypeConfirmed[j]==1||selectedFightTypeConfirmed[j]==3||selectedFightTypeConfirmed[j]==4||selectedFightTypeConfirmed[j]==5)
	{
		return 0;
	}
	else if(selectedFightTypeConfirmed[j]==6||selectedFightTypeConfirmed[j]==7)
	{
		return 1;
	}
	else if(selectedFightTypeConfirmed[j]==2)
	{
		if(magicList[j].magic[selectedMagic[j]].type == 1)
		{
			return 0;
		}
		return 1;
	}
	return 0;
}

void Fight::CountSpecialRecover(int j)
{
	if(j<3)//玩家
	{
		if(fighthero[j].hpAdd>0)
		{
			fighthero[j].hp+=fighthero[j].hpAdd;

			if(fighthero[j].hp>fighthero[j].hpMax)
			{
				fighthero[j].hp=fighthero[j].hpMax;
			}
			ShowHurt(j,-fighthero[j].hpAdd);
			CopyToHdc();
			Delay(500);
		}
		if(fighthero[j].mpAdd>0)
		{
			fighthero[j].mp+=fighthero[j].mpAdd;

			if(fighthero[j].mp>fighthero[j].mpMax)
			{
				fighthero[j].mp=fighthero[j].mpMax;
			}
			ShowHurt(j,-fighthero[j].mpAdd);
			CopyToHdc();
			Delay(500);
		}
		
	}

	return;
}

int Fight::GetAllMagicHP(int magicno)
{
	Magic t_magic;
	t_magic.Init(1,magicno);
	return t_magic.hp;
}

int Fight::CountSkillHurt(int hp,int myanima,int enanima)//20170125增加计算技能伤害值公式
{
	int myanimatimes = hp  / 64 ;
	int tmphp = hp + myanimatimes * myanima;
	int enanimatimes = tmphp  / 64 ;
	int hurt = tmphp - enanimatimes * enanima ;

	//增加1/16的波动
	//%16
	int uphurt = 0;
	if(hurt <= 16) 
	{
		uphurt = 0;
	}
	else
	{
		uphurt = rand()%(hurt / 16) ;
	}
	hurt += uphurt;
	//hurt = hp + hp  / 64 * myanima - (hp + hp  / 64 * myanima)  / 64 * enanima;

	if(hurt < 0 ) 
	{
		if( disableAnima == 0)//20170820
		{
			hurt = 999999;
		}
        else if( disableAnima == 1)
		{
            hurt = 100;
		}
        else if( disableAnima == 2)//20181031
        {
            if(myanima>64)myanima = 60;
            if(enanima>64)enanima = 60;
            hurt = 0;
            myanimatimes = hp  / 64 ;
            tmphp = hp + myanimatimes * myanima;
            enanimatimes = tmphp  / 64 ;
            hurt = tmphp - enanimatimes * enanima ;

            //增加1/16的波动
            //%16
            uphurt = 0;
            if(hurt <= 16)
            {
                uphurt = 0;
            }
            else
            {
                uphurt = rand()%(hurt / 16) ;
            }
            hurt += uphurt;
        }
	}
	return hurt;
}

int Fight::CountNormalHurt(int type,int tatt,int tdef)////20170125 type 0-我方打敌人 1-敌人打我
{
	int hurt = 0;
	if(type == 0)
	{
		int tdeftimes = tdef / 8;
		if(tdeftimes == 0) tdeftimes = 1;
		hurt = tatt / tdeftimes;


		//y=0.25x-1.5
		int uphurtmax = (int)(hurt / 4 - 1.5);
		if(uphurtmax <=0)uphurtmax = 10;
		int uphurt = rand() % uphurtmax ;
		hurt += uphurt;
	}
	else
	{
		int tdeftimes = tdef / 8 + 1;
		hurt = tatt / tdeftimes;

		//%16
		int uphurt = 0;
		if(hurt <= 16) 
		{
			uphurt = 0;
		}
		else
		{
			uphurt = rand()%(hurt / 16) ;
		}
		hurt += uphurt;
	}
	return hurt;
}

int Fight::GetMissResult(int type,int from,int to)//20170130计算MISS的两个对象，type 0-我方打敌人 1-敌人打我1-miss 0-不miss
{
	int rnd = rand()%100;
	if(type == 0)
	{
		int herospeed = fighthero[from].speed;
		int enemyspeed = fightEnemy[to].speed;
		if((herospeed-enemyspeed)>0)
		{
			if(rnd > 10)return 0;//20170420 20-》10
			return 1;
		}
		else
		{
			if(rnd > 40)return 0;//20170420 70-》40
			return 1;
		}
	}
	else
	{
		int enemyspeed = fightEnemy[from].speed;
		int herospeed = fighthero[to].speed;
		if((enemyspeed-herospeed)>0)
		{
			if(rnd > 10)return 0;//20170420 20-》10
			return 1;
		}
		else
		{
			if(rnd > 80)return 0;//20170420 70-》40
			return 1;
		}
	}
}

int Fight::CheckAntiCauseBy(int type,int goodType,int goodIdx,int usedecorateflag)
{
	
	int head = fighthero[t_selectedFightHero].head;
	int body = fighthero[t_selectedFightHero].body;
	int shoulder = fighthero[t_selectedFightHero].shoulder;//17-肩披，
	int sleeve = fighthero[t_selectedFightHero].sleeve;//18-护腕，
	int hand = fighthero[t_selectedFightHero].hand;//19-手持，
	int foot = fighthero[t_selectedFightHero].foot;//20-脚蹬，
	int decorate1 = fighthero[t_selectedFightHero].decorate1;//21-佩戴1，
	int decorate2 = fighthero[t_selectedFightHero].decorate2;//22-佩戴2，


	if(goodType == 0)//head
	{
		if(type == 1)
		{

			if(goodList.good[1][body].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag / 8 >0)return 0; 
		}
		else if(type == 2)
		{

			if(goodList.good[1][body].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 8 /4 >0)return 0; 
		}
		else if(type == 3)
		{

			if(goodList.good[1][body].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag% 4 /2 >0)return 0; 
		}
		else if(type == 4)
		{

			if(goodList.good[1][body].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag  % 2 >0)return 0; 
		}

	}
	if(goodType == 1)//body
	{
		if(type == 1)
		{

			if(goodList.good[0][head].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag / 8 >0)return 0; 
		}
		else if(type == 2)
		{

			if(goodList.good[0][head].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 8 /4>0)return 0; 
		}
		else if(type == 3)
		{

			if(goodList.good[0][head].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 4 /2 >0)return 0; 
		}
		else if(type == 4)
		{

			if(goodList.good[0][head].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag  % 2 >0)return 0; 
		}
	}
	if(goodType == 2)//foot
	{
		if(type == 1)
		{
			if(goodList.good[0][head].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag / 8 >0)return 0; 
		}
		else if(type == 2)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 8 /4 >0)return 0; 
		}
		else if(type == 3)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 4 /2 >0)return 0; 
		}
		else if(type == 4)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 2 >0)return 0; 
		}
	}
	if(goodType == 3)//shoulder
	{
		if(type == 1)
		{
			if(goodList.good[0][head].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag / 8 >0)return 0; 
		}
		else if(type == 2)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 8 /4 >0)return 0; 
		}
		else if(type == 3)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 4 /2 >0)return 0; 
		}
		else if(type == 4)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 2 >0)return 0; 
		}
	}
	if(goodType == 4)//sleeve
	{
		if(type == 1)
		{
			if(goodList.good[0][head].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag / 8 >0)return 0; 
		}
		else if(type == 2)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag% 8 /4 >0)return 0; 
		}
		else if(type == 3)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 4 /2 >0)return 0; 
		}
		else if(type == 4)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag  % 2 >0)return 0; 
		}
	}
	if(goodType == 5 && usedecorateflag == 1)//decorate1 
	{
		if(type == 1)
		{
			if(goodList.good[0][head].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag / 8 >0)return 0;  
			if(goodList.good[5][decorate2].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag / 8 >0)return 0; 
		}
		else if(type == 2)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 8 /4 >0)return 0; 
		}
		else if(type == 3)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 4 /2 >0)return 0; 
		}
		else if(type == 4)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag  % 2 >0)return 0; 
		}
	}
	if(goodType == 5 && usedecorateflag == 2 )//decorate2
	{
		if(type == 1)
		{
			if(goodList.good[0][head].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag / 8 >0)return 0; 
		}
		else if(type == 2)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 8 /4 >0)return 0; 
		}
		else if(type == 3)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag % 4 /2 >0)return 0; 
		}
		else if(type == 4)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[6][hand].all_dlfm_Flag  % 2 >0)return 0; 
		}
	}
	if(goodType == 6)//hand
	{
		if(type == 1)
		{
			if(goodList.good[0][head].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag / 8 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag / 8 >0)return 0; 
			
		}
		else if(type == 2)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 8 /4 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 8 /4 >0)return 0; 
			
		}
		else if(type == 3)
		{
			if(goodList.good[0][head].all_dlfm_Flag% 4 /2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 4 /2>0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 4 /2 >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 4 /2 >0)return 0; 
			
		}
		else if(type == 4)
		{
			if(goodList.good[0][head].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[1][body].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[2][foot].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[3][shoulder].all_dlfm_Flag % 2 >0)return 0; 
			if(goodList.good[4][sleeve].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate1].all_dlfm_Flag % 2  >0)return 0; 
			if(goodList.good[5][decorate2].all_dlfm_Flag % 2  >0)return 0;  
		}

	}
	return 1;

	//roleList.actor[act[selectedRoleIdx]].anti + goodList.good[equipType-1][equipIdx-1].all_dlfm_Flag
}