UPS-CS240-F12 / main_trunk

A repository that can act as our central hub, for others to fork off of etc.
4 stars 0 forks source link

You can now restart the gameState with a POST request to 1730 #6

Open sdunham opened 11 years ago

sdunham commented 11 years ago

I'll update the API documentation soon, but you can reset the gameState by POSTing in the following manner:

http://puppetmaster.pugetsound.edu:1730/gameState.json?restartGame=true

If you're not the Game Engine, you probably shouldn't be doing this...

d-bahr commented 11 years ago

When I try to post the request, I get a '400 Bad Request' error. I'm 95% sure that my code should work :D

iameli commented 11 years ago

Try now.

d-bahr commented 11 years ago

Still happening. I'm able to post phone scores though, which have roughly the same format, so I'm not sure why that works and this doesn't...

sdunham commented 11 years ago

Sorry about that... Seemed to be working when I tested it in the browser, but it looks like it needs some tweaking. I'll fiddle with it tonight and get back to you.

On Tue, Dec 4, 2012 at 6:17 PM, Daniel Bahr notifications@github.comwrote:

Still happening. I'm able to post phone scores though, which have roughly the same format, so I'm not sure why that works and this doesn't...

— Reply to this email directly or view it on GitHubhttps://github.com/UPS-CS240-F12/main_trunk/issues/6#issuecomment-11025482.

sdunham commented 11 years ago

I just successfully retested by sending an ajax call to http://puppetmaster.pugetsound.edu:1730/gameState.json?restartGame=true

Is "Bad Request" the exact error text you're getting back? There are a couple places in the code where we catch errors and respond with a 400 code, and knowing the exact message will help me figure out which one your request is getting caught in.

It's a long shot, but are you sending more than just the restartGame variable with your POST request? If you were sending some phone score data as well, I can see where the issue might be.

On Tue, Dec 4, 2012 at 6:36 PM, Scott Dunham dunham.scott@gmail.com wrote:

Sorry about that... Seemed to be working when I tested it in the browser, but it looks like it needs some tweaking. I'll fiddle with it tonight and get back to you.

On Tue, Dec 4, 2012 at 6:17 PM, Daniel Bahr notifications@github.comwrote:

Still happening. I'm able to post phone scores though, which have roughly the same format, so I'm not sure why that works and this doesn't...

— Reply to this email directly or view it on GitHubhttps://github.com/UPS-CS240-F12/main_trunk/issues/6#issuecomment-11025482.

iameli commented 11 years ago

It should be parsing the request and responding with a 204 "No Content" reply--the 2XX code affirms success but there's no data with which we can logically reply.

Maybe it's working but your code is seeing no content and responding with an error?

On Tue, Dec 4, 2012 at 8:45 PM, sdunham notifications@github.com wrote:

I just successfully retested by sending an ajax call to http://puppetmaster.pugetsound.edu:1730/gameState.json?restartGame=true

Is "Bad Request" the exact error text you're getting back? There are a couple places in the code where we catch errors and respond with a 400 code, and knowing the exact message will help me figure out which one your request is getting caught in.

It's a long shot, but are you sending more than just the restartGame variable with your POST request? If you were sending some phone score data as well, I can see where the issue might be.

On Tue, Dec 4, 2012 at 6:36 PM, Scott Dunham dunham.scott@gmail.com wrote:

Sorry about that... Seemed to be working when I tested it in the browser, but it looks like it needs some tweaking. I'll fiddle with it tonight and get back to you.

On Tue, Dec 4, 2012 at 6:17 PM, Daniel Bahr notifications@github.comwrote:

Still happening. I'm able to post phone scores though, which have roughly the same format, so I'm not sure why that works and this doesn't...

— Reply to this email directly or view it on GitHub< https://github.com/UPS-CS240-F12/main_trunk/issues/6#issuecomment-11025482>.

— Reply to this email directly or view it on GitHubhttps://github.com/UPS-CS240-F12/main_trunk/issues/6#issuecomment-11029495.

d-bahr commented 11 years ago

I just double-checked my code and I'm not sure there's anything wrong. I will try a couple things tomorrow when I'm on campus again.

sdunham commented 11 years ago

In anticipation of getting this issue figured out, I want to make one small tweak to this part of the API which I think should clear up a few unresolved issues.

There are now essentially 2 versions of this call that you can make, and I'm wondering if you can make them in 2 different places in your code:

  1. Reset the JSON, but don't log scores for the leaderboard This will be the same POST request that you're attempting to make now ( http://puppetmaster.pugetsound.edu:1730/gameState.json?restartGame=true). It will reinitialize the JSON, and should be called right before you start a new game (before you set gameRunning to true).
  2. Reset the JSON and log scores for the leaderboard For this call, you will add a new parameter to your POST request ( http://puppetmaster.pugetsound.edu:1730/gameState.json?restartGame=true&logScores=true). This call will reinitialize the JSON and log high scores in our leaderboard. You should call this when a game has finished, and after you have updated player/phone scores to their final score.

Let us know if you have any issues with any of this.

On Tue, Dec 4, 2012 at 10:47 PM, Daniel Bahr notifications@github.comwrote:

I just double-checked my code and I'm not sure there's anything wrong. I will try a couple things tomorrow when I'm on campus again.

— Reply to this email directly or view it on GitHubhttps://github.com/UPS-CS240-F12/main_trunk/issues/6#issuecomment-11031399.

d-bahr commented 11 years ago

I'm still unable to get either of them working. And now that I'm thinking about it, I'm not even sure that updating phone scores is working, because we haven't been able to test with the phone group.

I've spent several hours on this and I still have no idea why it's not working =\

sdunham commented 11 years ago

Well, that's frustrating... Sorry for all the issues. Could you point me to where in your code you're making the restartGame calls? You could try POSTing phone scores to the simulator, if you want to test out that functionality before your next meeting with the phone group. I'd be very curious to hear if that fails as well.

This is probably self-explanatory, but just to make sure we've covered all possible sources of this issue:

These calls are different from the standard GET/POST JSON calls, in that they expect URL parameters which we parse on the server side (and don't include any JSON data). The fact that you can successfully POST gameState JSON, but are unable to POST using URL parameters makes me wonder if the required parameters aren't being tacked on to the request URL somehow...

d-bahr commented 11 years ago

Got it working. I pushed the changes in the most recent commit to the Game Engine's repo.