-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRiver.cpp
More file actions
49 lines (46 loc) · 1.46 KB
/
Copy pathRiver.cpp
File metadata and controls
49 lines (46 loc) · 1.46 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
/************************************************************
** Author: Peter Nguyen
** CS162-400, Final project
** Date: 6/6/15
** Description: River (Location subclass) implementation file
************************************************************/
#include "River.hpp"
#include <iostream>
#include <cstdlib>
#include <ctime>
using std::cout;
using std::string;
/************************************************************
** River::printDescription
** Description: Prints description of the Location
** Parameters: none
************************************************************/
void River::printDescription()
{
cout << "\nYou are in a lush green forest.\n";
cout << "There is a river here teaming with fish.\n\n";
printMenu();
cout << "6. Try to catch some fish\n";
}
/************************************************************
** River::specialAction
** Description: Performs special action for the location
** Parameters: none
************************************************************/
string River::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() % 4 + 1;
if (roll == 4)
{
pl->addBagItem("fish");
return "\nYou caught a fish!\n";
}
else
return "\nYou didn't catch anything ...\n";
}