43 if(results.size() == 0)
46 return results.at(
Random::inst()->rangeExclusive(0, results.size()));
56 results.append(entry);
64 for(
auto entry : QVector<MapDBEntry*>(results))
65 if(entry->name == val ||
66 entry->modernName == val)
67 results.removeOne(entry);
74 for(
auto entry : QVector<MapDBEntry*>(results))
75 if(!(entry->ind < val))
76 results.removeOne(entry);
83 for(
auto entry : QVector<MapDBEntry*>(results))
84 if(!(entry->ind > val))
85 results.removeOne(entry);
92 for(
auto entry : QVector<MapDBEntry*>(results))
93 if(entry->width < 0 || !(entry->width > val))
94 results.removeOne(entry);
101 for(
auto entry : QVector<MapDBEntry*>(results))
102 if(entry->height < 0 || !(entry->height < val))
103 results.removeOne(entry);
110 for(
auto entry : QVector<MapDBEntry*>(results))
111 if(entry->width < 0 || !(entry->width > val))
112 results.removeOne(entry);
119 for(
auto entry : QVector<MapDBEntry*>(results))
120 if(entry->width < 0 || !(entry->width < val))
121 results.removeOne(entry);
128 for(
auto entry : QVector<MapDBEntry*>(results))
129 if(entry->width < 0 || entry->height < 0 ||
130 !((entry->width * entry->height) > val))
131 results.removeOne(entry);
138 for(
auto entry : QVector<MapDBEntry*>(results))
139 if(entry->width < 0 || entry->height < 0 ||
140 !((entry->width * entry->height) < val))
141 results.removeOne(entry);
148 for(
auto entry : QVector<MapDBEntry*>(results))
149 if(entry->toTileset ==
nullptr ||
150 (!(entry->toTileset->name == val) ||
151 !(entry->toTileset->nameAlias == val)))
152 results.removeOne(entry);
159 for(
auto entry : QVector<MapDBEntry*>(results))
160 if(entry->toTileset ==
nullptr ||
161 (!(entry->toTileset->name != val) &&
162 !(entry->toTileset->nameAlias != val)))
163 results.removeOne(entry);
170 for(
auto entry : QVector<MapDBEntry*>(results)) {
174 if(entry->toTileset ==
nullptr) {
175 results.removeOne(entry);
179 if(entry->toTileset->type != val && entry->toTileset->typeAlias != val)
180 results.removeOne(entry);
188 for(
auto entry : QVector<MapDBEntry*>(results)) {
189 if(entry->toTileset ==
nullptr)
192 if(entry->toTileset->type == val || entry->toTileset->typeAlias == val)
193 results.removeOne(entry);
201 for(
auto entry : QVector<MapDBEntry*>(results))
202 if(entry->connect.isEmpty())
203 results.removeOne(entry);
210 for(
auto entry : QVector<MapDBEntry*>(results))
211 if(!entry->connect.isEmpty())
212 results.removeOne(entry);
219 for(
auto entry : QVector<MapDBEntry*>(results))
220 if(entry->warpOut.isEmpty())
221 results.removeOne(entry);
228 for(
auto entry : QVector<MapDBEntry*>(results))
229 if(!entry->warpOut.isEmpty())
230 results.removeOne(entry);
237 for(
auto entry : QVector<MapDBEntry*>(results))
238 if(entry->warpIn.isEmpty())
239 results.removeOne(entry);
246 for(
auto entry : QVector<MapDBEntry*>(results))
247 if(!entry->warpIn.isEmpty())
248 results.removeOne(entry);
255 for(
auto entry : QVector<MapDBEntry*>(results))
256 if(entry->signs.isEmpty())
257 results.removeOne(entry);
264 for(
auto entry : QVector<MapDBEntry*>(results))
265 if(!entry->signs.isEmpty())
266 results.removeOne(entry);
273 for(
auto entry : QVector<MapDBEntry*>(results))
274 if(entry->sprites.isEmpty())
275 results.removeOne(entry);
282 for(
auto entry : QVector<MapDBEntry*>(results))
283 if(!entry->sprites.isEmpty())
284 results.removeOne(entry);
294 for(
auto entry : QVector<MapDBEntry*>(results))
295 if(entry->spriteSet < 0)
296 results.removeOne(entry);
303 for(
auto entry : QVector<MapDBEntry*>(results))
304 if(entry->spriteSet >= 0)
305 results.removeOne(entry);
315 for(
auto entry : QVector<MapDBEntry*>(results))
316 if(entry->spriteSet < 0 || entry->toSpriteSet ==
nullptr ||
317 !entry->toSpriteSet->isDynamic())
318 results.removeOne(entry);
328 for(
auto entry : QVector<MapDBEntry*>(results))
329 if(entry->spriteSet < 0 || entry->toSpriteSet ==
nullptr ||
330 entry->toSpriteSet->isDynamic())
331 results.removeOne(entry);
338 for(
auto entry : QVector<MapDBEntry*>(results))
339 if(entry->monRate < 0 || entry->monRate == 0)
340 results.removeOne(entry);
347 for(
auto entry : QVector<MapDBEntry*>(results))
348 if(entry->monRate < 0 || entry->monRate > 0)
349 results.removeOne(entry);
356 for(
auto entry : QVector<MapDBEntry*>(results))
357 if(entry->incomplete ==
"")
358 results.removeOne(entry);
365 for(
auto entry : QVector<MapDBEntry*>(results))
366 if(entry->incomplete !=
"")
367 results.removeOne(entry);
374 for(
auto entry : QVector<MapDBEntry*>(results))
376 results.removeOne(entry);
383 for(
auto entry : QVector<MapDBEntry*>(results)) {
385 results.removeOne(entry);
393 for(
auto entry : QVector<MapDBEntry*>(results))
395 results.removeOne(entry);
402 for(
auto entry : QVector<MapDBEntry*>(results))
404 results.removeOne(entry);
432 return results.size();
437 if(ind >= results.size())
440 return results.at(ind);
448void MapSearch::qmlRegister()
const
450 static bool registered =
false;
454 qmlRegisterUncreatableType<MapSearch>(
"PSE.DB.MapSearch", 1, 0,
"MapSearch",
"Can't instantiate in QML");
MapSearch * indexGt(int val)
Keep maps with index > val.
MapSearch * startOver()
Reset to all maps. Returns this.
MapSearch * isGood()
Keep only "good" maps (criteria listed above).
MapSearch * hasConnections()
MapDBEntry * pickRandom()
A random map from the current results (backs pickRandom).
MapSearch * widthGt(int val)
Keep maps wider than val.
MapSearch * areaLt(int val)
Keep maps with area < val.
MapSearch * hasSpriteSet()
MapSearch * hasTileset(QString val)
Keep maps using tileset val.
MapSearch * heightLt(int val)
Keep maps shorter than val.
MapSearch * noSpriteSet()
MapSearch * heightGt(int val)
Keep maps taller than val.
const QVector< MapDBEntry * > getMaps() const
The current result set.
MapSearch * widthLt(int val)
Keep maps narrower than val.
MapSearch()
Start with all maps in the result set.
MapSearch * notType(QString val)
Drop maps of tileset-type val.
int getMapCount() const
Result count (backs mapCount).
MapSearch * hasDynamicSpriteSet()
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
MapSearch * hasWarpsOut()
MapSearch * isIncomplete()
MapSearch * areaGt(int val)
Keep maps with area > val.
MapSearch * isType(QString val)
Keep maps of tileset-type val.
MapSearch * noDynamicSpriteSet()
MapSearch * notTileset(QString val)
Drop maps using tileset val.
MapSearch * notIncomplete()
MapSearch * notNamed(QString val)
Drop the map named val.
MapSearch * noConnections()
MapSearch * indexLt(int val)
Keep maps with index < val.
const MapDBEntry * mapAt(const int ind) const
Result ind (for QML).
static MapsDB * inst()
< Number of maps.
static Random * inst()
< Convenience 50% coin flip (integer path), readable from QML.
static void qmlProtectUtil(const QObject *const obj, const QQmlEngine *const engine)
Pin obj to C++ ownership so the QML engine never garbage-collects it.
One map's complete static definition – the root of the MapDBEntry family.