diff --git a/Boss.cpp b/Boss.cpp index 825dee39aac963f6fe3deb7e7d647b287d956620..46bb6f90633a98ea9c62921d51f6f8513bda8fc7 100644 --- a/Boss.cpp +++ b/Boss.cpp @@ -14,6 +14,7 @@ #include using namespace std; +// Outputs the intro for the boss of a given floor void Boss::summonBoss(int floorNum) { switch(floorNum) { @@ -33,7 +34,7 @@ void Boss::summonBoss(int floorNum) { } } - +// Accessor for fight int Boss::getFight(int floorNum) { switch(floorNum) { @@ -52,6 +53,7 @@ int Boss::getFight(int floorNum) { } } +// Accessor for talk int Boss::getTalk(int floorNum) { switch(floorNum) { @@ -70,6 +72,7 @@ int Boss::getTalk(int floorNum) { } } +// The response for if the player beats the boss of a given floor number void Boss::bossResponse(int floorNum, bool playerWon) { if (playerWon == true) { @@ -116,6 +119,7 @@ void Boss::bossResponse(int floorNum, bool playerWon) { } } +// Puts items into the inventory of the player from the boss of a given floor void Boss::giveBossItems(int floorNum, Inventory &inventory) { switch(floorNum) { diff --git a/Boss.h b/Boss.h index 44866106a94443e7efe957b4c3f31b31907ccd21..a44ed0ce492b030beccf2c8b85c2a8eb9be0d5d1 100644 --- a/Boss.h +++ b/Boss.h @@ -22,16 +22,20 @@ using namespace std; class Boss { private: + //boss stats int fight; int talk; + public: - // Get Functions + // Accesssor Functions for a boss on a given floor int getFight(int floorNum); int getTalk(int floorNum); - // Other Functions + // Outputs the intro for the boss of a given floor void summonBoss(int floorNum); + // The response for if the player beats the boss of a given floor number void bossResponse(int floorNum, bool playerWon); + // Puts items into the inventory of the player from the boss of a given floor void giveBossItems(int floorNum, Inventory &inventory); }; diff --git a/Dungeon.cpp b/Dungeon.cpp index 9b79f080777c1fd28a988ad3270751277cd41b1e..c3f00cf4e4d00e85390c19ff254fc3e1a06d192d 100644 --- a/Dungeon.cpp +++ b/Dungeon.cpp @@ -7,34 +7,42 @@ #include "Monster.h" using namespace std; + // initiating sudo classes Monster monster; Boss boss; + // randomly rooms the monster from 1 to 20 int Dungeon::rollRoom() { int roll = rand() % 20 + 1; return roll; } + // summons the monster rolled void Dungeon::getMonster(int encounterNum) { monster.summon(encounterNum); } + // gets the monster's responce if they were beaten void Dungeon::monsterResponse(int encounterNum, bool playerWon) { monster.monsterResponse(encounterNum, playerWon); } + // summons the boss of a given floor void Dungeon::getBoss(int floorNum) { boss.summonBoss(floorNum); } + // gets the boss' response if it was beaten or not void Dungeon::bossResponse(int floorNum, bool playerWon) { boss.bossResponse(floorNum, playerWon); } + // gives items to the player given the encounter number and the player's inventory void Dungeon::giveBossItems(int encounterNum, Inventory inventory) { boss.giveBossItems(floorNum, inventory); } - void Dungeon::giveMonsterItems(int encounterNum, Inventory inventory) { - monster.giveMonsterItems(encounterNum, inventory); + // gives items to the player given the floor number of the boss and the player's inventory + void Dungeon::giveMonsterItems(int floorNum, Inventory inventory) { + monster.giveMonsterItems(floorNum, inventory); } diff --git a/Dungeon.h b/Dungeon.h index 3361b2c23d681d40fc0bee4774d7c05364f8a167..c0183575044899b82a2295b44481e48de0923620 100644 --- a/Dungeon.h +++ b/Dungeon.h @@ -12,17 +12,26 @@ using namespace std; class Dungeon { + public: + //stats the dungeon keeps track of int roomEncounter; int floorNum = 1; int roomCounter = 1; + // roll the room enoucnter int rollRoom(); + // gets the output for the room that was rolled from monster void getMonster(int encounterNum); + // gets the monster's response from the monster if they were beaten or if they beat the player void monsterResponse(int encounterNum, bool playerWon); + // gets the output for the boss for a given floor number void getBoss(int floorNum); + // gets the boss' response from the monster if they were beaten or if they beat the player void bossResponse(int floorNum, bool plyarWon); + // gives items of the boss on a given floor void giveBossItems(int floorNum, Inventory inventory); + // gives items of a monster that was rolled void giveMonsterItems(int encounterNum, Inventory inventory); }; diff --git a/Monster.cpp b/Monster.cpp index a023e2a819cf322da2fbfcff5ffa94c84d9ee289..58b6f3d735d1c89f7730eb1a9809e664dea47d36 100644 --- a/Monster.cpp +++ b/Monster.cpp @@ -15,7 +15,7 @@ using namespace std; - +// takes an ecnounter number and outputs the intro for the number void Monster::summon(int encounterNum) { switch(encounterNum) { @@ -82,6 +82,7 @@ void Monster::summon(int encounterNum) { } } +// Accessor for the fight stat given an encouter number int Monster::getFight(int encounterNum) { switch (encounterNum) { @@ -148,7 +149,8 @@ int Monster::getFight(int encounterNum) { return fight = 10; } } - + +// Accessor for the talk given and encounter number int Monster::getTalk(int encounterNum) { switch (encounterNum) { @@ -215,6 +217,7 @@ int Monster::getTalk(int encounterNum) { } } +// gives items to the inventory provided gien an encounter number void Monster::giveMonsterItems(int encounterNum, Inventory &inventory) { switch(encounterNum) { @@ -301,6 +304,7 @@ void Monster::giveMonsterItems(int encounterNum, Inventory &inventory) { } } +// gets the response if a player was beaten or beats the monster given an encounter number void Monster::monsterResponse(int encounterNum, int playerWon) { if (playerWon == true) { switch(encounterNum) { diff --git a/Monster.h b/Monster.h index 25aabfd90fbc686bc5700362780148c4b6dfb314..20c4cdabaf27f6e8d1b70ffd3eccac35fbff241b 100644 --- a/Monster.h +++ b/Monster.h @@ -22,17 +22,21 @@ using namespace std; class Monster { private: + // monster stats int fight; int talk; public: - // Get Functions + // Accessor Functions int getFight(int encounterNum); int getTalk(int encounterNum); // Other Functions + // Outputs the intro for the boss of a given floor void summon(int encounterNum); + // gives items to the inventory given based on the encounter number provided void giveMonsterItems(int encounterNum, Inventory &inventory); + // The response for if the player beats the monster given an encounter number void monsterResponse(int encounterNum, int playerWon); diff --git a/Player.cpp b/Player.cpp index 23df204107a6ce38c2b7fb28bd4ebb5121b2e5ac..e3100da86c92ec2df4c2a740e85d53121c66138c 100644 --- a/Player.cpp +++ b/Player.cpp @@ -16,6 +16,7 @@ #include using namespace std; +// takes a seed and randomly sets the players stats void Player::setStats(int seed) { srand(seed); diff --git a/Player.h b/Player.h index 992f65b187d6ad2828d3905256c469c205652e8d..ecbcbe1cab827129bdfd5da714b94ac07a20fe48 100644 --- a/Player.h +++ b/Player.h @@ -22,18 +22,16 @@ using namespace std; class Player { private: + // players stats int fight; int talk; - int fightModifier; - int talkModifier; - int finalFight; - int finalTalk; string playerName; public: + // inventory and health management int inventoryIndex; int health = 100; - // Get Functions + // Accessor Functions int getFight() { return fight; } int getTalk() { return talk; } string getPlayerName() { return playerName; } @@ -43,6 +41,8 @@ class Player { void setFight(int Fight) { fight = Fight; } void setTalk(int Talk) { talk = Talk; } void setPlayerName(string name) { playerName = name; } + + // deals damage to the players health when called void doDamage() { health -= 5; } // Check Victory diff --git a/main.cpp b/main.cpp index 954c5ac1ac64085650d37a67dd0fc9d5f69c2941..86c9b9e6ad2f4912af3f0e687cf064b4313d2201 100644 --- a/main.cpp +++ b/main.cpp @@ -11,31 +11,36 @@ #include "Dungeon.h" using namespace std; - +//prototypes for the menus +// Shows a welcome message void introMenu(); +// Takes info from the inventory of the player and the player stats and displays it void ingameMenu(Inventory, Player); int main() { + // initating class pointers so they can be deleted later to save space Dungeon *dungeonPtr = new Dungeon; Player *playerPtr = new Player; Inventory *inventoryPtr = new Inventory; Monster *monsterPtr = new Monster; Boss *bossPtr = new Boss; + + //victory condition checkers bool playerWon = false; bool playerVictory = false; string name; + //randomizing based on time and seeting the seed randomly between 1 and 650 srand(time(NULL)); - int seed = rand() % 650 + 1; introMenu(); + // getting and displaying player info cout << "Enter your name adventurer!" << endl; cin >> name; cin.ignore(1000, '\n'); - playerPtr->setPlayerName(name); playerPtr->setStats(seed); inventoryPtr->gainItem("Sword", 0, 0); @@ -46,13 +51,16 @@ int main() { //floor 1-3 do { + //getting the room encounter string response; playerWon = false; dungeonPtr->roomEncounter = dungeonPtr->rollRoom(); - + + // runs the encounter every five floors to show a boss if(dungeonPtr->roomCounter % 5 == 0) { cout << endl; cout << "You enter the room" << endl; + // outputting the boss and getting responses till they either run from the boss or kill the boss dungeonPtr->getBoss(dungeonPtr->floorNum); do { @@ -82,14 +90,16 @@ int main() { playerWon = true; } ingameMenu(*inventoryPtr, *playerPtr); - } while (playerWon == false); + } while (playerWon == false); // checks for defeat of the boss playerWon = false; dungeonPtr->roomCounter++; - + + // runs this if the encounter is not a boss } else { cout << endl; cout << "You enter the room" << endl; + // shows the encounter and gets responses till they either run from the encounter or defeat the encounter dungeonPtr->getMonster(dungeonPtr->roomEncounter); do { cout << "How do you respond? (Fight, Talk, Or Flee): "; @@ -117,19 +127,20 @@ int main() { playerWon = true; } ingameMenu(*inventoryPtr, *playerPtr); - } while (playerWon == false); + } while (playerWon == false); // checks for defeat of the monster playerWon = false; dungeonPtr->roomCounter++; } - } while(dungeonPtr->floorNum <= 3); + } while(dungeonPtr->floorNum <= 3); //checks to see if the room is less than 3 to know when to go onto the final boss //floor 4 cout << endl; cout << "You enter the room" << endl; + // out puts the final boss and gets responses until they either run from the boss or defeat it dungeonPtr->getBoss(dungeonPtr->floorNum); do { string response; @@ -160,14 +171,15 @@ int main() { playerWon = true; } ingameMenu(*inventoryPtr, *playerPtr); - }while (playerWon == false); + }while (playerWon == false); // checks to see if they win the encounter - } while (playerVictory == false); + } while (playerVictory == false); // checks to see if the final boss was beaten cout << "You win!" << endl; cout << "Final Inventory" << endl; ingameMenu(*inventoryPtr, *playerPtr); + //delets the class pointers delete monsterPtr; delete bossPtr; delete inventoryPtr; @@ -176,12 +188,14 @@ int main() { return 0; } +// intro function void introMenu() { cout << "Welcome to DunGen::theExperience()!" << endl; cout << "You will be diving into the most interesting dungeon around," << " so good luck fighting, talking or fleeing like a little baby!" << endl; } +//shows stats based on the inventory input and the player input void ingameMenu(Inventory inventory, Player player) { cout << "--------------------------------" << endl; cout << "Inventory" << endl;