def gen_photosets(self, contract): targetLocs = LocationRecord.objects.filter(game=contract.game, user=contract.target).order_by("-timestamp") if not targetLocs.exists(): return None for player in contract.game.players.all().order_by("?"): if player == contract.assassin or player == contract.target: continue takerLocs = LocationRecord.objects.filter(game=contract.game, user=player).order_by("-timestamp") if not takerLocs.exists(): continue if gisfuncs.multi_distance([takerLocs[0], targetLocs[0]]) > 50: continue ps = self.filter(contract=contract, user=player) if ps.exists(): return [(player.get_profile().gcm_regid, {'type': 'take_photo', 'photoset': ps[0].id})] else: ps = self.create(game=contract.game, contract=contract, user=player) return [(player.get_profile().gcm_regid, {'type': 'take_photo', 'photoset': ps.id})]
def gen_user_location(self, contract): userLocs = list(self.filter(user=contract.target).order_by("-timestamp")[:5]) if not userLocs: return None mostRecentLoc = userLocs[0] isMoving = False gcmid = contract.assassin.get_profile().gcm_regid if gisfuncs.multi_distance(userLocs) >= 250: isMoving = True oldestLoc = userLocs[-1] nameFrom = fsqfuncs.get_nearest_location(oldestLoc.location) nameTo = fsqfuncs.get_nearest_location(mostRecentLoc.location) if nameFrom and nameTo: return [(gcmid, {'type': 'location_moving', 'target': contract.target.username, 'locationFrom': nameFrom, 'locationTo': nameTo})] return None else: name = fsqfuncs.get_nearest_location(mostRecentLoc.location) if name: return [(gcmid, {'type': 'location_stationary', 'target': contract.target.username, 'location': name})] return None