EmilZach / Sentence-Crusher

A Python game for crushing sentences.
0 stars 1 forks source link

Send data from server to client. HOW!? !? #22

Open Arxcis opened 8 years ago

Arxcis commented 8 years ago

Siden vi har tenkt til å bare ha data liggende på serveren, så lurer jeg på hvordan vi skal klare å sende data fra serveren til klienten. Går det ann å returnere en dictinary i en post -request foreksempel? Jeg fant ikke noe om dette.

raglew commented 8 years ago

The server is already programmed to return a message to the game client. Study the collect_data function in flaskserver.py. When the data is collected, a list is sent back to the game client in return. What I would like to suggest is that we send a rank back to the player instead... something like... 'Your score for game level has reached number out of . So <if number 1> Congratulations! <elif in top 10> Well done you are in the Top 10. Keep it up.' We might need to add a to each score when we sort the scores. And to simplify, I think we should store all scores (not just high scores). I can't see any reason why one player can't monopolise all the top spots :) We could set a limit though, perhaps 100 scores to save on storage space. Let me know what you think.

raglew commented 8 years ago

I can see that all the bits placed between 'greater than' & 'less than' signs didn't get posted :( I'll try and do it again.

raglew commented 8 years ago

Again... Let's see if this works with parantheses.

The server is already programmed to return a message to the game client. Study the collect_data function in flaskserver.py. When the data is collected, a list is sent back to the game client in return. What I would like to suggest is that we send a rank back to the player instead... something like... 'Your score for game (game) level (level) has reached number (rank) out of (number of ranks). So (if number 1) Congratulations! (elif in top 10) Well done you are in the Top 10. (else) Keep it up.' We might need to add a (rank) to each score when we sort the scores. And to simplify, I think we should store all scores (not just high scores). I can't see any reason why one player can't monopolise all the top spots :) We could set a limit though, perhaps 100 scores to save on storage space. Let me know what you think.

technocake commented 8 years ago

You can send structured data like dictionaries, lists or objects by using json

On 4/3/16, raglew notifications@github.com wrote:

Again... Let's see if this works with parantheses.

The server is already programmed to return a message to the game client. Study the collect_data function in flaskserver.py. When the data is collected, a list is sent back to the game client in return. What I would like to suggest is that we send a rank back to the player instead... something like... 'Your score for game (game) level (level) has reached number (rank) out of (number of ranks). So (if number 1) Congratulations! (elif in top 10) Well done you are in the Top 10. (else) Keep it up.' We might need to add a (rank) to each score when we sort the scores. And to simplify, I think we should store all scores (not just high scores). I can't see any reason why one player can't monopolise all the top spots :) We could set a limit though, perhaps 100 scores to save on storage space. Let me know what you think.


You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/EmilZach/Sentence-Crusher/issues/22#issuecomment-205035872

Arxcis commented 8 years ago

Server-side:

Kan eg bruke flask.jsonify ? http://flask.pocoo.org/docs/0.10/api/#flask.json.jsonify

Arxcis commented 8 years ago

Client-side ?

http://docs.python-requests.org/en/master/user/quickstart/#json-response-content

r = requests.get('127.0.0.1:5000/get-highscore', auth=('level'))

r.status_code = 200

r.json() = {u'jonas': 200, 'raglew': 199, ' Emil': 198}

Arxcis commented 8 years ago

Synes det er vanskelig, fordi en må bruke 2 forskjellige bibliotek, Flask og Requests, til å snakke sammen, over HTTP som er enda et slags bibliotek.. + JSON som er en enda en filtype. Mange ting på en gang :+1:

PS: Får eg bamsemums ?