2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2013-08-19 14:29:29 +00:00
|
|
|
|
|
|
|
#ifndef CHARACTER_H
|
|
|
|
#define CHARACTER_H
|
|
|
|
|
|
|
|
#include <QJsonObject>
|
2017-08-22 07:52:55 +00:00
|
|
|
#include <QObject>
|
2013-08-19 14:29:29 +00:00
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
//! [0]
|
|
|
|
class Character
|
|
|
|
{
|
2023-02-07 12:52:50 +00:00
|
|
|
Q_GADGET
|
2017-08-22 07:52:55 +00:00
|
|
|
|
2013-08-19 14:29:29 +00:00
|
|
|
public:
|
|
|
|
enum ClassType {
|
|
|
|
Warrior, Mage, Archer
|
|
|
|
};
|
2017-08-22 07:52:55 +00:00
|
|
|
Q_ENUM(ClassType)
|
2013-08-19 14:29:29 +00:00
|
|
|
|
|
|
|
Character();
|
|
|
|
Character(const QString &name, int level, ClassType classType);
|
|
|
|
|
|
|
|
QString name() const;
|
|
|
|
void setName(const QString &name);
|
|
|
|
|
|
|
|
int level() const;
|
|
|
|
void setLevel(int level);
|
|
|
|
|
|
|
|
ClassType classType() const;
|
|
|
|
void setClassType(ClassType classType);
|
|
|
|
|
|
|
|
void read(const QJsonObject &json);
|
|
|
|
void write(QJsonObject &json) const;
|
2017-08-22 07:52:55 +00:00
|
|
|
|
|
|
|
void print(int indentation = 0) const;
|
2013-08-19 14:29:29 +00:00
|
|
|
private:
|
|
|
|
QString mName;
|
2023-02-07 12:52:50 +00:00
|
|
|
int mLevel = 0;
|
|
|
|
ClassType mClassType = Warrior;
|
2013-08-19 14:29:29 +00:00
|
|
|
};
|
|
|
|
//! [0]
|
|
|
|
|
|
|
|
#endif // CHARACTER_H
|