-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActionTake.cpp
38 lines (35 loc) · 1 KB
/
ActionTake.cpp
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
#include "Action.h"
#include "Player.h"
#include <iostream>
#include "Flags.h"
#include "Object.h"
class ActionTake : public Action
{
virtual void doWith(const std::string ¶meter1, const std::string ¶meter2) const
{
Location *curLocation = player.getLocation();
Object *curObject = curLocation->getObject(parameter1);
if (curObject != NULL)
{
if (curObject->canHandle())
{
player.takeObject(curObject);
curLocation->removeObject(curObject);
if ((curObject->getKind() != OKSonnik) && (curObject->getKind() != OKShishka) && (curObject->getKind() != OKBall))
{
setStateFlag(FlagGetProgress, getStateFlag(FlagGetProgress)+1);
getProgress();
}
}
else std::cout << "Âû íå ìîæåòå ýòî âçÿòü!\n";
}
else std::cout << "Çäåñü íåò òàêîãî ïðåäìåòà!\n";
}
virtual const char * const * getNames() const
{
static const char *names[] = {"âçÿòü", "ïîäíÿòü", "ïîëó÷èòü", "çàáðàòü", 0};
return names;
}
};
static ActionTake action;
const Action *actionTake = &action;