Hi gang, happy new year!
I’ll try to be as short as possible, i am currently trying to build an idle MMORPG flat menu based game (similar to Melvor Idle), this is pretty simple and easy when we do the backend on the client side, but what is the best way to do it when having the backend (for validation and database changes) on a web API, for example with Cloud Run and dockers.
Imagine the scenario where a task, lets say Smithing, every 3s uses “Coal” and “Iron” to make a “Steel Bar”, would i have the web API run every 3s to remove and add the necessary items from the database? Or is there a better way to do this an still prevent cheating?
The values from the database would be synced to the Client side via listeners so there isnt an issue there, im just confused about the web API side if there is a more efficient way to do this (or maybe i am just overthinking and this is already the right way to achieve cheating-proof gameplay).
Appreciate your inputs!
I tend to avoid making games that require a server/database. Mainly because I’m worried about getting a large bill and I don’t really want to have to keep maintaining it for years. If I made a game like this I’d also have to worry about long term costs so the game would probably need to focus on IAP which I don’t like.
If it’s just a single player game I wouldn’t even worry about cheaters and would just make it local. If I did want a lot of players in the same game (>1000) and the gameplay was really slow (building takes hours to build) and the game state was large (maybe 10,000x10,000 tiles) then I’d be tempted to just make something like a blog system / pubsub and have deterministic gameplay.
So I might have a request commands endpoint that’s public for the clients to call e.g.
userSessionId: a, tick:8, RequestBuildSteelBars(50)
userSessionId: b, tick:12, RequestCaptureCell(2, 3)
userSessionId: c, tick:20, RequestCaptureCell(2, 3)
Then I might have a server that processes these requests (get all messages after the last process) and generates a read only public output e.g.
userId:1, BuildSteelBars(50), startTick:8
userId:2, CapturedCell(2, 3), startTick:12
userId:3, CapturedCellFailed(2, 3), startTick:12
Then the client just reads the pubsub and processes the data (maybe once a minute). This does require it to be deterministic though. So the client might see a BuildSteelBars() command. X time has passed so create the required amount of bars and consume the consumables. Then locally every 3 seconds it builds another bar. So kind of a lockstep system with a large delay (similar to an RTS game). Then after some time maybe create a large world state (maybe once a day).
1 Like
Thanks for the reply!
Indeed a singleplayer game would be sooo much easier, but for this niche market and the vision i have, the multiplayer side of it is a must. The costs are indeed a factor specially when i have no idea how fast i will burn thro the free tier of Cloud Run, even tho this is a niche market and i dont see more than 1000 players simultaneous, and hopefully if i do reach that far the microtransactions would cover for the costs of running the game, but i do want to keep the game super accessible to everyone and not have paywalls on actual content, hence why im trying to see whats the best (most efficient) way that professionals tackle this type of game.
Your pub/sub idea is very interesting and it is something i will have to give it some thought about, appreciate the suggestion mate! ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/google/slight_smile.png?v=12)