-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMine.cpp
More file actions
53 lines (50 loc) · 1.62 KB
/
Copy pathMine.cpp
File metadata and controls
53 lines (50 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/************************************************************
** Author: Peter Nguyen
** CS162-400, Final project
** Date: 6/6/15
** Description: Mine (Location subclass) implementation file
************************************************************/
#include "Mine.hpp"
#include <iostream>
#include <cstdlib>
#include <ctime>
using std::cout;
using std::string;
/************************************************************
** Mine::printDescription
** Description: Prints description of the Location
** Parameters: none
************************************************************/
void Mine::printDescription()
{
cout << "\nYou are in a decrepit old mine.\n";
cout << "There are old munitions and bullets laying about.\n\n";
printMenu();
cout << "6. Search the area\n";
}
/************************************************************
** Mine::specialAction
** Description: Performs special action for the location
** Parameters: none
************************************************************/
string Mine::specialAction(Player* pl)
{
int roll = 0;
static int seedIncrement = 0;
unsigned seed;
seed = time(0) + seedIncrement++; // Ensures a different
srand(seed); // seed value each time
// function is called
roll = rand() % 2 + 1;
if (roll == 2 && !pl->getHasBullets())
{
pl->addBagItem("bullets");
pl->setHasBullets(true);
if (pl->getHasGun())
return "\nYou found some bullets!\nYour attack power has now doubled!\n";
else
return "\nYou found some bullets!\n";
}
else
return "\nYou didn't find anything ...\n";
}