-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSword.cpp
More file actions
99 lines (89 loc) · 1.78 KB
/
Sword.cpp
File metadata and controls
99 lines (89 loc) · 1.78 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <string>
#include <iostream>
#include <string>
#include <map>
#include "User.h"
#include "InteractObject.h"
#include "Mirror.h"
#include "Sword.h"
using namespace std;
Sword::Sword(string d, string l):InteractObject(true,false,d,l,"sword")
{
}
void Sword::beCalled(string v, User& b)
{
if(sameLoc(b)||getInventoryState())
{
if(v == "use")
beUsed();
else if(v == "get")
bePickedUp(b);
else if(v == "drop")
beDropped(b);
else if(v == "look")
beLooked();
else
cout<<"I can't do that."<<endl;
}
else
cout<<"I don't see a sword."<<endl;
};
void Sword::beCalled2(string v, User& b, InteractObject* p)
{
if(p->sameLoc(b))
{
if(p->getName() == "mirror")
{
dynamic_cast<Mirror*>(p)->beBroken(b);
}
else if (p->getName() == "painting")
{
cout<<"Why would you try to destroy such a nice piece of artwork?"<<endl;
}
else
{
cout<<"I can't do that."<<endl;
}
}
else
cout<<"I can't do that."<<endl;
};
void Sword::beUsed()
{
if(getInventoryState())
{
cout<<"You swing the sword around with a flourish, but you then fumble and \ncut yourself and realize how exceedingly stupid you look."<<endl;
}
else
cout<<"You don't have a sword. Be cool if you did though."<<endl;
};
void Sword::bePickedUp(User& b)
{
if(getInventoryState())
{
cout<<"The sword is already in your inventory."<<endl;
}
else
{
cout<<"The sword seems to glow softly as you pick it up"<<endl;
cout<<"Picked Up"<<endl;
changeInventoryState("Sword", b);
}
};
void Sword::beDropped(User& b)
{
if(getInventoryState())
{
cout<<"Dropped the Sword"<<endl;
changeInventoryState("Sword", b);
changeLocation(b.getLocation());
}
else
{
cout<<"You don't have a sword (I'm sure you wish you did)."<<endl;
}
}
void Sword::beLooked()
{
cout<<getDescription()<<endl;
};