Crossfire Server, Trunk
CREMapInformation.cpp
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 #include "CREMapInformation.h"
14 #include "random_maps/RandomMap.h"
15 #include "quests/QuestWrapper.h"
16 #include "faces/FaceWrapper.h"
18 #include "scripts/ScriptFile.h"
20 
22 {
23  myDifficulty = 0;
25  myExperience = 0;
26  myShopGreed = 0;
27  myShopMin = 0;
28  myShopMax = 0;
29 }
30 
31 CREMapInformation::CREMapInformation(const QString& path) : AssetWrapper(nullptr, "Map")
32 {
33  myPath = path;
34  myDifficulty = 0;
36  myExperience = 0;
37  myShopGreed = 0;
38  myShopMin = 0;
39  myShopMax = 0;
40 }
41 
43 {
44  qDeleteAll(myRandomMaps);
45 }
46 
48 {
49  if (myName.isEmpty())
50  return myPath;
51  return myName;
52 }
53 
54 const QString& CREMapInformation::path() const
55 {
56  return myPath;
57 }
58 
59 void CREMapInformation::setPath(const QString& path)
60 {
61  myPath = path;
62 }
63 
64 const QString& CREMapInformation::name() const
65 {
66  return myName;
67 }
68 
69 void CREMapInformation::setName(const QString& name)
70 {
71  myName = name;
72 }
73 
75 {
76  return myBackgroundMusic;
77 }
78 
79 void CREMapInformation::setBackgroundMusic(const QString& music)
80 {
81  myBackgroundMusic = music;
82 }
83 
84 const QString& CREMapInformation::resetGroup() const
85 {
86  return myResetGroup;
87 }
88 
89 void CREMapInformation::setResetGroup(const QString& resetGroup)
90 {
92 }
93 
94 QStringList CREMapInformation::archetypes() const
95 {
96  return myArchetypes;
97 }
98 
100 {
101  if (!myArchetypes.contains(archetype))
102  myArchetypes.append(archetype);
103 }
104 
105 QStringList CREMapInformation::faces() const
106 {
107  return myFaces.values();
108 }
109 
110 void CREMapInformation::addFace(const QString& face)
111 {
112  myFaces.insert(face);
113 }
114 
115 QStringList CREMapInformation::animations() const
116 {
117  return myAnimations.values();
118 }
119 
121 {
122  myAnimations.insert(anim);
123 }
124 
125 const QDateTime& CREMapInformation::mapTime() const
126 {
127  return myMapTime;
128 }
129 
130 void CREMapInformation::setMapTime(const QDateTime& date)
131 {
132  myMapTime = date;
133 }
134 
135 QStringList CREMapInformation::exitsTo() const
136 {
137  return myExitsTo;
138 }
139 
140 void CREMapInformation::addExitTo(const QString& path)
141 {
142  if (!myExitsTo.contains(path))
143  myExitsTo.append(path);
144 }
145 
147 {
148  return myAccessedFrom;
149 }
150 
152 {
153  if (!myAccessedFrom.contains(path))
154  myAccessedFrom.append(path);
155 }
156 
158 {
159  return myDifficulty;
160 }
161 
163 {
165 }
166 
168 {
169  return myComputedDifficulty;
170 }
171 
172 void CREMapInformation::setComputedDifficulty(int computedDifficulty)
173 {
175 }
176 
177 qint64 CREMapInformation::experience() const
178 {
179  return myExperience;
180 }
181 
182 void CREMapInformation::setExperience(qint64 experience)
183 {
185 }
186 
187 const QString& CREMapInformation::region() const
188 {
189  return myRegion;
190 }
192 {
193  myRegion = region;
194 }
195 
196 QStringList CREMapInformation::messages() const
197 {
198  return myMessages;
199 }
200 
202 {
203  if (!myMessages.contains(message))
204  myMessages.append(message);
205 }
206 
207 QStringList CREMapInformation::quests() const
208 {
209  return myQuests;
210 }
211 
212 void CREMapInformation::addQuest(const QString& quest)
213 {
214  if (!myQuests.contains(quest))
215  myQuests.append(quest);
216 }
217 
218 QHash<QString, int>& CREMapInformation::shopItems()
219 {
220  return myShopItems;
221 }
222 
223 const QHash<QString, int>& CREMapInformation::shopItems() const
224 {
225  return myShopItems;
226 }
227 
229 {
230  return myShopGreed;
231 }
232 
234 {
235  myShopGreed = greed;
236 }
237 
238 const QString& CREMapInformation::shopRace() const
239 {
240  return myShopRace;
241 }
242 
243 void CREMapInformation::setShopRace(const QString& race)
244 {
245  myShopRace = race;
246 }
247 
249 {
250  return myShopMin;
251 }
252 
254 {
255  myShopMin = min;
256 }
257 
259 {
260  return myShopMax;
261 }
262 
264 {
265  myShopMax = max;
266 }
267 
268 QList<RandomMap*> CREMapInformation::randomMaps() const
269 {
270  return myRandomMaps;
271 }
272 
274 {
275  myRandomMaps.append(map);
276 }
277 
278 AssetWrapper::PossibleUse CREMapInformation::uses(const AssetWrapper *asset, std::string &hint) const {
279  auto quest = dynamic_cast<const QuestWrapper *>(asset);
280  if (quest) {
281  return myQuests.indexOf(quest->wrappedItem()->quest_code) == -1 ? DoesntUse : Uses;
282  }
283  auto face = dynamic_cast<const FaceWrapper *>(asset);
284  if (face) {
285  return myFaces.find(face->wrappedItem()->name) == myFaces.end() ? DoesntUse : Uses;
286  }
287  auto anim = dynamic_cast<const AnimationWrapper *>(asset);
288  if (anim) {
289  return myAnimations.find(anim->wrappedItem()->name) == myAnimations.end() ? DoesntUse : Uses;
290  }
291  auto script = dynamic_cast<const ScriptFile *>(asset);
292  if (script) {
293  return script->forMap(this) ? Uses : DoesntUse;
294  }
295  auto arch = dynamic_cast<const ArchetypeWrapper *>(asset);
296  if (arch) {
297  if (myArchetypes.indexOf(arch->wrappedItem()->name) != -1) {
298  return Uses;
299  };
300  for (auto map : myRandomMaps) {
301  if (strcmp(arch->wrappedItem()->name, map->parameters()->final_exit_archetype) == 0) {
302  hint = "random map final exit";
303  return Uses;
304  }
305  }
306  return DoesntUse;
307  }
308  return DoesntUse;
309 }
RandomMap
Definition: RandomMap.h:24
CREMapInformation::setShopGreed
void setShopGreed(double greed)
Definition: CREMapInformation.cpp:233
CREMapInformation::region
const QString & region() const
Definition: CREMapInformation.cpp:187
CREMapInformation::myFaces
QSet< QString > myFaces
Definition: CREMapInformation.h:114
CREMapInformation::myQuests
QStringList myQuests
Definition: CREMapInformation.h:124
CREMapInformation::displayName
virtual QString displayName() const override
Definition: CREMapInformation.cpp:47
CREMapInformation::setComputedDifficulty
void setComputedDifficulty(int computed)
Definition: CREMapInformation.cpp:172
CREMapInformation::myAnimations
QSet< QString > myAnimations
Definition: CREMapInformation.h:115
CREMapInformation::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: CREMapInformation.cpp:278
CREMapInformation::myDifficulty
int myDifficulty
Definition: CREMapInformation.h:119
CREMapInformation::difficulty
int difficulty
Definition: CREMapInformation.h:33
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
CREMapInformation::myName
QString myName
Definition: CREMapInformation.h:112
CREMapInformation.h
send.date
date
Definition: send.py:29
AnimationWrapper
Definition: AnimationWrapper.h:24
CREMapInformation::exitsTo
QStringList exitsTo() const
Definition: CREMapInformation.cpp:135
CREMapInformation::setPath
void setPath(const QString &path)
Definition: CREMapInformation.cpp:59
ScriptFile::forMap
bool forMap(const CREMapInformation *map) const
Definition: ScriptFile.cpp:30
CREMapInformation::shopItems
QHash< QString, int > & shopItems()
Definition: CREMapInformation.cpp:218
QuestWrapper
Definition: QuestWrapper.h:66
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:31
CREMapInformation::shopRace
const QString & shopRace() const
Definition: CREMapInformation.cpp:238
CREMapInformation::archetypes
QStringList archetypes() const
Definition: CREMapInformation.cpp:94
CREMapInformation::myMessages
QStringList myMessages
Definition: CREMapInformation.h:123
CREMapInformation::myShopItems
QHash< QString, int > myShopItems
Definition: CREMapInformation.h:125
CREMapInformation::myShopMax
quint64 myShopMax
Definition: CREMapInformation.h:128
CREMapInformation::myAccessedFrom
QStringList myAccessedFrom
Definition: CREMapInformation.h:118
CREMapInformation::setDifficulty
void setDifficulty(int difficulty)
Definition: CREMapInformation.cpp:162
CREMapInformation::myExitsTo
QStringList myExitsTo
Definition: CREMapInformation.h:117
CREMapInformation::addAnimation
void addAnimation(const QString &anim)
Definition: CREMapInformation.cpp:120
CREMapInformation::myResetGroup
QString myResetGroup
Definition: CREMapInformation.h:131
RandomMap.h
CREMapInformation::addMessage
void addMessage(const QString &message)
Definition: CREMapInformation.cpp:201
CREMapInformation::name
QString name
Definition: CREMapInformation.h:32
CREMapInformation::shopGreed
double shopGreed() const
Definition: CREMapInformation.cpp:228
archt
Definition: object.h:472
CREMapInformation::messages
QStringList messages() const
Definition: CREMapInformation.cpp:196
CREMapInformation::myShopRace
QString myShopRace
Definition: CREMapInformation.h:127
QuestWrapper.h
CREMapInformation::backgroundMusic
const QString & backgroundMusic()
Definition: CREMapInformation.cpp:74
quest
Definition: quest.py:1
CREMapInformation::setRegion
void setRegion(const QString &region)
Definition: CREMapInformation.cpp:191
CREMapInformation::mapTime
const QDateTime & mapTime() const
Definition: CREMapInformation.cpp:125
FaceWrapper
Definition: FaceWrapper.h:24
CREMapInformation::myArchetypes
QStringList myArchetypes
Definition: CREMapInformation.h:113
disinfect.map
map
Definition: disinfect.py:4
CREMapInformation::setShopMin
void setShopMin(quint64 min)
Definition: CREMapInformation.cpp:253
ScriptFile.h
CREMapInformation::animations
QStringList animations() const
Definition: CREMapInformation.cpp:115
CREMapInformation::addQuest
void addQuest(const QString &quest)
Definition: CREMapInformation.cpp:212
AssetWrapper
Definition: AssetWrapper.h:25
CREMapInformation::setShopRace
void setShopRace(const QString &race)
Definition: CREMapInformation.cpp:243
AnimationWrapper.h
python_init.path
path
Definition: python_init.py:8
CREMapInformation::~CREMapInformation
virtual ~CREMapInformation()
Definition: CREMapInformation.cpp:42
CREMapInformation::shopMin
quint64 shopMin() const
Definition: CREMapInformation.cpp:248
CREMapInformation::accessedFrom
QStringList accessedFrom() const
Definition: CREMapInformation.cpp:146
CREMapInformation::resetGroup
QString resetGroup
Definition: CREMapInformation.h:36
CREMapInformation::addFace
void addFace(const QString &face)
Definition: CREMapInformation.cpp:110
CREMapInformation::CREMapInformation
CREMapInformation()
Definition: CREMapInformation.cpp:21
CREMapInformation::myShopMin
quint64 myShopMin
Definition: CREMapInformation.h:128
ArchetypeWrapper.h
CREMapInformation::experience
qint64 experience
Definition: CREMapInformation.h:35
FaceWrapper.h
say.max
dictionary max
Definition: say.py:148
CREMapInformation::path
QString path
Definition: CREMapInformation.h:31
AssetWrapper::Uses
@ Uses
Definition: AssetWrapper.h:31
animate.anim
string anim
Definition: animate.py:20
CREMapInformation::quests
QStringList quests() const
Definition: CREMapInformation.cpp:207
CREMapInformation::computedDifficulty
int computedDifficulty
Definition: CREMapInformation.h:34
CREMapInformation::myComputedDifficulty
int myComputedDifficulty
Definition: CREMapInformation.h:120
CREMapInformation::myBackgroundMusic
QString myBackgroundMusic
Definition: CREMapInformation.h:130
ScriptFile
Definition: ScriptFile.h:48
CREMapInformation::addExitTo
void addExitTo(const QString &path)
Definition: CREMapInformation.cpp:140
diamondslots.message
string message
Definition: diamondslots.py:57
CREMapInformation::randomMaps
QList< RandomMap * > randomMaps() const
Definition: CREMapInformation.cpp:268
CREMapInformation::setBackgroundMusic
void setBackgroundMusic(const QString &music)
Definition: CREMapInformation.cpp:79
CREMapInformation::addRandomMap
void addRandomMap(RandomMap *map)
Definition: CREMapInformation.cpp:273
CREMapInformation::setMapTime
void setMapTime(const QDateTime &date)
Definition: CREMapInformation.cpp:130
CREMapInformation::setShopMax
void setShopMax(quint64 max)
Definition: CREMapInformation.cpp:263
ArchetypeWrapper
Definition: ArchetypeWrapper.h:25
CREMapInformation::setResetGroup
void setResetGroup(const QString &resetGroup)
Definition: CREMapInformation.cpp:89
CREMapInformation::myExperience
qint64 myExperience
Definition: CREMapInformation.h:121
CREMapInformation::setName
void setName(const QString &name)
Definition: CREMapInformation.cpp:69
CREMapInformation::addArchetype
void addArchetype(const QString &archetype)
Definition: CREMapInformation.cpp:99
CREMapInformation::faces
QStringList faces() const
Definition: CREMapInformation.cpp:105
CREMapInformation::myShopGreed
double myShopGreed
Definition: CREMapInformation.h:126
CREMapInformation::addAccessedFrom
void addAccessedFrom(const QString &path)
Definition: CREMapInformation.cpp:151
AssetWrapper::DoesntUse
@ DoesntUse
Definition: AssetWrapper.h:31
CREMapInformation::setExperience
void setExperience(qint64 experience)
Definition: CREMapInformation.cpp:182
CREMapInformation::myPath
QString myPath
Definition: CREMapInformation.h:111
CREMapInformation::myMapTime
QDateTime myMapTime
Definition: CREMapInformation.h:116
CREMapInformation::myRandomMaps
QList< RandomMap * > myRandomMaps
Definition: CREMapInformation.h:129
CREMapInformation::myRegion
QString myRegion
Definition: CREMapInformation.h:122
give.name
name
Definition: give.py:27
CREMapInformation::shopMax
quint64 shopMax() const
Definition: CREMapInformation.cpp:258
regiondef
Definition: map.h:275