Commit 1bd0a3ed authored by Aaron Sturtevant's avatar Aaron Sturtevant

committing

parent 716c41ab
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <iostream> #include <iostream>
using namespace std; using namespace std;
// Outputs the intro for the boss of a given floor
void Boss::summonBoss(int floorNum) { void Boss::summonBoss(int floorNum) {
switch(floorNum) { switch(floorNum) {
...@@ -33,7 +34,7 @@ void Boss::summonBoss(int floorNum) { ...@@ -33,7 +34,7 @@ void Boss::summonBoss(int floorNum) {
} }
} }
// Accessor for fight
int Boss::getFight(int floorNum) { int Boss::getFight(int floorNum) {
switch(floorNum) { switch(floorNum) {
...@@ -52,6 +53,7 @@ int Boss::getFight(int floorNum) { ...@@ -52,6 +53,7 @@ int Boss::getFight(int floorNum) {
} }
} }
// Accessor for talk
int Boss::getTalk(int floorNum) { int Boss::getTalk(int floorNum) {
switch(floorNum) { switch(floorNum) {
...@@ -70,6 +72,7 @@ int Boss::getTalk(int 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) { void Boss::bossResponse(int floorNum, bool playerWon) {
if (playerWon == true) { if (playerWon == true) {
...@@ -116,6 +119,7 @@ void Boss::bossResponse(int floorNum, bool playerWon) { ...@@ -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) { void Boss::giveBossItems(int floorNum, Inventory &inventory) {
switch(floorNum) { switch(floorNum) {
......
...@@ -22,16 +22,20 @@ using namespace std; ...@@ -22,16 +22,20 @@ using namespace std;
class Boss { class Boss {
private: private:
//boss stats
int fight; int fight;
int talk; int talk;
public: public:
// Get Functions // Accesssor Functions for a boss on a given floor
int getFight(int floorNum); int getFight(int floorNum);
int getTalk(int floorNum); int getTalk(int floorNum);
// Other Functions // Outputs the intro for the boss of a given floor
void summonBoss(int floorNum); void summonBoss(int floorNum);
// The response for if the player beats the boss of a given floor number
void bossResponse(int floorNum, bool playerWon); 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); void giveBossItems(int floorNum, Inventory &inventory);
}; };
......
...@@ -7,34 +7,42 @@ ...@@ -7,34 +7,42 @@
#include "Monster.h" #include "Monster.h"
using namespace std; using namespace std;
// initiating sudo classes
Monster monster; Monster monster;
Boss boss; Boss boss;
// randomly rooms the monster from 1 to 20
int Dungeon::rollRoom() { int Dungeon::rollRoom() {
int roll = rand() % 20 + 1; int roll = rand() % 20 + 1;
return roll; return roll;
} }
// summons the monster rolled
void Dungeon::getMonster(int encounterNum) { void Dungeon::getMonster(int encounterNum) {
monster.summon(encounterNum); monster.summon(encounterNum);
} }
// gets the monster's responce if they were beaten
void Dungeon::monsterResponse(int encounterNum, bool playerWon) { void Dungeon::monsterResponse(int encounterNum, bool playerWon) {
monster.monsterResponse(encounterNum, playerWon); monster.monsterResponse(encounterNum, playerWon);
} }
// summons the boss of a given floor
void Dungeon::getBoss(int floorNum) { void Dungeon::getBoss(int floorNum) {
boss.summonBoss(floorNum); boss.summonBoss(floorNum);
} }
// gets the boss' response if it was beaten or not
void Dungeon::bossResponse(int floorNum, bool playerWon) { void Dungeon::bossResponse(int floorNum, bool playerWon) {
boss.bossResponse(floorNum, 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) { void Dungeon::giveBossItems(int encounterNum, Inventory inventory) {
boss.giveBossItems(floorNum, inventory); boss.giveBossItems(floorNum, inventory);
} }
void Dungeon::giveMonsterItems(int encounterNum, Inventory inventory) { // gives items to the player given the floor number of the boss and the player's inventory
monster.giveMonsterItems(encounterNum, inventory); void Dungeon::giveMonsterItems(int floorNum, Inventory inventory) {
monster.giveMonsterItems(floorNum, inventory);
} }
...@@ -12,17 +12,26 @@ ...@@ -12,17 +12,26 @@
using namespace std; using namespace std;
class Dungeon { class Dungeon {
public: public:
//stats the dungeon keeps track of
int roomEncounter; int roomEncounter;
int floorNum = 1; int floorNum = 1;
int roomCounter = 1; int roomCounter = 1;
// roll the room enoucnter
int rollRoom(); int rollRoom();
// gets the output for the room that was rolled from monster
void getMonster(int encounterNum); 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); void monsterResponse(int encounterNum, bool playerWon);
// gets the output for the boss for a given floor number
void getBoss(int floorNum); 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); void bossResponse(int floorNum, bool plyarWon);
// gives items of the boss on a given floor
void giveBossItems(int floorNum, Inventory inventory); void giveBossItems(int floorNum, Inventory inventory);
// gives items of a monster that was rolled
void giveMonsterItems(int encounterNum, Inventory inventory); void giveMonsterItems(int encounterNum, Inventory inventory);
}; };
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
using namespace std; using namespace std;
// takes an ecnounter number and outputs the intro for the number
void Monster::summon(int encounterNum) { void Monster::summon(int encounterNum) {
switch(encounterNum) { switch(encounterNum) {
...@@ -82,6 +82,7 @@ void Monster::summon(int encounterNum) { ...@@ -82,6 +82,7 @@ void Monster::summon(int encounterNum) {
} }
} }
// Accessor for the fight stat given an encouter number
int Monster::getFight(int encounterNum) { int Monster::getFight(int encounterNum) {
switch (encounterNum) { switch (encounterNum) {
...@@ -148,7 +149,8 @@ int Monster::getFight(int encounterNum) { ...@@ -148,7 +149,8 @@ int Monster::getFight(int encounterNum) {
return fight = 10; return fight = 10;
} }
} }
// Accessor for the talk given and encounter number
int Monster::getTalk(int encounterNum) { int Monster::getTalk(int encounterNum) {
switch (encounterNum) { switch (encounterNum) {
...@@ -215,6 +217,7 @@ int Monster::getTalk(int 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) { void Monster::giveMonsterItems(int encounterNum, Inventory &inventory) {
switch(encounterNum) { switch(encounterNum) {
...@@ -301,6 +304,7 @@ void Monster::giveMonsterItems(int encounterNum, Inventory &inventory) { ...@@ -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) { void Monster::monsterResponse(int encounterNum, int playerWon) {
if (playerWon == true) { if (playerWon == true) {
switch(encounterNum) { switch(encounterNum) {
......
...@@ -22,17 +22,21 @@ using namespace std; ...@@ -22,17 +22,21 @@ using namespace std;
class Monster { class Monster {
private: private:
// monster stats
int fight; int fight;
int talk; int talk;
public: public:
// Get Functions // Accessor Functions
int getFight(int encounterNum); int getFight(int encounterNum);
int getTalk(int encounterNum); int getTalk(int encounterNum);
// Other Functions // Other Functions
// Outputs the intro for the boss of a given floor
void summon(int encounterNum); void summon(int encounterNum);
// gives items to the inventory given based on the encounter number provided
void giveMonsterItems(int encounterNum, Inventory &inventory); 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); void monsterResponse(int encounterNum, int playerWon);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <iostream> #include <iostream>
using namespace std; using namespace std;
// takes a seed and randomly sets the players stats
void Player::setStats(int seed) { void Player::setStats(int seed) {
srand(seed); srand(seed);
......
...@@ -22,18 +22,16 @@ using namespace std; ...@@ -22,18 +22,16 @@ using namespace std;
class Player { class Player {
private: private:
// players stats
int fight; int fight;
int talk; int talk;
int fightModifier;
int talkModifier;
int finalFight;
int finalTalk;
string playerName; string playerName;
public: public:
// inventory and health management
int inventoryIndex; int inventoryIndex;
int health = 100; int health = 100;
// Get Functions // Accessor Functions
int getFight() { return fight; } int getFight() { return fight; }
int getTalk() { return talk; } int getTalk() { return talk; }
string getPlayerName() { return playerName; } string getPlayerName() { return playerName; }
...@@ -43,6 +41,8 @@ class Player { ...@@ -43,6 +41,8 @@ class Player {
void setFight(int Fight) { fight = Fight; } void setFight(int Fight) { fight = Fight; }
void setTalk(int Talk) { talk = Talk; } void setTalk(int Talk) { talk = Talk; }
void setPlayerName(string name) { playerName = name; } void setPlayerName(string name) { playerName = name; }
// deals damage to the players health when called
void doDamage() { health -= 5; } void doDamage() { health -= 5; }
// Check Victory // Check Victory
......
...@@ -11,31 +11,36 @@ ...@@ -11,31 +11,36 @@
#include "Dungeon.h" #include "Dungeon.h"
using namespace std; using namespace std;
//prototypes for the menus
// Shows a welcome message
void introMenu(); void introMenu();
// Takes info from the inventory of the player and the player stats and displays it
void ingameMenu(Inventory, Player); void ingameMenu(Inventory, Player);
int main() { int main() {
// initating class pointers so they can be deleted later to save space
Dungeon *dungeonPtr = new Dungeon; Dungeon *dungeonPtr = new Dungeon;
Player *playerPtr = new Player; Player *playerPtr = new Player;
Inventory *inventoryPtr = new Inventory; Inventory *inventoryPtr = new Inventory;
Monster *monsterPtr = new Monster; Monster *monsterPtr = new Monster;
Boss *bossPtr = new Boss; Boss *bossPtr = new Boss;
//victory condition checkers
bool playerWon = false; bool playerWon = false;
bool playerVictory = false; bool playerVictory = false;
string name; string name;
//randomizing based on time and seeting the seed randomly between 1 and 650
srand(time(NULL)); srand(time(NULL));
int seed = rand() % 650 + 1; int seed = rand() % 650 + 1;
introMenu(); introMenu();
// getting and displaying player info
cout << "Enter your name adventurer!" << endl; cout << "Enter your name adventurer!" << endl;
cin >> name; cin >> name;
cin.ignore(1000, '\n'); cin.ignore(1000, '\n');
playerPtr->setPlayerName(name); playerPtr->setPlayerName(name);
playerPtr->setStats(seed); playerPtr->setStats(seed);
inventoryPtr->gainItem("Sword", 0, 0); inventoryPtr->gainItem("Sword", 0, 0);
...@@ -46,13 +51,16 @@ int main() { ...@@ -46,13 +51,16 @@ int main() {
//floor 1-3 //floor 1-3
do { do {
//getting the room encounter
string response; string response;
playerWon = false; playerWon = false;
dungeonPtr->roomEncounter = dungeonPtr->rollRoom(); dungeonPtr->roomEncounter = dungeonPtr->rollRoom();
// runs the encounter every five floors to show a boss
if(dungeonPtr->roomCounter % 5 == 0) { if(dungeonPtr->roomCounter % 5 == 0) {
cout << endl; cout << endl;
cout << "You enter the room" << 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); dungeonPtr->getBoss(dungeonPtr->floorNum);
do { do {
...@@ -82,14 +90,16 @@ int main() { ...@@ -82,14 +90,16 @@ int main() {
playerWon = true; playerWon = true;
} }
ingameMenu(*inventoryPtr, *playerPtr); ingameMenu(*inventoryPtr, *playerPtr);
} while (playerWon == false); } while (playerWon == false); // checks for defeat of the boss
playerWon = false; playerWon = false;
dungeonPtr->roomCounter++; dungeonPtr->roomCounter++;
// runs this if the encounter is not a boss
} else { } else {
cout << endl; cout << endl;
cout << "You enter the room" << 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); dungeonPtr->getMonster(dungeonPtr->roomEncounter);
do { do {
cout << "How do you respond? (Fight, Talk, Or Flee): "; cout << "How do you respond? (Fight, Talk, Or Flee): ";
...@@ -117,19 +127,20 @@ int main() { ...@@ -117,19 +127,20 @@ int main() {
playerWon = true; playerWon = true;
} }
ingameMenu(*inventoryPtr, *playerPtr); ingameMenu(*inventoryPtr, *playerPtr);
} while (playerWon == false); } while (playerWon == false); // checks for defeat of the monster
playerWon = false; playerWon = false;
dungeonPtr->roomCounter++; 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 //floor 4
cout << endl; cout << endl;
cout << "You enter the room" << 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); dungeonPtr->getBoss(dungeonPtr->floorNum);
do { do {
string response; string response;
...@@ -160,14 +171,15 @@ int main() { ...@@ -160,14 +171,15 @@ int main() {
playerWon = true; playerWon = true;
} }
ingameMenu(*inventoryPtr, *playerPtr); 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 << "You win!" << endl;
cout << "Final Inventory" << endl; cout << "Final Inventory" << endl;
ingameMenu(*inventoryPtr, *playerPtr); ingameMenu(*inventoryPtr, *playerPtr);
//delets the class pointers
delete monsterPtr; delete monsterPtr;
delete bossPtr; delete bossPtr;
delete inventoryPtr; delete inventoryPtr;
...@@ -176,12 +188,14 @@ int main() { ...@@ -176,12 +188,14 @@ int main() {
return 0; return 0;
} }
// intro function
void introMenu() { void introMenu() {
cout << "Welcome to DunGen::theExperience()!" << endl; cout << "Welcome to DunGen::theExperience()!" << endl;
cout << "You will be diving into the most interesting dungeon around," cout << "You will be diving into the most interesting dungeon around,"
<< " so good luck fighting, talking or fleeing like a little baby!" << endl; << " 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) { void ingameMenu(Inventory inventory, Player player) {
cout << "--------------------------------" << endl; cout << "--------------------------------" << endl;
cout << "Inventory" << endl; cout << "Inventory" << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment