def joinRace(self, user, race): runners = race.runner_set race_runners = Runner.gql("WHERE user = :1 and race = :2", user, race) if race_runners.count() == 0: my_runner = Runner(user=user, race=race, position=0, ready=False) my_runner.put() else: my_runner = race_runners[0] logging.error(my_runner.to_xml()) return my_runner
def areAllRunnersReady(self, race): total_runners = race.runner_set.count() ready_runners = Runner.gql("WHERE race = :1 and ready = true", race).count() logging.error(total_runners) logging.error(ready_runners) return total_runners == ready_runners
def post(self): runner_key = self.request.get('from') runner = Runner.get(runner_key) race = runner.race self.raceService.sendDisconnectedToRunners(runner, race) runner.delete()
def get(self, raceKey, runnerKey): """ Returns the portion of html needed to represent a runner """ runner = Runner.get(runnerKey) ret = { "runner": { "runner_key": str(runner.key()), "runner_name": runner.user.nickname(), "runner_position": runner.position, "runner_visible": False, "runner_ready": runner.ready, } } path = os.path.join(os.path.dirname(__file__), "../../templates/show-race-player.html") self.response.out.write(template.render(path, ret))
def joinRace(self, user, race): runners = race.runner_set race_runners = Runner.gql("WHERE user = :1 and race = :2", user, race) if (race_runners.count() == 0): my_runner = Runner(user=user, race=race, position=0, ready=False) my_runner.put() else: my_runner = race_runners[0] logging.error(my_runner.to_xml()) return my_runner
def getRunnerForUser(self, race, user): race_runners = Runner.gql("WHERE user = :1 and race = :2", user, race)
def getWinner(self, update): for runnerKey in update["payload"]: if (update["payload"][runnerKey] > 100) : return Runner.get(runnerKey).user.nickname()
def post(self, runnerKey): jsonMessage = simplejson.loads(self.request.body); runner = Runner.get(runnerKey) {'gameUpdate': self.handleUpdate, 'runnerStatusUpdate': self.handleReady}[jsonMessage["messageType"]](runner, jsonMessage)