2020-08-24 21:04:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "CNShardServer.hpp"
|
2020-09-10 13:01:35 +00:00
|
|
|
#include "Player.hpp"
|
2020-08-24 21:04:56 +00:00
|
|
|
|
2020-09-09 19:09:01 +00:00
|
|
|
#include "contrib/JSON.hpp"
|
|
|
|
|
|
|
|
struct Reward {
|
|
|
|
int32_t id;
|
|
|
|
int32_t itemTypes[4];
|
|
|
|
int32_t itemIds[4];
|
|
|
|
int32_t money;
|
|
|
|
int32_t fusionmatter;
|
|
|
|
|
|
|
|
Reward(int32_t id, nlohmann::json types, nlohmann::json ids, int32_t m, int32_t fm) :
|
|
|
|
id(id), money(m), fusionmatter(fm) {
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
itemTypes[i] = types[i];
|
|
|
|
itemIds[i] = ids[i];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-09-10 16:40:38 +00:00
|
|
|
struct TaskData {
|
|
|
|
/*
|
|
|
|
* TODO: We'll probably want to keep only the data the server actually needs,
|
|
|
|
* but for now RE/development is much easier if we have everything at
|
|
|
|
* our fingertips.
|
|
|
|
*/
|
|
|
|
nlohmann::json task;
|
|
|
|
|
|
|
|
TaskData(nlohmann::json t) : task(t) {}
|
|
|
|
|
|
|
|
// convenience
|
|
|
|
auto operator[](std::string s) { return task[s]; }
|
2020-09-10 13:01:35 +00:00
|
|
|
};
|
|
|
|
|
2020-08-24 21:04:56 +00:00
|
|
|
namespace MissionManager {
|
2020-09-09 19:09:01 +00:00
|
|
|
extern std::map<int32_t, Reward*> Rewards;
|
2020-09-10 16:40:38 +00:00
|
|
|
extern std::map<int32_t, TaskData*> Tasks;
|
2020-09-23 19:44:27 +00:00
|
|
|
extern nlohmann::json AvatarGrowth[36];
|
2020-08-24 21:04:56 +00:00
|
|
|
void init();
|
|
|
|
|
2020-09-10 16:40:38 +00:00
|
|
|
void taskStart(CNSocket* sock, CNPacketData* data);
|
|
|
|
void taskEnd(CNSocket* sock, CNPacketData* data);
|
2020-08-24 21:04:56 +00:00
|
|
|
void setMission(CNSocket* sock, CNPacketData* data);
|
|
|
|
void quitMission(CNSocket* sock, CNPacketData* data);
|
2020-09-10 13:01:35 +00:00
|
|
|
|
2020-09-10 16:40:38 +00:00
|
|
|
int findQSlot(Player *plr, int id);
|
2020-09-10 13:01:35 +00:00
|
|
|
void dropQuestItem(CNSocket *sock, int task, int count, int id, int mobid);
|
2020-09-21 19:43:53 +00:00
|
|
|
//checks if player doesn't have n/n quest items
|
|
|
|
bool isQuestItemFull(CNSocket* sock, int itemId, int itemCount);
|
2020-09-10 21:40:17 +00:00
|
|
|
int giveMissionReward(CNSocket *sock, int task);
|
2020-09-23 19:44:27 +00:00
|
|
|
void updateFusionMatter(CNSocket* sock);
|
2020-09-10 16:40:38 +00:00
|
|
|
|
|
|
|
void mobKilled(CNSocket *sock, int mobid);
|
2020-09-13 18:45:51 +00:00
|
|
|
|
|
|
|
void saveMission(Player* player, int missionId);
|
2020-09-09 19:09:01 +00:00
|
|
|
}
|