Ask coding questions

← Back to all posts
Help Please
h
Arealight (7)

So I'm making a game across multiple repls and want to be able to see when someone has finished the game in one and send that info back to the start page. Does anyone know how to do this? Any help is very much appreciated.

Comments
hotnewtop
BrysonVan1 (11)

It is an interesting question. @PYer's idea is a good one, but the only issue with submitting scores with a POST request is that it's pretty simple to send one in the browser and essentially end up breaking the game. You could use WebSockets which might be a little more secure or institute some sort of authentication system on your POST requests so that the game isn't broken into. GETting scores with GET would work since you aren't actually submitting data. Just my advice let me know if you have questions. Python does have libraries for WebSockets

PYer (4009)

Personally @BrysonVan1, I find websockets harder to understand and use, but definitely another thing you can look into, especially if you want to avoid the get/post requests. There are ways you can try secure the information you are sending with GET/POST requests. But yes, that could be a problem. Depends on the security you want in the repl, and how important the information that is being sent is. Good suggestion.

Arealight (7)

@BrysonVan1 Sorry if this is a stupid question and all (Very new to all of this) but what language would I use and do you have an example of this I could look at?

PYer (4009)

Looking at your repl, @Arealight, I understand more of what you are trying to accomplish. Creating a different repl for each difficulty/player might not be the best solution. It would also save you a lot of the hassle of trying to communicate between the repls. If you made them all part of the same repl, you could have them linked to the same javascript code. Then, you could keep all the information in one place. I can't tell if you have any specific reason for making them different repls though, I might be missing something. However, that's what I would recommend.

BrysonVan1 (11)

@Arealight I'm a firm believer that there are no stupid questions. You could use Python if you know that otherwise Node.JS would be a good option since it looks like you already know Javascript! I don't really have any example Repls but if you look online I'm sure you could find something

Arealight (7)

@PYer I originally put them in seperate ones cause I had no idea what I was doing XD. But now that I know how I have put them all in the same repl and am trying to setup the rest. Thanks for all the advice @BrysonVan1 and @PYer! (Btw sorry in advance for pinging you)

PYer (4009)

@Arealight Okay, feel free to ask if you need any help with that.

PYer (4009)

Intereting question, though it is hard to answer and vague. My first thought would be to create some system with post or get requests. If you create a server (unless you have a preffered way, I would recommend flask with python ;)), which holds the information about who has completed the game. Then, when you need it, send a request to the server to find out if the person has completed it. Or if you need to be notified when the player has finished, try setting an interval to repeatedly send a request to the server to find out if the player has finished the game. You'd add the information to the server with another get request, that saves the information somewhere. If it's very important and long-term, in a database, otherwise, you could save it in a variable that would get deleted when the server goes down. This is a broad topic, and I recommend looking at some flask examples of servers/tutorials on how to do this if you don't have experience yet. I can't really help you and teach you everything about it, as it would take lots of time, and I don't know the specifics of what you are trying to do.

Arealight (7)

@PYer Thanks for the advice I'll look into that