MCPcopy Create free account
hub / github.com/RocketMap/RocketMap / get_spawnpoints

Method get_spawnpoints

pogom/models.py:251–284  ·  view source on GitHub ↗
(cls, southBoundary, westBoundary, northBoundary, eastBoundary)

Source from the content-addressed store, hash-verified

249
250 @classmethod
251 def get_spawnpoints(cls, southBoundary, westBoundary, northBoundary, eastBoundary):
252 query = Pokemon.select(Pokemon.latitude, Pokemon.longitude, Pokemon.spawnpoint_id, ((Pokemon.disappear_time.minute * 60) + Pokemon.disappear_time.second).alias('time'), fn.Count(Pokemon.spawnpoint_id).alias('count'))
253
254 if None not in (northBoundary, southBoundary, westBoundary, eastBoundary):
255 query = (query
256 .where((Pokemon.latitude <= northBoundary) &
257 (Pokemon.latitude >= southBoundary) &
258 (Pokemon.longitude >= westBoundary) &
259 (Pokemon.longitude <= eastBoundary)
260 ))
261
262 query = query.group_by(Pokemon.latitude, Pokemon.longitude, Pokemon.spawnpoint_id, SQL('time'))
263
264 queryDict = query.dicts()
265 spawnpoints = {}
266
267 for sp in queryDict:
268 key = sp['spawnpoint_id']
269 disappear_time = cls.get_spawn_time(sp.pop('time'))
270 count = int(sp['count'])
271
272 if key not in spawnpoints:
273 spawnpoints[key] = sp
274 else:
275 spawnpoints[key]['special'] = True
276
277 if 'time' not in spawnpoints[key] or count >= spawnpoints[key]['count']:
278 spawnpoints[key]['time'] = disappear_time
279 spawnpoints[key]['count'] = count
280
281 for sp in spawnpoints.values():
282 del sp['count']
283
284 return list(spawnpoints.values())
285
286 @classmethod
287 def get_spawnpoints_in_hex(cls, center, steps):

Callers 2

_generate_locationsMethod · 0.80
raw_dataMethod · 0.80

Calls 1

get_spawn_timeMethod · 0.80

Tested by

no test coverage detected