Example #1
0
/*
void Slime::BeginContact(GameObject* other, b2Contact* contact)
{
	if (other->getType() == TYPE_HERO)
	{
		Hero* hero = GameManager::getInstance()->hero;
		if (hero->isDie())
			return;
		hero->setHp(hero->getHp() - SD_INT("slime_int_atk"));
		//Ó¢ÐÛÎÞµÐ0.5Ãë
		hero->setUnbeatable(0.5);

		//»ñÈ¡Åöײºó²úÉúµÄºÏÁ¦·½Ïò
		float y = contact->GetManifold()->localNormal.y;
		if (y > 0)
		{
			b2Vec2 vec = hero->getBody()->GetLinearVelocity();
			vec.y = SD_FLOAT("slime_float_atk_jump");
			//ʹӢÐÛÌøÔ¾
			hero->getBody()->SetLinearVelocity(vec);
			//É˺¦Ê·À³Ä·
			this->setHp(getHp()-1);
		}
	}
}
*/
void Slime::PreSolve(GameObject* other, b2Contact* contact, const b2Manifold* oldManifold)
{
	if (other->getType() == TYPE_HERO)
	{
		Hero* hero = GameManager::getInstance()->hero;
		if (hero->isDie())
			return;
		hero->setHp(hero->getHp() - SD_INT("slime_int_atk"));
		//Ó¢ÐÛÎÞµÐ0.5Ãë
		hero->setUnbeatable(SD_FLOAT("slime_float_unbeatable"));

		//»ñÈ¡Åöײºó²úÉúµÄºÏÁ¦·½Ïò
		float y = contact->GetManifold()->localNormal.y;
		if (y > 0)
		{
			b2Vec2 vec = hero->getBody()->GetLinearVelocity();
			vec.y = SD_FLOAT("slime_float_atk_jump");
			//ʹӢÐÛÌøÔ¾
			hero->getBody()->SetLinearVelocity(vec);
			//É˺¦Ê·À³Ä·
			this->setHp(getHp()-1);
		}
	}
}
// 自己打自己的实现
BaseHero* ClientTestProvider::getBaseHero(unsigned int _heroId,ScriptBuilderUserData user_data)
{
	short cdTime;
	getHeroCDTime(cdTime,_heroId,user_data);
	// 直接取本地的英雄的数据
	vector<BaseActor*> actors = MyselfManager::getManager()->getTeamActors_ZhenShen(Actor_ShangZheng);
	int actorNum = actors.size();
	BaseActor* actor = actors[(_heroId-1)%actorNum];

	
	Hero* ret = new Hero();
	ret->init(actor->getCurrentProperty());
	// 不用装备
	ret->equipVec.clear();
	ret->skilVec.clear();

	switch (actor->getActorType())
	{
	case Profession_Yemanren:
		ret->skilVec.push_back(SkillDataForFight(SkillType_BaoLieZhan));
		break;
	case Profession_Chike:
		ret->skilVec.push_back(SkillDataForFight(SkillType_ShaLu));
		break;
	case Profession_Fashi:
		ret->skilVec.push_back(SkillDataForFight(SkillType_ShanDian));
		break;
	case Profession_Qishi:
		ret->skilVec.push_back(SkillDataForFight(SkillType_JianShou));
		break;
	case Profession_ShenJianShou:
		ret->skilVec.push_back(SkillDataForFight(SkillType_LieGong));
		break;
	case Profession_MiShu:
		ret->skilVec.push_back(SkillDataForFight(SkillType_HuoQiuShu));
		break;
	case Profession_WuSeng:
		ret->skilVec.push_back(SkillDataForFight(SkillType_ShenZhiXingNian));
		break;
	case Profession_YouXia:
		ret->skilVec.push_back(SkillDataForFight(SkillType_ShunYinTuXi));
		break;
	case Profession_LieShou:
		ret->skilVec.push_back(SkillDataForFight(SkillType_JianYu));
		break;
	case Profession_WuShi:
		ret->skilVec.push_back(SkillDataForFight(SkillType_WenYi));
		break;
	default:
		break;
	}

	vector<Equipment*> equips = actor->getEquipments();
	int equipsNum = equips.size();
	for (int i=0;i<equipsNum;i++)
	{
		ret->equipVec.push_back(equips[i]->getEquipData());
	}
	if (user_data.teamTag > 0)
	{
		// 回血
		if (((FightSUD*)user_data.data)->fightIndex > 0)
		{
			for (int i=0;i<FormationHeroAcountMax;i++)
			{
				if (((FightSUD*)user_data.data)->heroHpAfterLastFight.A_teamHeroId[i] == _heroId)
				{
					ret->zhuangbeiOpEnd();
					//修改血
					float hp = ret->getHp();
					hp *= 0.15f;
					hp += ((FightSUD*)user_data.data)->heroHpAfterLastFight.currentHp_A[i];
					if(hp > ret->getHp())
					{
						hp = ret->getHp();
					}
					ret->subHp(ret->getHp() - hp);
				}
			}
		}
		else
		{
			ret->zhuangbeiOpEnd();
		}
	}

	return ret;

}
BaseHero* ClientTestProvider::getBaseHero(unsigned int _heroId,ScriptBuilderUserData user_data)
{
	short cdTime;
	getHeroCDTime(cdTime,_heroId,user_data);

	Profession proA[] = {Profession_Yemanren,Profession_Yemanren,Profession_Qishi,Profession_WuSeng};
	SkillType skill_A[] = {SkillType_BaoLieZhan,SkillType_BaoLieZhan,SkillType_JianShou,SkillType_ShenZhiXingNian};

	int proB[] = {23,24,40,40};
	float gongJiJuLi_B[] = {1,10.0f,2,2};
	int jinengchufalv[] = {100,100,100,100};
	int jinengchufalv_B[] = {0,0,0,0};
	int guaiwu_x_size[] = {1,1,1,1};

	// A 队
	if (user_data.teamTag > 0)
	{
		//
		Hero* ret = new Hero();
		// test
		{
			// 不用装备
			ret->equipVec.clear();
			ret->skilVec.clear();

			HeroBaseProperty data;
			data.hero_id= _heroId;
			data.profession = proA[(_heroId-1) % 4];
			data.level = 10;

			data.exp_current = 20;
			data.exp_need = 2000;
			data.parent_hero_id = 0;
			data.postion = 1;
			data.vit_current = 100;

			data.mLiLiang = 4 + 4*lfRandom0_1();
			data.mMinJie = 500+6*lfRandom0_1();
			data.mZhiLi = 6 + 10*lfRandom0_1();
			data.mTiNeng = 0;
			data.vit_current = 200;
			data.mHP = 200;
			data.mGongJiJuLi = CS::getHeroGongjiJuLiByProfession(data.profession);
			data.mBaoJiLv = 100;
			data.mBaoJiShangHaiYinZi = 500;
			data.mJiNengFaChuLv = jinengchufalv[(_heroId-1) % 4];
			data.mShangHaiLeiXing = SHANG_HAI_WU_LI;
			data.currentStage = 1;
			data.currentEffectPercent = 300;
			data.isYuanShen = false;

			ret->init(data);
			ret->setDefaultCdTime(cdTime);
			ret->skilVec.push_back(SkillDataForFight(skill_A[(_heroId-1) % 4]));

			// 加装备,测试
			{
				EquipData zhuangbei;
				zhuangbei.gongji_max = 2;
				zhuangbei.gongji_min = 1;
				zhuangbei.hole = 3;
				zhuangbei.hujia = 2;
				zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
				zhuangbei.equipDicrib = "equipDicrib";
				zhuangbei.zhuangbei_hero_id = 1;
				zhuangbei.zhuangbei_id = 2;
				zhuangbei.zhuangbei_level = 3;
				zhuangbei.equipName = "equipName";

				ZBAttr atti;
				atti.attr_type = AttrType_mingjie;
				atti.cuiqu_suc_ratio = 0;
				atti.attr_value = 1;
				zhuangbei.attr_vec.push_back(atti);

				if (data.profession == Profession_Yemanren)
				{
					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_dsj_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_DanshouJian;
					ret->equipVec.push_back(zhuangbei);

					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_dunp_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_Dunpai;
					ret->equipVec.push_back(zhuangbei);

					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_jz_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_Jiezhi;
					ret->equipVec.push_back(zhuangbei);
					ret->equipVec.push_back(zhuangbei);


					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_hsf_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_Hushenfu;
					ret->equipVec.push_back(zhuangbei);

					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_hsf_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_KuijiaZhong;
					ret->equipVec.push_back(zhuangbei);
				}
				else if(data.profession == Profession_Qishi)
				{
					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_fu_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_Dunpai;
					ret->equipVec.push_back(zhuangbei);
				}
				else if(data.profession == Profession_MiShu)
				{
					BaseActor* misu = NULL;
					{
						vector<BaseActor*> actors = MyselfManager::getManager()->getMyZhuShous_ZhenShen(Actor_ShangZheng);
						int size = actors.size();
						for (int i=0;i<size;i++)
						{
							if (actors[i]->getActorType() == Profession_MiShu)
							{
								misu = actors[i];
								break;
							}
						}
					}

					// 找到就用外面的配置
					if (misu)
					{
						vector<Equipment*> equips = misu->getEquipments();
						int equipsNum = equips.size();
						for (int i=0;i<equipsNum;i++)
						{
							ret->equipVec.push_back(equips[i]->getEquipData());
						}
					}
					else
					{
						zhuangbei.zhuangbei_colour = ZhuangbeiColour_Baizhuang;
						zhuangbei.equipPic = "zb_fz_ss_1";
						zhuangbei.zhuangbei_type = ZhuangbeiType_ShuangshouFazhang;
						ret->equipVec.push_back(zhuangbei);
					}

					
				}
				else if(data.profession == Profession_ShenJianShou)
				{
					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_gong_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_Gong;
					ret->equipVec.push_back(zhuangbei);
				}
			}

			// 回血
			if ( ((FightSUD*)user_data.data)->fightIndex > 0)
			{
				for (int i=0;i<FormationHeroAcountMax;i++)
				{
					if (((FightSUD*)user_data.data)->heroHpAfterLastFight.A_teamHeroId[i] == _heroId)
					{
						ret->zhuangbeiOpEnd();
						//修改血
						float hp = ret->getHp();
						hp *= 0.15f;
						hp += ((FightSUD*)user_data.data)->heroHpAfterLastFight.currentHp_A[i];
						if(hp > ret->getHp())
						{
							hp = ret->getHp();
						}
						ret->subHp(ret->getHp() - hp);
					}
				}
			}
			else
			{
				ret->zhuangbeiOpEnd();
			}
		}

		return ret;
	}
	else
	{
		
		//
		Guaiwu* ret = new Guaiwu();
		GuaiWuData g_Data;
		g_Data.level = 1;
		g_Data.gongJiLi = 18 + 20*lfRandom0_1();
		//g_Data.xueLiang = 4000+ 300*lfRandom0_1()+_heroId;
		g_Data.xueLiang = 10+ 30*lfRandom0_1()+_heroId;
		g_Data.baoJiLv = 35;
		g_Data.baoShangYinZi = 120;
		g_Data.jiNengChuFaLv = jinengchufalv_B[(_heroId-1) % 4];
		g_Data.huJiaJianMianLv = 20;
		g_Data.kangXingJianMianLv = 10 + 5*lfRandom0_1();
		g_Data.gongJiJuLi = gongJiJuLi_B[(_heroId-1) % 4];;
		g_Data.shangHaiLeiXing = SHANG_HAI_WU_LI;
		g_Data.profession = (Profession)proB[(_heroId-1) % 4];
		g_Data.x_size = guaiwu_x_size[(_heroId-1) % 4];
		g_Data.type = ((_heroId-1) % 4)==1?Type_Guaiwu_jingying:Type_Guaiwu_putong;
		ret->initWithGuaiwuData(g_Data);
		ret->setDefaultCdTime(cdTime);
		ret->skilVec.push_back(SkillType_LieGong);
		
		if (((FightSUD*)user_data.data)->boss_freezy)
		{
			// boss不动的做法
			GameBuffEffect effect(-1);
			effect.xuanyun = true;
			effect.remove_pos = Pos_None;
			GameBuff buff(BuffState_Controller,0,0); 
			buff.effect_vec.push_back(effect);
			ret->attachBuff(buff);
		}

		return ret;
	}
}
BaseHero* ClientTestProvider::getBaseHero(unsigned int _heroId,ScriptBuilderUserData user_data)
{
	
	short cdTime;
	getHeroCDTime(cdTime,_heroId,user_data);

	//const int index_offset = 0;
	//const int index_offset = 0;
	//Profession profession_pool[] = {
	//	Profession_Yemanren,Profession_Chike,Profession_Fashi,Profession_YouXia,Profession_Qishi,
	//	Profession_LieShou,Profession_ShenJianShou,Profession_MiShu,Profession_WuShi,Profession_WuSeng
	//};
	//SkillType skill_pool[] = {
	//	SkillType_BaoLieZhan,SkillType_ShaLu,SkillType_ShanDian,SkillType_LiRenHuiXuan,SkillType_JianShou,
	//	SkillType_JianYu,SkillType_LieGong,SkillType_HuoQiuShu,SkillType_WenYi,SkillType_ShenZhiXingNian
	//};
	//Profession proA[] = {profession_pool[index_offset+0],profession_pool[index_offset+1],profession_pool[index_offset+2],profession_pool[index_offset+3]};
	//Profession proB[] = {profession_pool[index_offset+4],profession_pool[index_offset+5],profession_pool[index_offset+6],profession_pool[index_offset+7]};
	//SkillType skill_a[] = {skill_pool[index_offset+0],skill_pool[index_offset+1],skill_pool[index_offset+2],skill_pool[index_offset+3]};
	//SkillType skill_b[] = {skill_pool[index_offset+4],skill_pool[index_offset+5],skill_pool[index_offset+6],skill_pool[index_offset+7]};

	Profession proA[] = {Profession_WuShi,Profession_WuSeng,Profession_ShenJianShou,Profession_Yemanren};
	Profession proB[] = {Profession_WuShi,Profession_WuSeng,Profession_ShenJianShou,Profession_Chike};
	SkillType skill_a[] = {SkillType_WenYi,SkillType_WenYi,SkillType_HuoQiuShu,SkillType_HuoQiuShu};
	SkillType skill_b[] = {SkillType_WenYi,SkillType_WenYi,SkillType_HuoQiuShu,SkillType_HuoQiuShu};

	SkillType* skill_A = skill_a;
	SkillType* skill_B = skill_b;
	float gongJiJuLi_A[] = {1,1,2,2};// 距离写出10,绝度全屏,只要大于对角线的长度就是了4.5f
	float gongJiJuLi_B[] = {1,10.0f,2,2};
	int guaiwu_x_size[] = {1,1,1,1};

	// A 队
	if (user_data.teamTag > 0)
	{
		//
		Hero* ret = new Hero();
		// test
		{
			// 不用装备
			ret->equipVec.clear();
			ret->skilVec.clear();

			HeroBaseProperty data;
			data.hero_id= _heroId;
			data.profession = proA[(_heroId-1) % 4];
			data.level = 10;

			data.exp_current = 20;
			data.exp_need = 2000;
			data.parent_hero_id = 0;
			data.postion = 1;
			data.vit_current = 100;

			data.mLiLiang = 4 + 4*lfRandom0_1();
			data.mMinJie = 500+6*lfRandom0_1();
			data.mZhiLi = 6 + 10*lfRandom0_1();
			data.mTiNeng = 0;
			data.vit_current = 50;
			data.mHP = 30;
			data.mGongJiJuLi = CS::getHeroGongjiJuLiByProfession(data.profession);
			data.mBaoJiLv = 100;
			data.mBaoJiShangHaiYinZi = 500;
			data.mJiNengFaChuLv = 0;
			data.mShangHaiLeiXing = SHANG_HAI_WU_LI;
			data.currentStage = 1;
			data.currentEffectPercent = 300;
			data.isYuanShen = false;

			ret->init(data);
			ret->setDefaultCdTime(cdTime);
			ret->skilVec.push_back(SkillDataForFight(skill_A[(_heroId-1) % 4]));

			// 加装备,测试
			{
				EquipData zhuangbei;
				zhuangbei.gongji_max = 2;
				zhuangbei.gongji_min = 1;
				zhuangbei.hole = 3;
				zhuangbei.hujia = 2;
				zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
				zhuangbei.equipDicrib = "equipDicrib";
				zhuangbei.zhuangbei_hero_id = 1;
				zhuangbei.zhuangbei_id = 2;
				zhuangbei.zhuangbei_level = 3;
				zhuangbei.equipName = "equipName";

				ZBAttr atti;
				atti.attr_type = AttrType_mingjie;
				atti.cuiqu_suc_ratio = 0;
				atti.attr_value = 1;
				zhuangbei.attr_vec.push_back(atti);

				if (data.profession == Profession_Yemanren)
				{
					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_dsj_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_DanshouJian;
					ret->equipVec.push_back(zhuangbei);

					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_dunp_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_Dunpai;
					ret->equipVec.push_back(zhuangbei);

					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_jz_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_Jiezhi;
					ret->equipVec.push_back(zhuangbei);
					ret->equipVec.push_back(zhuangbei);


					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_hsf_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_Hushenfu;
					ret->equipVec.push_back(zhuangbei);

// 					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
// 					zhuangbei.equipPic = "zb_kj_z_2";
// 					zhuangbei.zhuangbei_type = ZhuangbeiType_KuijiaZhong;
// 					ret->equipVec.push_back(zhuangbei);
				}
				else if(data.profession == Profession_Qishi)
				{
					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_fu_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_Dunpai;
					ret->equipVec.push_back(zhuangbei);
				}
				else if(data.profession == Profession_MiShu)
				{
					/*BaseActor* misu = NULL;
					{
					vector<BaseActor*> actors = MyselfManager::getManager()->getMyZhuShous_ZhenShen(Actor_ShangZheng);
					int size = actors.size();
					for (int i=0;i<size;i++)
					{
					if (actors[i]->getActorType() == Profession_MiShu)
					{
					misu = actors[i];
					break;
					}
					}
					}*/
					//// 找到就用外面的配置
					//if (misu)
					//{
					//	vector<Equipment*> equips = misu->getEquipments();
					//	int equipsNum = equips.size();
					//	for (int i=0;i<equipsNum;i++)
					//	{
					//		ret->equipVec.push_back(equips[i]->getEquipData());
					//	}
					//}
					//else
					{
						zhuangbei.zhuangbei_colour = ZhuangbeiColour_Baizhuang;
						zhuangbei.equipPic = "zb_fz_ss_1";
						zhuangbei.zhuangbei_type = ZhuangbeiType_ShuangshouFazhang;
						ret->equipVec.push_back(zhuangbei);
					}


				}
				else if(data.profession == Profession_ShenJianShou)
				{
					zhuangbei.zhuangbei_colour = ZhuangbeiColour_Chuanqi;
					zhuangbei.equipPic = "zb_gong_1";
					zhuangbei.zhuangbei_type = ZhuangbeiType_Gong;
					ret->equipVec.push_back(zhuangbei);
				}
			}

			// 回血
			if ( ( (FightSUD*)user_data.data )->fightIndex > 0)
			{
				for (int i=0;i<FormationHeroAcountMax;i++)
				{
					if (( (FightSUD*)user_data.data )->heroHpAfterLastFight.A_teamHeroId[i] == _heroId)
					{
						ret->zhuangbeiOpEnd();
						//修改血
						float hp = ret->getHp();
						hp *= 0.15f;
						hp += ( (FightSUD*)user_data.data )->heroHpAfterLastFight.currentHp_A[i];
						if(hp > ret->getHp())
						{
							hp = ret->getHp();
						}
						ret->subHp(ret->getHp() - hp);
					}
				}
			}
			else
			{
				ret->zhuangbeiOpEnd();
			}
		}

		return ret;
	}
	else
	{
		//
		Hero* ret = new Hero();
		{
			// 不用装备
			ret->equipVec.clear();
			ret->skilVec.clear();

			HeroBaseProperty data;
			data.hero_id= _heroId;
			data.profession = proB[(_heroId-1) % 4];
			data.level = 1;

			data.exp_current = 20;
			data.exp_need = 2000;
			data.parent_hero_id = 0;
			data.postion = 1;
			data.vit_current = 100;

			data.mLiLiang = 4 + 4*lfRandom0_1();
			data.mMinJie = 5+6*lfRandom0_1();
			data.mZhiLi = 6 + 10*lfRandom0_1();
			data.mTiNeng = 0;
			data.vit_current = 200;
			data.mHP = 300;
			data.mGongJiJuLi = gongJiJuLi_B[(_heroId-1) % 4];
			data.mBaoJiLv = 20;
			data.mBaoJiShangHaiYinZi = 150;
			data.mJiNengFaChuLv = 0;
			data.mShangHaiLeiXing = SHANG_HAI_WU_LI;
			data.currentStage = 1;
			data.currentEffectPercent = 100;
			data.isYuanShen = false;

			ret->init(data);

			ret->setDefaultCdTime(cdTime);
			ret->skilVec.push_back(SkillDataForFight(skill_B[(_heroId-1) % 4]));
			ret->zhuangbeiOpEnd();


			if (((FightSUD*)user_data.data)->boss_freezy)
			{
				// boss不动的做法
				GameBuffEffect effect(-1);
				effect.xuanyun = true;
				effect.remove_pos = Pos_None;
				GameBuff buff(BuffState_Controller,0,0); 
				buff.effect_vec.push_back(effect);
				ret->attachBuff(buff);
			}
		}

		return ret;
	}
}
void PotionShop::potionShop(Hero& hero)
{
    /*this->potion_items = {//name, health, price, value
        {1, Potion("Mommy's Tea", 4, 150, 1)},
        {2, Potion("Antidote of Life", 10, 230, 2)},
        {3, Potion("Red Potion'", 16, 300, 3)},
        {4, Potion("Imperial Regeneration", 24, 550, 4)},
        {5, Potion("Oil of Health", 32, 610, 5)},
        {6, Potion("Holy Light", 40, 690, 6)},
        {7, Potion("Serum of Rejuvination", 52, 750, 7)},
        {8, Potion("Elixir", 60, 900, 8)}
    };*/
	
	this->init_map_values();//Inherits init_map_values from mainshop
	
	this->potion_items = {//name, health, price, value
        {1, Potion("Mommy's Tea",		    map_effect_array[0], map_price_array[0],map_sellValue_array[0], 1)},
        {2, Potion("Antidote of Life",      map_effect_array[1], map_price_array[1],map_sellValue_array[1], 2)},
        {3, Potion("Red Potion'",		    map_effect_array[2], map_price_array[2],map_sellValue_array[2], 3)},
        {4, Potion("Imperial Regeneration", map_effect_array[3], map_price_array[3],map_sellValue_array[3], 4)},
        {5, Potion("Oil of Health",			map_effect_array[4], map_price_array[4],map_sellValue_array[4], 5)},
        {6, Potion("Holy Light",			map_effect_array[5], map_price_array[5],map_sellValue_array[5], 6)},
        {7, Potion("Serum of Rejuvination", map_effect_array[6], map_price_array[6],map_sellValue_array[6], 7)},
        {8, Potion("Elixir",				map_effect_array[7], map_price_array[7],map_sellValue_array[7], 8)}
    };
    
	//Make a random function that gets potions from inventories and puts thhem into treasure chests which are also called randomly
	//Make the potions you take, not pass the hp-For example: If i am lvl 2 and my max hp is 200, and i have 190hp and i get a potion of 50 hp
	//make sure it will fill me to max hp which is 200, not passed it
    
	//Create an inventory for weapons, potions and armor instead of just one inventory
	//Change The gold and Health numbers for potions
    
    this->getPotionShop();//Display potions
    
	//int choice;
	cout << "Select what you would like to buy, or enter 9 to quit!\n";
	cin >> choice;
	switch (choice)
	{
        case 1:
            for (map <int, Potion>::iterator iter = potion_items.begin(); iter != potion_items.end(); iter++)
            {
                if(iter->first == 1)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {//Add a function-if you already have a weapon, you cannot buy it again
                        add_potion(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        hero.setHp(hero.getHp() + iter->second._health);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< potion_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->potionShop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 2:
            for (map <int, Potion>::iterator iter = potion_items.begin(); iter != potion_items.end(); iter++)
            {
                if(iter->first == 2)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_potion(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        hero.setHp(hero.getHp() + iter->second._health);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< potion_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->potionShop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 3:
            for (map <int, Potion>::iterator iter = potion_items.begin(); iter != potion_items.end(); iter++)
            {
                if(iter->first == 3)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_potion(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        hero.setHp(hero.getHp() + iter->second._health);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< potion_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->potionShop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 4:
            for (map <int, Potion>::iterator iter = potion_items.begin(); iter != potion_items.end(); iter++)
            {
                if(iter->first == 4)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_potion(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        hero.setHp(hero.getHp() + iter->second._health);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< potion_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->potionShop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 5:
            for (map <int, Potion>::iterator iter = potion_items.begin(); iter != potion_items.end(); iter++)
            {
                if(iter->first == 5)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_potion(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        hero.setHp(hero.getHp() + iter->second._health);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< potion_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->potionShop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 6:
            for (map <int, Potion>::iterator iter = potion_items.begin(); iter != potion_items.end(); iter++)
            {
                if(iter->first == 6)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_potion(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        hero.setHp(hero.getHp() + iter->second._health);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< potion_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->potionShop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 7:
            for (map <int, Potion>::iterator iter = potion_items.begin(); iter != potion_items.end(); iter++)
            {
                if(iter->first == 7)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_potion(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        hero.setHp(hero.getHp() + iter->second._health);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< potion_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->potionShop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 8:
            for (map <int, Potion>::iterator iter = potion_items.begin(); iter != potion_items.end(); iter++)
            {
                if(iter->first == 8)
                {
                    if (hero.getMoney() >= iter->second._price)
                    {
                        add_potion(iter->second);
                        hero.setMoney(hero.getMoney() - iter->second._price);
                        hero.setHp(hero.getHp() + iter->second._health);
                        cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n";
                        cout << "your total items are: "<< potion_inventory.size() << endl;
                        break;//break for loop
                    }
                    
                    else
                    {
                        cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl;
                        //system("CLS");//cout << string(50, '\n');
                        this->potionShop(hero);
                        break;//break for loop
                    }
                }
            }
            break;//break switch
            
        case 9: cout << "Exiting Potion shop...\n\n";
            break;
            
        default:
            cout << "Error! You have entered an invalid answer\nPlease try again";
            this->potionShop(hero);
	}
}