Esempio n. 1
0
    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
Esempio n. 2
0
    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()
Esempio n. 4
0
    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
Esempio n. 5
0
    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))
Esempio n. 6
0
    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
Esempio n. 7
0
 def getRunnerForUser(self, race, user):
     race_runners = Runner.gql("WHERE user = :1 and race = :2", user, race)
Esempio n. 8
0
 def getWinner(self, update):
     for runnerKey in update["payload"]:
         if (update["payload"][runnerKey] > 100) :
             return Runner.get(runnerKey).user.nickname()
Esempio n. 9
0
 def post(self, runnerKey):
     jsonMessage = simplejson.loads(self.request.body);
     runner = Runner.get(runnerKey)
     
     {'gameUpdate': self.handleUpdate,
      'runnerStatusUpdate': self.handleReady}[jsonMessage["messageType"]](runner, jsonMessage)
Esempio n. 10
0
 def getRunnerForUser(self, race, user):
     race_runners = Runner.gql("WHERE user = :1 and race = :2", user, race)