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  Q_PROPERTY(QString arch_name READ archName)
40  ATW_RPROP(QString, name, name)
41  ATW_RPROP(QString, race, race)
42  ATW_RPROP(QString, title, title)
43  ATW_RPROP(QString, slaying, slaying)
44  ATW_RPROP(QString, skill, skill)
45  ATW_RPROP(int, type, type)
46  ATW_RPROP(int, subType, subtype)
47  ATW_PROP(int, level, level)
48  Q_PROPERTY(int suggested_level READ suggested_level);
49  OBJ_FLAG(isMonster, FLAG_MONSTER)
50  OBJ_FLAG(isAlive, FLAG_ALIVE)
51  OBJ_FLAG(isGenerator, FLAG_GENERATOR)
52  OBJ_FLAG(isUnaggressive, FLAG_UNAGGRESSIVE)
53  ATW_RPROP(quint32, attacktype, attacktype)
54  ATW_PROP(int, str, stats.Str);
55  ATW_PROP(int, dex, stats.Dex);
56  ATW_PROP(int, con, stats.Con);
57  ATW_PROP(int, wis, stats.Wis);
58  ATW_PROP(int, cha, stats.Cha);
59  ATW_PROP(int, intl, stats.Int);
60  ATW_PROP(int, pow, stats.Pow);
61  ATW_PROP(int, wc, stats.wc)
62  ATW_PROP(int, ac, stats.ac)
63  ATW_PROP(int, luck, stats.luck)
64  ATW_PROP(int, hp, stats.hp)
65  ATW_PROP(int, maxhp, stats.maxhp)
66  ATW_PROP(int, sp, stats.sp)
67  ATW_PROP(int, maxsp, stats.maxsp)
68  ATW_PROP(int, grace, stats.grace)
69  ATW_PROP(int, maxgrace, stats.maxgrace)
70  ATW_PROP(int, damage, stats.dam)
71  ATW_PROP(qint64, experience, stats.exp)
72  ATW_PROP(int, food, stats.food)
73  Q_PROPERTY(QObject* arch READ arch)
74  ATW_PROP(int, weight, weight)
75  ATW_RPROP(QString, materialName, materialname)
76  Q_PROPERTY(QObject* randomItems READ randomItems)
77  ATW_PROP(float, speed, speed);
78  Q_PROPERTY(float dps READ dps);
79  Q_PROPERTY(float regen READ regen);
80  ATW_RPROP(int, nrof, nrof);
81  ATW_PROP(quint32, path_attuned, path_attuned);
82  ATW_PROP(quint32, path_repelled, path_repelled);
83  ATW_PROP(quint32, path_denied, path_denied);
84 
85  public:
86  ObjectWrapper(AssetWrapper *parent, object *ob, ResourcesManager *resourcesManager);
87  virtual ~ObjectWrapper();
88 
89  virtual QString displayName() const override { return name(); }
90 
91  object *getObject() { return myWrappedItem; }
92 
93  QString archName() const { return myWrappedItem->arch->name; }
94  AssetWrapper* arch();
95  int suggested_level() const;
97  const Face *face() const { return myWrappedItem->face; }
98  float dps() const;
99  float regen() const;
100 
101  protected:
103 };
104 
105 #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:89
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:102
ResourcesManager
Definition: ResourcesManager.h:80
ObjectWrapper::face
const Face * face() const
Definition: ObjectWrapper.h:97
ObjectWrapper::arch_name
QString arch_name
Definition: ObjectWrapper.h:39
object::arch
struct archetype * arch
Definition: object.h:424
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:78
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:48
ObjectWrapper::ATW_PROP
ATW_PROP(int, str, stats.Str)
title
Definition: readable.cpp:108
ObjectWrapper::randomItems
QObject randomItems
Definition: ObjectWrapper.h:76
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:78
sword_of_souls.Int
Int
Definition: sword_of_souls.py:59
ObjectWrapper::getObject
object * getObject()
Definition: ObjectWrapper.h:91
TreasureListWrapper.h
OBJ_FLAG
#define OBJ_FLAG(name_, flag_)
Definition: ObjectWrapper.h:30
archetype::name
sstring name
Definition: object.h:484
ObjectWrapper::arch
QObject arch
Definition: ObjectWrapper.h:73
ObjectWrapper::archName
QString archName() const
Definition: ObjectWrapper.h:93
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