Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
cptr142_group_project
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aaron Sturtevant
cptr142_group_project
Commits
1bd0a3ed
Commit
1bd0a3ed
authored
Mar 21, 2018
by
Aaron Sturtevant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
committing
parent
716c41ab
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
71 additions
and
23 deletions
+71
-23
Boss.cpp
Boss.cpp
+5
-1
Boss.h
Boss.h
+6
-2
Dungeon.cpp
Dungeon.cpp
+10
-2
Dungeon.h
Dungeon.h
+9
-0
Monster.cpp
Monster.cpp
+6
-2
Monster.h
Monster.h
+5
-1
Player.cpp
Player.cpp
+1
-0
Player.h
Player.h
+5
-5
main.cpp
main.cpp
+24
-10
No files found.
Boss.cpp
View file @
1bd0a3ed
...
...
@@ -14,6 +14,7 @@
#include <iostream>
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
)
{
...
...
Boss.h
View file @
1bd0a3ed
...
...
@@ -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
);
// O
ther Functions
// O
utputs 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
);
};
...
...
Dungeon.cpp
View file @
1bd0a3ed
...
...
@@ -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
);
}
Dungeon.h
View file @
1bd0a3ed
...
...
@@ -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
);
};
...
...
Monster.cpp
View file @
1bd0a3ed
...
...
@@ -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
)
{
...
...
Monster.h
View file @
1bd0a3ed
...
...
@@ -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
);
...
...
Player.cpp
View file @
1bd0a3ed
...
...
@@ -16,6 +16,7 @@
#include <iostream>
using
namespace
std
;
// takes a seed and randomly sets the players stats
void
Player
::
setStats
(
int
seed
)
{
srand
(
seed
);
...
...
Player.h
View file @
1bd0a3ed
...
...
@@ -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
...
...
main.cpp
View file @
1bd0a3ed
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment