Lucas-Bot/dependencies/Person/Person.h

80 lines
2.2 KiB
C
Raw Normal View History

2022-10-08 22:47:18 +08:00
/*
* This file is part of Lucas' Bot.
*
* Lucas' Bot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
Lucas' Bot is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
for more details.
You should have received a copy of the GNU Affero General Public License along
with Lucas' Bot. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef PERSON_DEMO_PERSON_H
#define PERSON_DEMO_PERSON_H
2022-10-20 13:15:42 +08:00
#ifdef _MSC_VER
#ifdef EXPORT_PERSON
#define PERSON_LIB __declspec(dllexport)
#else
#define PERSON_LIB __declspec(dllimport)
#endif
2022-10-20 16:14:46 +08:00
#else
#define PERSON_LIB
2022-10-20 13:15:42 +08:00
#endif
2022-10-08 22:47:18 +08:00
#include <ctime>
#include "json.hpp"
2022-10-20 13:15:42 +08:00
#ifndef MIRAICP_PRO_PLUGINCONFIG_H
2022-10-08 22:47:18 +08:00
namespace MiraiCP {
using QQID = unsigned long long;
}
2022-10-20 13:15:42 +08:00
#endif
2022-10-08 22:47:18 +08:00
class Person {
private:
MiraiCP::QQID qqID;
// 上次签到时间
std::time_t lastSignOnTime;
// 连续签到天数
int signOnDays;
// 发言未被攻击累计次数
int speakCount;
// 铜钱数量
int copperCoin;
public:
// Generate ctors and dtors
// assignment operators
2022-10-20 13:15:42 +08:00
PERSON_LIB Person();
explicit PERSON_LIB Person(MiraiCP::QQID id);
2022-10-08 22:47:18 +08:00
// Deserialize from JSON
2022-10-20 13:15:42 +08:00
explicit PERSON_LIB Person(const nlohmann::json&);
PERSON_LIB ~Person();
PERSON_LIB Person(const Person&);
PERSON_LIB Person& operator=(const Person&);
PERSON_LIB Person(Person&&);
PERSON_LIB Person& operator=(Person&&);
2022-10-08 22:47:18 +08:00
2022-10-20 13:15:42 +08:00
[[nodiscard]] bool PERSON_LIB isSignOnToday() const;
void PERSON_LIB signOn();
[[nodiscard]] int PERSON_LIB continuousSignOnDays() const;
2022-10-08 22:47:18 +08:00
2022-10-20 13:15:42 +08:00
[[nodiscard]] bool PERSON_LIB willBeAttackNextTime() const;
void PERSON_LIB resetAttackCount();
void PERSON_LIB increaseSpeakCount();
2022-10-08 22:47:18 +08:00
2022-10-20 13:15:42 +08:00
[[nodiscard]] int PERSON_LIB getCopperCoin() const;
nlohmann::json PERSON_LIB serializeToJSON();
2022-10-08 22:47:18 +08:00
2022-10-20 13:15:42 +08:00
[[nodiscard]] MiraiCP::QQID PERSON_LIB getQQID() const;
2022-10-08 22:47:18 +08:00
};
#endif //PERSON_DEMO_PERSON_H