void ChallengeTest() { // human player variables int humanLoc = 0; StringOO name = "Barry"; int strength = 10; int health = 100; int luck = 10; int intellegence = 10; int difficulty = 2; // initialise human Human Human(humanLoc, name, strength, health, luck, intellegence); Human.SetLocation(0); StringOO Question1 = ">> What day is Wednesday? \n a) the third day \n b) hump day \n c) the day after Tuesday"; StringOO Answer1 = "the day after Tuesday"; Question Q1(Question1, Answer1, difficulty); //const int userInputLimit = 11; //char userInput[userInputLimit] = {}; //std::cin.getline(userInput, userInputLimit); ApplyChallenge(Q1, Human); }
void Universe::CreateHuman(void){ m_vHumans.push_back(Human()); }
void Human::reset(){ Human(); }
bool BaseAI::startTurn() { int count = 0; count = getWallCount(); walls.clear(); walls.resize(count); for(int i = 0; i < count; i++) { walls[i] = Wall(getWalls()+i); } count = getCrateCount(); crates.clear(); crates.resize(count); for(int i = 0; i < count; i++) { crates[i] = Crate(getCrates()+i); } count = getWeaponCount(); weapons.clear(); weapons.resize(count); for(int i = 0; i < count; i++) { weapons[i] = Weapon(getWeapons()+i); } count = getHumanCount(); humans.clear(); humans.resize(count); for(int i = 0; i < count; i++) { humans[i] = Human(getHumans()+i); } count = getZombieCount(); zombies.clear(); zombies.resize(count); for(int i = 0; i < count; i++) { zombies[i] = Zombie(getZombies()+i); } count = getAirstrikeCount(); airstrikes.clear(); airstrikes.resize(count); for(int i = 0; i < count; i++) { airstrikes[i] = Airstrike(getAirstrikes()+i); } count = getSpawnzoneCount(); spawnzones.clear(); spawnzones.resize(count); for(int i = 0; i < count; i++) { spawnzones[i] = Spawnzone(getSpawnzones()+i); } if(turnNum() == 1) { init(); if(!isHuman()) { return true; } } if(isHuman()) { return runHuman(); } else { return runZombie(); } }
/******************************************************************************************************* * 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]; } }
void TestInitaliseDestroy() { // user input variables const int userInputLimit = 11; char userInput[userInputLimit] = {}; bool humanFinished = false; bool moveHuman = false; StringOO humanMove = "move south"; // 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 = "Barry"; 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); AddEnemyToChallenge(Enemies, Challenges, enemyNum, challengeNum); TestCombat() //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]; } }