cosmetix
[k8-i-v-a-n.git] / src / game / items / item_moneybag.cpp
blob82e65515b9681d924c951fcfb0f50cccd2008367
1 #ifdef HEADER_PHASE
2 ITEM(moneybag, item)
4 public:
5 moneybag () : moneyAmount(1+RAND_N(300)) {
6 if (RAND_N(100) < 10) moneyAmount += 1000;
8 virtual truth Apply (character *beggar);
9 virtual void Save (outputfile &) const;
10 virtual void Load (inputfile &);
11 virtual truth IsConsumable () const { return false; }
12 virtual truth IsAppliable (ccharacter *beggar) const;
13 virtual truth CanBeHardened (ccharacter *) const { return false; }
14 virtual truth IsMoneyBag () const { return true; }
16 virtual sLong GetTruePrice () const { return moneyAmount; }
18 protected:
19 int moneyAmount;
23 #else
27 truth moneybag::IsAppliable (ccharacter *beggar) const {
28 return beggar->IsPlayer();
33 truth moneybag::Apply (character *beggar) {
34 if (!beggar->IsPlayer()) return false;
35 if (!game::TruthQuestion(CONST_S("Are you sure you want to open ")+GetName(DEFINITE)+"? [y/N]")) return false;
36 ADD_MESSAGE("You opens %s and found %i gold coins", CHAR_NAME(DEFINITE), moneyAmount);
37 beggar->EditMoney(moneyAmount);
38 RemoveFromSlot();
39 SendToHell();
40 return true;
45 void moneybag::Save (outputfile &saveFile) const {
46 item::Save(saveFile);
47 saveFile << moneyAmount;
52 void moneybag::Load (inputfile &saveFile) {
53 item::Load(saveFile);
54 saveFile >> moneyAmount;
56 #endif