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