blob: ae25453d8d7662a693060553fbbe6e2d1854e116 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// container/moneyhandler.c -- money handler for container
4//
5// $Id: moneyhandler.c 6738 2008-02-19 18:46:14Z Humni $
6#pragma strong_types
7#pragma save_types
8#pragma range_check
9#pragma no_clone
10#pragma pedantic
11
12#define NEED_PROTOTYPES
13#include <thing/properties.h>
14#undef NEED_PROTOTYPES
15
16#include <properties.h>
17#include <moving.h>
18#include <money.h>
19
20public int AddMoney( int amount )
21{
22 object ob;
23 int ret;
24
25 if ( !amount )
26 return 1;
27
28 ob = clone_object( GELD );
29 ob->SetProp( P_AMOUNT, amount );
30
31 ret=ob->move( this_object(), M_PUT|M_MOVE_ALL );
32 // Bei fehlerhaftem move ggf. wieder zerstoeren.
33 if ((ret != MOVE_OK)
34 && ob)
35 {
36 ob->remove(1);
37 }
38 return ret;
39}
40
41public int QueryMoney()
42{
43 object money;
44 int geld;
45
46 if ( money = present_clone(GELD, this_object()) )
47 geld = money->QueryProp(P_AMOUNT);
48
49 if ( money = present(GELDBOERSE_MIT_GELD, this_object()) )
50 geld += money->QueryProp(P_AMOUNT);
51
52 return geld;
53}