0
\$\begingroup\$

I'm currently working on a minor multiplayer project which is made like a hacking simulator where your character can login to a "console"-like interface to permanently manipulate the system with various commands. But now i want to convert this to a more persistent model like if two characters enter the same systems minutes apart, the second character should be able to see if the first character left traces of him being there and continue his damage or counter it.

Could all this be handled by a Rest API or what would be the more "right" way of doing it. ?

This will also work as the authentication for the player, which will initialize all multiplayer behaviour in the game.

\$\endgroup\$
  • \$\begingroup\$ How have you tried implementing this with a REST API so far? Where did you run into specific trouble that we can help you solve? \$\endgroup\$ – DMGregory Dec 4 '19 at 17:10
  • \$\begingroup\$ I have not or i have, but with a mocked api, i was just worried if a web based backend was going down the wrong path for this solution and there might be other and even better solutions for my needs that i wasn't aware of just yet. But if it's somewhat acceptable i will definitely continue with the rest api as it pretty much hassle free. \$\endgroup\$ – Poul A. M. Poulsen Dec 5 '19 at 7:13
  • \$\begingroup\$ GameDev.StackExchange is not a good place to ask for permission to pursue a solution. We don't have crystal balls to predict whether it will lead you to problems or not. Your own intimate knowledge of your project means you're better positioned to evaluate your long-term needs and whether your chosen tech stack will fulfill them than we are. \$\endgroup\$ – DMGregory Dec 5 '19 at 12:36
  • \$\begingroup\$ Guess i took the bait. I'm sure whatever i do it will lead me to problems, but those i will solve. I guess what i'm asking is what would be best practice and/or would it be wrong of me to assume rest api's are used as inventory management in game mechanics. I have no doubt it if choose the wrong path, posted some code, someone would tell me i shouldn't be doing it like that and come up with a better example or a better path to follow/look into. :) \$\endgroup\$ – Poul A. M. Poulsen Dec 5 '19 at 14:10
0
\$\begingroup\$

The short answer to your question is yes, a REST API is one way to store persistent data on a server than can be accessed by multiple players. But keep in mind that "REST API" is a category, not a ready-made solution you just install and use. A REST API is typically going to require three major components:

  • A host or server (this by itself is a broad category that encompasses countless possible solutions)
  • A database to store the data, such as MySQL or MongoDB
  • Code that defines your API, in a language such as JavaScript or PHP. Your API code will handle and respond to web requests from clients, and interact with the database to read and write data.

Learning how to create a REST API can be overwhelming if you have no prior web development experience. How to build a REST API would be far too broad and subjective to cover in any one question. You may find it easier to use a BaaS platform that simplifies some of the setup for you, but these can come with their own bugs and limitations.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks for clarifying, luckily i'm well aware of how to structure and build a rest api, i was just afraid it might lead me down the wrong path and i would end up shooting myself in the foot. \$\endgroup\$ – Poul A. M. Poulsen Dec 5 '19 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.