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


C++ Battle::BossBattle方法代码示例

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


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

示例1: main

int main()
{
	SeedRandom();	// Seeds random values for entire program.
	// Create weapon shops and load inventory.
	WeaponShop staveShop;
	std::ifstream staveInputFile("staves.txt");
	staveShop.InitializeShop(staveInputFile);
	WeaponShop swordShop;
	std::ifstream swordInputFile("swords.txt");
	swordShop.InitializeShop(swordInputFile);
	WeaponShop bowShop;
	std::ifstream bowInputFile("bows.txt");
	bowShop.InitializeShop(bowInputFile);


	// Get user input to create a player character.
	std::cout << "\n----------------------------------" << std::endl;
	std::cout << "Welcome to Scott's Text Adventure!" << std::endl;
	std::cout << "----------------------------------" << std::endl;
	std::cout << "Enter your character's name: ";
	std::string characterName;
	getline(std::cin, characterName);
	std::cout << "\nChoose your class:" << std::endl;
	std::cout << "[1] Warrior -- High HP & high defense, low damage output" << std::endl
			  << "[2] Mage    -- Low HP & low defense, high damage output. " << std::endl
			  << "[3] Archer  -- Medium HP & medium defense, medium damage output." << std::endl;
	std::size_t jobChoicesCount = 3;
	int jobChoice = 0;
	std::cout << ">>";
	// While input is valid and isn't out of range for the options.
	while(!(std::cin >> jobChoice) || 0 > jobChoice || jobChoice > jobChoicesCount)
	{
		HandleInvalidInput(std::cin);
	}

	// Use input to create the player character.
	Handle<PlayerCharacterBase> playerHandle(CreatePlayerCharacter(characterName, jobChoice));
	//playerHandle->GainExp(3000);
	std::cout << "\nCharacter Information:" << std::endl;
	playerHandle->DisplayStats();
	std::cout << "\nPress enter to begin the game!" << std::endl;
	std::cin.get();
	std::cin.get();

	// Create Battle object.
	Battle battleSystem;

	// Run main program loop while player isn't dead.
	while(!playerHandle->PlayerIsDead())
	{
		if(playerHandle->ReturnLevel() % 3 == 0)
		{
			battleSystem.BossBattle(playerHandle);
		}
		else
		{
			battleSystem.RandomBattle(playerHandle);
		}
		if(!playerHandle->PlayerIsDead())
		{
			enum MenuOptions {NextBattle = 1, 
							  WeaponShop = 2, 
							  DisplayStats = 3,
							  QuitGame = 4};
			int menuChoicesTotal = 4;
			int menuChoice = 0;
			while(menuChoice != NextBattle)
			{
				std::cout << "Menu: " << std::endl;
				std::cout << "[1] Next Battle" << std::endl;
				std::cout << "[2] Weapon Shop" << std::endl;
				std::cout << "[3] Display Stats" << std::endl;
				std::cout << "[4] Quit Game" << std::endl;
				std::cout << ">> ";
				// Take user input for menu choice, check for invalid input.
				while(!(std::cin >> menuChoice) || menuChoice < 0 || menuChoicesTotal < menuChoice)
				{
					// Clear std::cin and remove extra characters from istream.
					HandleInvalidInput(std::cin);
				}
				if(menuChoice == WeaponShop)
				{
					// Check the job type of the player. This is used to 
					// determine which store the player needs to visit. 
					std::string jobType = playerHandle->JobType();
					if(jobType == "warrior")
					{
						swordShop.DisplayInventory();
						swordShop.ProcessTransaction(playerHandle);

					}
					else if(jobType == "mage")
					{
						staveShop.DisplayInventory();
						staveShop.ProcessTransaction(playerHandle);
					}
					else if(jobType == "archer")
					{
						bowShop.DisplayInventory();
						bowShop.ProcessTransaction(playerHandle);
//.........这里部分代码省略.........
开发者ID:scottkrohn,项目名称:TextRPGBattleSystem,代码行数:101,代码来源:main.cpp


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