quests.h

main 120 lines · 3 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1/**
2 * The Forgotten Server - a free and open-source MMORPG server emulator
3 * Copyright (C) 2019 Mark Samman <mark.samman@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#ifndef FS_QUESTS_H_16E44051F23547BE8097F8EA9FCAACA0
21#define FS_QUESTS_H_16E44051F23547BE8097F8EA9FCAACA0
22
23#include "player.h"
24#include "networkmessage.h"
25
26class Mission;
27class Quest;
28
29using MissionsList = std::list<Mission>;
30using QuestsList = std::list<Quest>;
31
32class Mission
33{
34 public:
35 Mission(std::string name, int32_t storageID, int32_t startValue, int32_t endValue, bool ignoreEndValue) :
36 name(std::move(name)), storageID(storageID), startValue(startValue), endValue(endValue), ignoreEndValue(ignoreEndValue) {}
37
38 bool isCompleted(Player* player) const;
39 bool isStarted(Player* player) const;
40 std::string getName(Player* player) const;
41 std::string getDescription(Player* player) const;
42
43 uint32_t getStorageId() const {
44 return storageID;
45 }
46 int32_t getStartStorageValue() const {
47 return startValue;
48 }
49 int32_t getEndStorageValue() const {
50 return endValue;
51 }
52
53 std::map<int32_t, std::string> descriptions;
54 std::string mainDescription;
55
56 private:
57 std::string name;
58 uint32_t storageID;
59 int32_t startValue, endValue;
60 bool ignoreEndValue;
61};
62
63class Quest
64{
65 public:
66 Quest(std::string name, uint16_t id, int32_t startStorageID, int32_t startStorageValue) :
67 name(std::move(name)), startStorageID(startStorageID), startStorageValue(startStorageValue), id(id) {}
68
69 bool isCompleted(Player* player) const;
70 bool isStarted(Player* player) const;
71 uint16_t getID() const {
72 return id;
73 }
74 std::string getName() const {
75 return name;
76 }
77 uint16_t getMissionsCount(Player* player) const;
78
79 uint32_t getStartStorageId() const {
80 return startStorageID;
81 }
82 int32_t getStartStorageValue() const {
83 return startStorageValue;
84 }
85
86 const MissionsList& getMissions() const {
87 return missions;
88 }
89
90 private:
91 std::string name;
92
93 uint32_t startStorageID;
94 int32_t startStorageValue;
95 uint16_t id;
96
97 MissionsList missions;
98
99 friend class Quests;
100};
101
102class Quests
103{
104 public:
105 const QuestsList& getQuests() const {
106 return quests;
107 }
108
109 bool loadFromXml();
110 Quest* getQuestByID(uint16_t id);
111 bool isQuestStorage(const uint32_t key, const int32_t value, const int32_t oldValue) const;
112 uint16_t getQuestsCount(Player* player) const;
113 bool reload();
114
115 private:
116 QuestsList quests;
117};
118
119#endif
120
Top