Crossfire Server, Trunk
ObjectWrapper.h
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #ifndef CRE_WRAPPER_OBJECT_h
14 #define CRE_WRAPPER_OBJECT_h
15 
16 #include <QObject>
17 
18 #include "global.h"
19 #include "assets/AssetWrapper.h"
21 
22 class ResourcesManager;
23 
30 #define OBJ_FLAG(name_, flag_) \
31  public: \
32  bool name_() const { return QUERY_FLAG(myWrappedItem, flag_); } \
33  void name_(bool value) const { if (value) SET_FLAG(myWrappedItem, flag_); else CLEAR_FLAG(myWrappedItem, flag_); } \
34  Q_PROPERTY(bool name_ READ name_ WRITE name_)
35 
36 class ObjectWrapper : public AssetTWrapper<object> {
37  Q_OBJECT
38 
39  ATW_RPROP(QString, name, name)
40  ATW_RPROP(QString, race, race)
41  ATW_RPROP(QString, title, title)
42  ATW_RPROP(QString, slaying, slaying)
43  ATW_RPROP(QString, skill, skill)
44  ATW_RPROP(int, type, type)
45  ATW_RPROP(int, subType, subtype)
46  ATW_PROP(int, level, level)
47  Q_PROPERTY(int suggested_level READ suggested_level);
48  OBJ_FLAG(isMonster, FLAG_MONSTER)
49  OBJ_FLAG(isAlive, FLAG_ALIVE)
50  OBJ_FLAG(isGenerator, FLAG_GENERATOR)
51  OBJ_FLAG(isUnaggressive, FLAG_UNAGGRESSIVE)
52  ATW_RPROP(quint32, attacktype, attacktype)
53  ATW_PROP(int, str, stats.Str);
54  ATW_PROP(int, dex, stats.Dex);
55  ATW_PROP(int, con, stats.Con);
56  ATW_PROP(int, wis, stats.Wis);
57  ATW_PROP(int, cha, stats.Cha);
58  ATW_PROP(int, intl, stats.Int);
59  ATW_PROP(int, pow, stats.Pow);
60  ATW_PROP(int, wc, stats.wc)
61  ATW_PROP(int, ac, stats.ac)
62  ATW_PROP(int, luck, stats.luck)
63  ATW_PROP(int, hp, stats.hp)
64  ATW_PROP(int, maxhp, stats.maxhp)
65  ATW_PROP(int, sp, stats.sp)
66  ATW_PROP(int, maxsp, stats.maxsp)
67  ATW_PROP(int, grace, stats.grace)
68  ATW_PROP(int, maxgrace, stats.maxgrace)
69  ATW_PROP(int, damage, stats.dam)
70  ATW_PROP(qint64, experience, stats.exp)
71  ATW_PROP(int, food, stats.food)
72  Q_PROPERTY(QObject* arch READ arch)
73  ATW_PROP(int, weight, weight)
74  ATW_RPROP(QString, materialName, materialname)
75  Q_PROPERTY(QObject* randomItems READ randomItems)
76  ATW_PROP(float, speed, speed);
77  Q_PROPERTY(float dps READ dps);
78  Q_PROPERTY(float regen READ regen);
79  ATW_RPROP(int, nrof, nrof);
80  ATW_PROP(quint32, path_attuned, path_attuned);
81  ATW_PROP(quint32, path_repelled, path_repelled);
82  ATW_PROP(quint32, path_denied, path_denied);
83 
84  public:
85  ObjectWrapper(AssetWrapper *parent, object *ob, ResourcesManager *resourcesManager);
86  virtual ~ObjectWrapper();
87 
88  virtual QString displayName() const override { return name(); }
89 
90  object *getObject() { return myWrappedItem; }
91 
92  AssetWrapper* arch();
93  int suggested_level() const;
95  const Face *face() const { return myWrappedItem->face; }
96  float dps() const;
97  float regen() const;
98 
99  protected:
101 };
102 
103 #endif // CRE_WRAPPER_OBJECT_h
AssetTWrapper< object >::myWrappedItem
object * myWrappedItem
Definition: AssetWrapper.h:104
Face
Definition: face.h:14
global.h
sword_of_souls.Dex
Dex
Definition: sword_of_souls.py:57
sword_of_souls.Pow
Pow
Definition: sword_of_souls.py:60
AssetWrapper.h
ObjectWrapper::displayName
virtual QString displayName() const override
Definition: ObjectWrapper.h:88
FLAG_GENERATOR
#define FLAG_GENERATOR
Definition: define.h:248
sword_of_souls.Str
Str
Definition: sword_of_souls.py:56
ObjectWrapper::myResourcesManager
ResourcesManager * myResourcesManager
Definition: ObjectWrapper.h:100
ResourcesManager
Definition: ResourcesManager.h:80
ObjectWrapper::face
const Face * face() const
Definition: ObjectWrapper.h:95
sword_of_souls.Con
Con
Definition: sword_of_souls.py:58
guildjoin.ob
ob
Definition: guildjoin.py:42
ObjectWrapper::ATW_RPROP
ATW_RPROP(int, nrof, nrof)
curse_on_apply.ac
ac
Definition: curse_on_apply.py:4
FLAG_ALIVE
#define FLAG_ALIVE
Definition: define.h:230
ObjectWrapper::dps
float dps
Definition: ObjectWrapper.h:77
ObjectWrapper
Definition: ObjectWrapper.h:36
sword_of_souls.Wis
Wis
Definition: sword_of_souls.py:61
AssetWrapper
Definition: AssetWrapper.h:25
make_face_from_files.str
str
Definition: make_face_from_files.py:30
object::face
const Face * face
Definition: object.h:341
ObjectWrapper::suggested_level
int suggested_level
Definition: ObjectWrapper.h:47
ObjectWrapper::ATW_PROP
ATW_PROP(int, str, stats.Str)
title
Definition: readable.cpp:108
ObjectWrapper::randomItems
QObject randomItems
Definition: ObjectWrapper.h:75
FLAG_UNAGGRESSIVE
#define FLAG_UNAGGRESSIVE
Definition: define.h:272
FLAG_MONSTER
#define FLAG_MONSTER
Definition: define.h:245
sword_of_souls.Cha
Cha
Definition: sword_of_souls.py:62
ObjectWrapper::regen
float regen
Definition: ObjectWrapper.h:77
sword_of_souls.Int
Int
Definition: sword_of_souls.py:59
ObjectWrapper::getObject
object * getObject()
Definition: ObjectWrapper.h:90
TreasureListWrapper.h
OBJ_FLAG
#define OBJ_FLAG(name_, flag_)
Definition: ObjectWrapper.h:30
ObjectWrapper::arch
QObject arch
Definition: ObjectWrapper.h:72
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
give.name
name
Definition: give.py:27
AssetTWrapper
Definition: AssetWrapper.h:94
level
Definition: level.py:1