Ejemplo n.º 1
0
bool HelpWindow::GoTo0(const String& link)
{
	if(IsNull(link) || current_link == link)
		return true;
	Topic t = AcquireTopic(link);
	SetBar();
	if(!IsNull(t.text)) {
		label = t.label;
		topic = t.link;
		Title(FromUtf8(t.title));
		RichText txt = ParseQTF(t.text);
		FinishText(txt);
		view.Pick(pick(txt), zoom);
		view.GotoLabel(label, true);
		current_link = link;
		tree.FindSetCursor(topic);
		return true;
	}
	return false;
}
Ejemplo n.º 2
0
/*******************************************************************************************************
* GANE ENGINE - handles the looping of the game
*******************************************************************************************************/
void GameEngine()
{
	// user input variables
	const int userInputLimit = 11;
	char userInput[userInputLimit] = {};
	bool humanFinished = false;
	bool moveHuman = false;
	StringOO humanMove = "move south";
	int loopCount = 0;

	// location variables
	const int locationNum = 11;
	Location *Locations[locationNum] = {};
	int prevLocation = 0;
	int newLocation = 0;
	int finishLocation = locationNum - 1;

	// human player variables
	int humanLoc = 0;
	StringOO name = "Bruce";
	int strength = 10;
	int health = 100;
	int luck = 10;
	int intellegence = 10;

	// enemy variables
	const int enemyNum = 5;
	Enemy * Enemies[enemyNum] = {};

	// challenges variables
	const int challengeNum = 16;
	Challenge *Challenges[challengeNum] = {};

	// initialise Locations
	InitLocations(Locations);

	// initialise human
	Human Human(humanLoc, name, strength, health, luck, intellegence);

	// initialise Enemies
	InitEnemies(Enemies, enemyNum);

	// initialise Challenges
	InitChallenges(Challenges);
	//AllocateChallenges(Locations, locationNum);
	AllocateChallengesManually(Locations, locationNum);
	AddEnemyToChallenge(Challenges, enemyNum, challengeNum);

	// initial splash screen
	SetConsole();
	StartText(Human);

	// Game loop
	while (!humanFinished)
	{
		// print out details of room
		std::cout << Locations[Human.GetLocation()]->GetDescription() << std::endl;
		while (!moveHuman)
		{
			// get user to enter move
			std::cout << "+ ";
			std::cin.getline(userInput, userInputLimit);
			std::cout << std::endl;
			humanMove = userInput;
			if (loopCount == 5)
			{
				std::cout << "\n     ENOUGH ALREADY...YOUR MOVING SOUTH!! \n\n";
				//bored of guesses
				humanMove = "move south";
				loopCount = 0;
			}
			// determine the new location
			newLocation = PlayerMove(Human, humanMove, Locations[Human.GetLocation()]->GetAjacentLoc());

			// validate users move and if validate change their location
			if (ValidateMove(newLocation, prevLocation))
			{
				// set challenge user has to perform before progrogressing to the next room
				Human.SetChallenge(Locations[Human.GetLocation()]->GetPathChallenge(Human.GetHeading()));
				// challenge User
				Challenge *ChallengePtr = Challenges[Human.GetChallenge()];
				ApplyChallenge(ChallengePtr, Human, Enemies);
				// move user to new location
				prevLocation = Human.GetLocation();
				Human.SetPrevHeading(Human.GetHeading());
				Human.SetLocation(newLocation);
				moveHuman = true;
				loopCount = 0;
				std::cout << "\n***----------------------------*  pop!  *-------------------------------------**\n\n";
			}
			else
			{
				// invalid move try again
				moveHuman = false;
				loopCount++;
			}
		}
		// reset move
		moveHuman = false;
		//check if user is in the finish location
		if (Human.GetLocation() == finishLocation)
		{
			humanFinished = true;
			std::cout << Locations[Human.GetLocation()]->GetDescription() << std::endl;
			FinishText(Human);
		}

	}
	//DestroyEnemies(Enemies, enemyNum);
	for (int i = 0; i < enemyNum; i++)
	{
		delete Enemies[i];
	}
	//DestroyChallenges(Challenges, challengeNum);
	for (int i = 0; i < challengeNum; i++)
	{
		delete Challenges[i];
	}
	//DestroyLocations(Locations, locationNum);
	for (int i = 0; i < locationNum; i++)
	{
		delete Locations[i];
	}

}