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  ATW_RPROP(quint32, attacktype, attacktype)
52  ATW_PROP(int, str, stats.Str);
53  ATW_PROP(int, dex, stats.Dex);
54  ATW_PROP(int, con, stats.Con);
55  ATW_PROP(int, wis, stats.Wis);
56  ATW_PROP(int, cha, stats.Cha);
57  ATW_PROP(int, intl, stats.Int);
58  ATW_PROP(int, pow, stats.Pow);
59  ATW_PROP(int, wc, stats.wc)
60  ATW_PROP(int, ac, stats.ac)
61  ATW_PROP(int, luck, stats.luck)
62  ATW_PROP(int, hp, stats.hp)
63  ATW_PROP(int, maxhp, stats.maxhp)
64  ATW_PROP(int, sp, stats.sp)
65  ATW_PROP(int, maxsp, stats.maxsp)
66  ATW_PROP(int, grace, stats.grace)
67  ATW_PROP(int, maxgrace, stats.maxgrace)
68  ATW_PROP(int, damage, stats.dam)
69  ATW_PROP(qint64, experience, stats.exp)
70  ATW_PROP(int, food, stats.food)
71  Q_PROPERTY(QObject* arch READ arch)
72  ATW_PROP(int, weight, weight)
73  ATW_RPROP(QString, materialName, materialname)
74  Q_PROPERTY(QObject* randomItems READ randomItems)
75  ATW_PROP(float, speed, speed);
76  Q_PROPERTY(float dps READ dps);
77  Q_PROPERTY(float regen READ regen);
78 
79  public:
80  ObjectWrapper(AssetWrapper *parent, object *ob, ResourcesManager *resourcesManager);
81  virtual ~ObjectWrapper();
82 
83  virtual QString displayName() const override { return name(); }
84 
85  object *getObject() { return myWrappedItem; }
86 
87  AssetWrapper* arch();
88  int suggested_level() const;
90  const Face *face() const { return myWrappedItem->face; }
91  float dps() const;
92  float regen() const;
93 
94  protected:
96 };
97 
98 #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:83
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:95
ResourcesManager
Definition: ResourcesManager.h:80
ObjectWrapper::face
const Face * face() const
Definition: ObjectWrapper.h:90
sword_of_souls.Con
Con
Definition: sword_of_souls.py:58
guildjoin.ob
ob
Definition: guildjoin.py:42
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:76
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:24
object::face
const Face * face
Definition: object.h:339
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:74
FLAG_MONSTER
#define FLAG_MONSTER
Definition: define.h:245
sword_of_souls.Cha
Cha
Definition: sword_of_souls.py:62
ATW_RPROP
#define ATW_RPROP(type_, name_, field_)
Definition: AssetWrapper.h:114
ObjectWrapper::regen
float regen
Definition: ObjectWrapper.h:76
sword_of_souls.Int
Int
Definition: sword_of_souls.py:59
ObjectWrapper::getObject
object * getObject()
Definition: ObjectWrapper.h:85
TreasureListWrapper.h
OBJ_FLAG
#define OBJ_FLAG(name_, flag_)
Definition: ObjectWrapper.h:30
ObjectWrapper::arch
QObject arch
Definition: ObjectWrapper.h:71
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