-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValley.cpp
More file actions
46 lines (43 loc) · 1.41 KB
/
Copy pathValley.cpp
File metadata and controls
46 lines (43 loc) · 1.41 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
/************************************************************
** Author: Peter Nguyen
** CS162-400, Final project
** Date: 6/6/15
** Description: Valley (Location subclass) implementation file
************************************************************/
#include "Valley.hpp"
#include <iostream>
using std::cout;
using std::string;
/************************************************************
** Valley::printDescription
** Description: Prints description of the Location
** Parameters: none
************************************************************/
void Valley::printDescription()
{
cout << "\nYou come down into a lush valley.\n";
cout << "There is a grizzled gun merchant here.\n\n";
printMenu();
cout << "6. Buy the Spencer rifle\n";
}
/************************************************************
** Valley::specialAction
** Description: Performs special action for the location
** Parameters: none
************************************************************/
string Valley::specialAction(Player* pl)
{
if (pl->getHasGold())
{
pl->setHasGold(false);
pl->useBagItem("gold");
pl->setHasGun(true);
pl->addBagItem("rifle");
if (pl->getHasBullets())
return "\nYou bought the Spencer rifle!\nYour attack power has doubled!\n";
else
return "\nYou bought the Spencer rifle!\nHowever, you have no bullets ...";
}
else
return "\nYou don't have any gold!\n";
}