I want to make a tiny idle RPG

I want to make a tiny idle RPG
0

#1

I’ve been theorizing for a while. I want the diablo like random loot stuff without spending 10 hours a day grinding. So i’m thinking of a game where you log in, open some chests, fight a few bosses and leave. Basically to satisfy my thirst for loot without spending ALL my time. Others could also like the game, so i wanted to give it some backend too.

That’s why i’m asking here, I could make the front in javascript, I mean it’s just an inventory management game at first, (until I get better to make real time boss fights), but i need some way to store data so i’m asking if my thinking is correct.

Basically because items will be random, which means i’d do something like this:

Math.random > pick a stat > Math.random > pick a number and get an item like this:
Epic boots: +1 str, +50int, + 200hp
That item is unique and that means I have to store it on the server. But i also have to delete it after it was deleted right?

Either that or I could generate every possible item (millions or billions of items?!), store it on the server and use Math.random to pick one of them

Which approach is the best?

Also, if I mark every item with a number starting from 0, that means that if a few thousand players are playing, after a few months, the number can go up to a few million. So item id would be like 20801258, would this affect performance?

So to fix it, i’m thinking of making a server maintenenance to clear up the ID numbers, because they’d be like this: 100 deleted 102 deleted deleted 105 106… So because most items will be deleted after a while, the maintenance could re-order the millions of items by removing the deleted and giving them new number names, so they don’t become too big.

But i don’t know if this method is any good, probably not because it’s the first think I thought of, doesn’t it create lag if 50 people are all getting items at once because that means the server must schedule each item to get an ID, random stats etc, one by one? Because if 2 people create an item at the same time, those 2 items would have the same ID and bug the game? Or are numbers and letters so fast to process that this isn’t a worry?

Sorry for the rant, I just had an idea and I woke up still thinking of how to do it, and I didn’t even delve into back end yet lol.

EDIT: I think I have an idea to fix the items at same time! What if I used player ID + number to generate IDs? That means every one will be unique even if 2 players are making item at same time!
EDIT2, even with player + number, the items object or array would still be millions long, maybe I should create a new array/object for every player to store items in?


#3

First use mongoose, then use mongoose auto-increment to assign object id. Create 2 collections and use references. First should contain user details, name, pass,email, race, class, etc. and the second should be for items.

For item found you should just do a roll for each stat and maybe add some end-game stuff yourself, like some special item set or whatever. If you use node.js and you need help let me know :slight_smile:

But i don’t know if this method is any good, probably not because it’s the first think I thought of, doesn’t it create lag if 50 people are all getting items at once because that means the server must schedule each item to get an ID, random stats etc, one by one? Because if 2 people create an item at the same time, those 2 items would have the same ID and bug the game? Or are numbers and letters so fast to process that this isn’t a worry?

If you use node, it should not be a problem … it’s async. Even if 1000 ppl receive a item at the same time there wont be a duplicate id. Mongodb can handle like a gazillion operations per second so nothing to worry about :slight_smile:


#4

Thank you both! It seems my fears aren’t real!

and maybe add some end-game stuff yourself

Nono, the whole point is for everything to be random, otherwise i’d have billions of games to play.

No need for more replies, i’ll start the project when i learn enough and ask more then! The only thing i can do right now is pure javascript which means no saving, i’ll start when i get proficient in back end.