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 
24 class ObjectWrapper : public AssetTWrapper<object> {
25  Q_OBJECT
26 
27  Q_PROPERTY(QString name READ name)
28  Q_PROPERTY(QString race READ race)
29  Q_PROPERTY(QString title READ title)
30  Q_PROPERTY(QString slaying READ slaying)
31  Q_PROPERTY(QString skill READ skill)
32  Q_PROPERTY(int type READ type)
33  Q_PROPERTY(int subType READ subType)
34  Q_PROPERTY(int level READ level WRITE setLevel)
35  Q_PROPERTY(int suggested_level READ suggested_level);
36  Q_PROPERTY(bool isMonster READ isMonster)
37  Q_PROPERTY(bool isAlive READ isAlive)
38  Q_PROPERTY(bool isGenerator READ isGenerator)
39  Q_PROPERTY(qint64 experience READ experience WRITE setExperience)
40  Q_PROPERTY(quint32 attacktype READ attacktype)
41  Q_PROPERTY(int ac READ ac WRITE setAc)
42  Q_PROPERTY(int con READ con WRITE setCon)
43  Q_PROPERTY(int wc READ wc WRITE setWc)
44  Q_PROPERTY(QObject* arch READ arch)
45  Q_PROPERTY(int damage READ damage WRITE setDamage)
46  Q_PROPERTY(int hp READ hp WRITE setHp)
47  Q_PROPERTY(int weight READ weight WRITE setWeight)
48  Q_PROPERTY(QString materialName READ materialName)
49  Q_PROPERTY(QObject* randomItems READ randomItems)
50  Q_PROPERTY(float speed READ speed WRITE setSpeed);
51  Q_PROPERTY(float dps READ dps);
52  Q_PROPERTY(float regen READ regen);
53 
54  public:
55  ObjectWrapper(AssetWrapper *parent, object *ob, ResourcesManager *resourcesManager);
56  virtual ~ObjectWrapper();
57 
58  virtual QString displayName() const override { return name(); }
59 
60  object *getObject() { return myWrappedItem; }
61 
62  AssetWrapper* arch();
63  QString name() const;
64  QString race() const;
65  QString title() const { return myWrappedItem->title; }
66  QString slaying() const { return myWrappedItem->slaying; }
67  QString skill() const { return myWrappedItem->skill; }
68  int type() const;
69  int subType() const { return myWrappedItem->subtype; }
70  int level() const;
71  int suggested_level() const;
73  bool isMonster() const;
74  bool isAlive() const;
76  int64_t experience() const { return myWrappedItem->stats.exp; }
78  quint32 attacktype() const;
79  int8_t ac() const { return myWrappedItem->stats.ac; }
80  void setAc(int8_t ac) { myWrappedItem->stats.ac = ac; }
81  int8_t wc() const { return myWrappedItem->stats.wc; }
82  void setWc(int8_t wc) { myWrappedItem->stats.wc = wc; }
83  int16_t damage() const { return myWrappedItem->stats.dam; }
84  int8_t con() const { return myWrappedItem->stats.Con; }
85  void setCon(int8_t con) { myWrappedItem->stats.Con = con; }
86  void setDamage(int16_t damage) { myWrappedItem->stats.dam = damage; }
87  int16_t hp() const { return myWrappedItem->stats.hp; }
88  void setHp(int16_t hp) { myWrappedItem->stats.hp = hp; }
89  int32_t weight() const { return myWrappedItem->weight; }
90  void setWeight(int32_t weight) { myWrappedItem->weight = weight; }
91  QString materialName() const;
93  float speed() const { return myWrappedItem->speed; }
94  void setSpeed(float speed) { myWrappedItem->speed = speed; }
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:103
Face
Definition: face.h:14
global.h
liv::dam
int16_t dam
Definition: living.h:46
ObjectWrapper::setWeight
void setWeight(int32_t weight)
Definition: ObjectWrapper.h:90
obj::face
const Face * face
Definition: object.h:339
ObjectWrapper::name
QString name
Definition: ObjectWrapper.h:27
ObjectWrapper::wc
int wc
Definition: ObjectWrapper.h:43
AssetWrapper.h
ObjectWrapper::displayName
virtual QString displayName() const override
Definition: ObjectWrapper.h:58
FLAG_GENERATOR
#define FLAG_GENERATOR
Definition: define.h:248
ObjectWrapper::myResourcesManager
ResourcesManager * myResourcesManager
Definition: ObjectWrapper.h:100
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
ResourcesManager
Definition: ResourcesManager.h:80
ObjectWrapper::face
const Face * face() const
Definition: ObjectWrapper.h:95
ObjectWrapper::setWc
void setWc(int8_t wc)
Definition: ObjectWrapper.h:82
liv::wc
int8_t wc
Definition: living.h:37
ObjectWrapper::hp
int16_t hp() const
Definition: ObjectWrapper.h:87
guildjoin.ob
ob
Definition: guildjoin.py:42
liv::hp
int16_t hp
Definition: living.h:40
ObjectWrapper::skill
QString skill() const
Definition: ObjectWrapper.h:67
ObjectWrapper::wc
int8_t wc() const
Definition: ObjectWrapper.h:81
ObjectWrapper::materialName
QString materialName
Definition: ObjectWrapper.h:48
ObjectWrapper::con
int con
Definition: ObjectWrapper.h:42
ObjectWrapper::setCon
void setCon(int8_t con)
Definition: ObjectWrapper.h:85
obj::slaying
sstring slaying
Definition: object.h:325
ObjectWrapper::dps
float dps
Definition: ObjectWrapper.h:50
liv::exp
int64_t exp
Definition: living.h:47
ObjectWrapper::isGenerator
bool isGenerator
Definition: ObjectWrapper.h:38
titlestruct
Definition: readable.cpp:108
ObjectWrapper
Definition: ObjectWrapper.h:24
ObjectWrapper::attacktype
quint32 attacktype
Definition: ObjectWrapper.h:40
ObjectWrapper::skill
QString skill
Definition: ObjectWrapper.h:31
AssetWrapper
Definition: AssetWrapper.h:25
ObjectWrapper::slaying
QString slaying() const
Definition: ObjectWrapper.h:66
ObjectWrapper::suggested_level
int suggested_level
Definition: ObjectWrapper.h:35
ObjectWrapper::type
int type
Definition: ObjectWrapper.h:32
ObjectWrapper::randomItems
QObject randomItems
Definition: ObjectWrapper.h:49
ObjectWrapper::damage
int16_t damage() const
Definition: ObjectWrapper.h:83
obj::speed
float speed
Definition: object.h:335
ObjectWrapper::setLevel
void setLevel(int level)
Definition: ObjectWrapper.h:72
liv::Con
int8_t Con
Definition: living.h:36
ObjectWrapper::ac
int ac
Definition: ObjectWrapper.h:41
ObjectWrapper::isAlive
bool isAlive
Definition: ObjectWrapper.h:37
ObjectWrapper::experience
int64_t experience() const
Definition: ObjectWrapper.h:76
obj::title
sstring title
Definition: object.h:323
ObjectWrapper::regen
float regen
Definition: ObjectWrapper.h:51
ObjectWrapper::setExperience
void setExperience(int64_t experience)
Definition: ObjectWrapper.h:77
ObjectWrapper::isGenerator
bool isGenerator() const
Definition: ObjectWrapper.h:75
obj::stats
living stats
Definition: object.h:376
ObjectWrapper::setAc
void setAc(int8_t ac)
Definition: ObjectWrapper.h:80
obj::weight
int32_t weight
Definition: object.h:373
ObjectWrapper::getObject
object * getObject()
Definition: ObjectWrapper.h:60
TreasureListWrapper.h
ObjectWrapper::weight
int32_t weight() const
Definition: ObjectWrapper.h:89
ObjectWrapper::setSpeed
void setSpeed(float speed)
Definition: ObjectWrapper.h:94
ObjectWrapper::hp
int hp
Definition: ObjectWrapper.h:46
ObjectWrapper::con
int8_t con() const
Definition: ObjectWrapper.h:84
ObjectWrapper::setHp
void setHp(int16_t hp)
Definition: ObjectWrapper.h:88
ObjectWrapper::level
int level
Definition: ObjectWrapper.h:34
ObjectWrapper::experience
qint64 experience
Definition: ObjectWrapper.h:39
ObjectWrapper::weight
int weight
Definition: ObjectWrapper.h:47
ObjectWrapper::slaying
QString slaying
Definition: ObjectWrapper.h:30
obj::subtype
uint8_t subtype
Definition: object.h:347
ObjectWrapper::damage
int damage
Definition: ObjectWrapper.h:45
ObjectWrapper::ac
int8_t ac() const
Definition: ObjectWrapper.h:79
liv::ac
int8_t ac
Definition: living.h:38
obj::skill
sstring skill
Definition: object.h:327
ObjectWrapper::subType
int subType() const
Definition: ObjectWrapper.h:69
ObjectWrapper::race
QString race
Definition: ObjectWrapper.h:28
ObjectWrapper::speed
float speed
Definition: ObjectWrapper.h:50
ObjectWrapper::setDamage
void setDamage(int16_t damage)
Definition: ObjectWrapper.h:86
ObjectWrapper::isMonster
bool isMonster
Definition: ObjectWrapper.h:35
ObjectWrapper::subType
int subType
Definition: ObjectWrapper.h:33
ObjectWrapper::speed
float speed() const
Definition: ObjectWrapper.h:93
ObjectWrapper::arch
QObject arch
Definition: ObjectWrapper.h:44
ObjectWrapper::title
QString title() const
Definition: ObjectWrapper.h:65
obj::level
int16_t level
Definition: object.h:359
AssetTWrapper
Definition: AssetWrapper.h:93
level
Definition: level.py:1