当前位置: 首页>>代码示例>>C++>>正文


C++ Pokemon::setCurrentExperience方法代码示例

本文整理汇总了C++中Pokemon::setCurrentExperience方法的典型用法代码示例。如果您正苦于以下问题:C++ Pokemon::setCurrentExperience方法的具体用法?C++ Pokemon::setCurrentExperience怎么用?C++ Pokemon::setCurrentExperience使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pokemon的用法示例。


在下文中一共展示了Pokemon::setCurrentExperience方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadPokemonList

void PokemonFinder::ReadPokemonList(string kind)
{
	//Set les types
	SoftwareLogic::Type fire("Fire");
	fire.setStrength("Grass","Steel");
	fire.setWeakness("Water");
	SoftwareLogic::Type water("Water");
	water.setStrength("Fire");
	water.setWeakness("Grass","Electric");
	SoftwareLogic::Type grass("Grass");
	grass.setStrength("Water");
	grass.setWeakness("Fire","Flying");
	SoftwareLogic::Type electric("Electric");
	electric.setStrength("Water","Flying");
	electric.setWeakness("NULL");
	SoftwareLogic::Type flying("Flying");
	flying.setStrength("Grass","Fighting");
	flying.setWeakness("Electric");
	SoftwareLogic::Type normal("Normal");
	normal.setStrength("NULL");
	normal.setWeakness("Fighting");
	SoftwareLogic::Type steel("Steel");
	steel.setStrength("NULL");
	steel.setWeakness("Fire","Water");
	SoftwareLogic::Type fighting("Fighting");
	fighting.setStrength("Normal","Dark");
	fighting.setWeakness("Flying");
	SoftwareLogic::Type	dark("Dark");
	dark.setStrength("NULL");
	dark.setWeakness("Fighting");

	for (pugi::xml_node pokemonList = pokemonListNode.child(kind.c_str()); pokemonList!= nullptr; pokemonList= pokemonList.next_sibling(kind.c_str()))
	{
		Pokemon* pokemonElement = new Pokemon();
		string name = pokemonList.child_value("Name");
		name.erase(name.find_last_not_of("\n\t\t\t")+1);
		name = name.substr(4);
		pokemonElement->setName(name);
		pokemonElement->setLevel(ConvertStringToInt(pokemonList.child_value("Level")));
		pokemonElement->setFullHealth(ConvertStringToInt(pokemonList.child_value("MaxHP")));
		pokemonElement->setCurrentHealth(ConvertStringToInt(pokemonList.child_value("MaxHP")));
		pokemonElement->setAttack(ConvertStringToInt(pokemonList.child_value("Attack")));
		pokemonElement->setDefense(ConvertStringToInt(pokemonList.child_value("Defense")));
		pokemonElement->setSpeed(ConvertStringToInt(pokemonList.child_value("Speed")));
		int expToLevelUp = (4*pow((ConvertStringToInt(pokemonList.child_value("Level"))),3))/5;
		pokemonElement->setExperienceToLevelUp(expToLevelUp);
		pokemonElement->setCurrentExperience(0);
		pokemonElement->setDead(false);
		
		string type = pokemonList.child_value("Type");
		type.erase(type.find_last_not_of("\n\t\t\t")+1);
		type = type.substr(4);

		if(type == fire.getTypeName())
		{
			pokemonElement->setType(fire);
		}
		else if(type == water.getTypeName())
		{
			pokemonElement->setType(water);
		}
		else if(type == electric.getTypeName())
		{
			pokemonElement->setType(electric);
		}
		else if(type == grass.getTypeName())
		{
			pokemonElement->setType(grass);
		}
		else if(type == normal.getTypeName())
		{
			pokemonElement->setType(normal);
		}
		else if(type == flying.getTypeName())
		{
			pokemonElement->setType(flying);
		}

		vector<Move*> movePokemon;
		for (pugi::xml_node moveList = pokemonList.child("Move"); moveList!= nullptr; moveList= moveList.next_sibling("Move"))
		{
			string typeName = moveList.child_value("MoveType");
			typeName.erase(typeName.find_last_not_of("\n\t\t\t")+1);
			typeName = typeName.substr(5);
			
			SoftwareLogic::Type type;
			if(typeName == fire.getTypeName())
			{
				type = fire;
			}
			else if(typeName == water.getTypeName())
			{
				type = water;
			}
			else if(typeName == electric.getTypeName())
			{
				type = electric;
			}
			else if(typeName == grass.getTypeName())
			{
//.........这里部分代码省略.........
开发者ID:elise654,项目名称:Pokemon,代码行数:101,代码来源:PokemonFinder.cpp


注:本文中的Pokemon::setCurrentExperience方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。