Exemplo n.º 1
0
 def get(self, game_id):
     game = Game.get_by_id(game_id)
     hist = Cache.getHist(game_id)
     if not hist:
         self.response.status = 404
         self.response.write(self.response.status)
         return
     self.response.headers['Content-Type'] = 'text/plain'
     self.response.status = 200
     self.response.out.write("|".join([
         "%s:%s" % (p, ",".join([str(h.coords) for h in hls]))
         for p, hls in hist.iteritems()
     ]))
Exemplo n.º 2
0
 def get(self, game_id):
     hist = Cache.getHist(game_id)
     if not hist or not paramVal(self, "modes"):
         self.response.status = 404
         self.response.write(self.response.status)
         return
     modes = paramVal(self, "modes").split(" ")
     self.response.headers['Content-Type'] = 'text/plain'
     self.response.status = 200
     self.response.out.write("|".join([
         "%s:%s" % (p, ",".join(
             Map.get_reachable_areas(
                 PlayerState([(h.pickup_code, h.pickup_id, h.removed)
                              for h in hls]), modes)))
         for p, hls in hist.iteritems()
     ]))
Exemplo n.º 3
0
    def get(self, game_id, player_id):
        seedlines = []
        lines = paramVal(self, "seed").split(",")
        game = Game.get_by_id(game_id)
        hist = Cache.getHist(game_id)
        if not hist:
            Cache.setHist(game_id, player_id, [])
        pos = Cache.getPos(game_id)
        if not pos:
            Cache.setPos(game_id, player_id, 0, 0)
        if not game:
            flags = lines[0].split("|")
            mode_opt = [f[5:] for f in flags if f.lower().startswith("mode=")]
            shared_opt = [
                f[7:].split(" ") for f in flags
                if f.lower().startswith("shared=")
            ]
            mode = mode_opt[0].lower() if mode_opt else None
            if mode:
                mode = mode_map[mode] if mode in mode_map else int(mode)

            shared = shared_opt[0] if shared_opt else None
            game = get_new_game(_mode=mode, _shared=shared, id=game_id)
        for l in lines[1:]:
            line = l.split("|")
            if len(line) < 3:
                print "ERROR: malformed seed line %s, skipping" % l
            else:
                seedlines.append("%s:%s" %
                                 (line[0], Pickup.name(line[1], line[2])))
        player = game.player(player_id)
        player.seed = "\n".join(seedlines)
        player.put()
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.status = 200
        self.response.out.write("ok")