Commits

sweemeng  committed e9ae898

removed swap

  • Participants
  • Parent commits 27c2163

Comments (0)

Files changed (1)

File mapgame/action.py

 from google.appengine.ext import webapp
 from google.appengine.api import user
 from google.appengine.ext.webapp.util import run_wsgi_app
-from google.appengine.ext.db import GeoPt
 from django.utils import simplejson as json
 from models import Player
 from models import Location
+from random import *
 
 
-class Position(webapp.RequestHandler):
+class Action(webapp.RequestHandler):
     def post(self):
-        user = user.get_current_user()
-        player = Player.get('player =','user')
-        x_point = self.request.get('x_point')
-        y_point = self.request.get('y_point')
-        l = Location()
-        l.x_pt = float(x_point)
-        l.y_pt = float(y_point)
-        l.put()
-        output = []
-        output.append(
-            approximate_post(l.x_pt,l.x_pt-5.0,'x_pt <','x_pt >')
-        )
-        output.append(
-            approximate_post(l.x_pt+5,l.x_pt,'x_pt >','x_pt <')
-        )
-        output.append(
-            approximate_post(l.y_pt,l.y_pt-5.0,'y_pt <','y_pt >')
-        )
-        output.append(
-            approximate_post(l.y_pt+5,l.y_pt,'y_pt >','y_pt <')
-        )
-        self.response.out.write(json.loads(output))     
+        u = user.get_current_user()
+        player1 = {'player':u.email,'hp':random.randint()}   
+        player2 = {'player':self.request.get('opponent'),
+                   'hp':random.randint()}
+        result = [player1,player2]
+        self.response.out.write(json.loads(result))     
+     
         
-def approximate_post(x_pt1,x_pt2,query1,query2)
-    output = []
-    nl = db.Query(Location)
-    nl.filter(query1,x_pt1)
-    nl.filter(query2,x_pt2)
-    for i in nl.fetch(limit=5):
-        temp = {}
-        temp['location'] = i.player.player.email
-        temp['position'] = [i.x_pt,i.y_pt]
-        output.append(temp)
-    return output
+