Commits

sweemeng  committed 590ab77

added battle system display backend

  • Participants
  • Parent commits c6152e0

Comments (0)

Files changed (1)

File goproj/positions/positions.go

 type Player struct{
     Name string
     Profession string
-    Score int32
+    Score int
+}
+
+type Result struct{
+    player string
+    hitpoint int
 }
 
 func init(){
     fmt.Fprint(w,string(b))
 }
 
-func action(w http.ResponseWriter.r *http.Request){
-    
-   fmt.Fprint(w,"Velociraptor")
+func action(w http.ResponseWriter,r *http.Request){
+   c := appengine.NewContext(r)
+   u := user.Current(c)
+   hp := rand.Intn(10)
+   player1 := Result{u.String(),hp}
+   p2 := r.FormValue("opponent") 
+   hp2 := rand.Intn(10)
+   player2 := Result{p2,hp2}
+   result_set := [2]Result{player1,player2}
+
+   b,err := json.Marshal(result_set)
+   if err != nil{
+        http.Error(w,err.String(),http.StatusInternalServerError)
+        return
+    }
+    fmt.Fprint(w,string(b))
 }