Esempio n. 1
0
    def put(self):
        # Get parameters
        ville = self.request.get('ville')
        x = int(self.request.get('x'))
        y = int(self.request.get('y'))
        type  = self.request.get('type')

        # Get ville
        ville = Ville.get(ville)

        # Modify objects
        objects = json.loads(ville.objects)
        objects.append({'type': type,
                        'x': x,
                        'y': y,
                        'state': 'sleeping'})
        ville.objects = json.dumps(objects)

        # Modify ground
        try:
            tile = self.scheme['types'][type]['ground']
        except KeyError:
            pass
        else:
            ground = json.loads(ville.ground)
            ground[y][x] = tile
            ville.ground = json.dumps(ground)

        # Write ville back on the database
        ville.put()
Esempio n. 2
0
    def put(self):
        ville = self.request.get('ville')
        y = self.request.get('y')
        x = self.request.get('x')
        type  = self.request.get('type')

        ville = Ville.get(ville)
        ground = json.loads(ville.ground)
        ground[y][x] = type
        ville.ground = json.dumps(ground)
        ville.put()
Esempio n. 3
0
    def get(self):
        ville = self.request.get('ville')

        try:
            ville = Ville.get(ville)

        except BadKeyError:
            pass

        else:
            if not ville.ground:
                ville.ground = json.dumps(self.default)
                ville.put()
            ground = json.loads(ville.ground)
            self.response.out.write(json.dumps({'ground': ground,
                                                'scheme': self.scheme}))
Esempio n. 4
0
    def get(self):
        ville = self.request.get('ville')

        try:
            ville = Ville.get(ville)

        except BadKeyError:
            pass

        else:
            if not ville.objects:
                ville.objects = json.dumps(self.default)
                ville.put()
            objects = json.loads(ville.objects)
            self.response.out.write(json.dumps({'objects': objects,
                                                'scheme':  self.scheme}))