First of all, a lot of this will be pseudo-code because I am mostly looking for feedback on the approach to the cross server marketplace for an RPG game. Mostly, this is based on the auction house in World of Warcraft.
What I want to do:
- User can list an item (such as a piece of armor)
- When listing the item, it shows all other listings of that item on the UI
- You can then list the item for as much or as little Gold as you want.
- If they list the item, the item is removed from their inventory and a MemoryStore is sent.
- User can browse the marketplace
- Search for an item they want, and if they see it at a good price they can purchase it with gold.
- After an item is purchased, a memory store is sent.
- When memory stores are processed, the gold will be sent to the seller and the item will be sent to the player via an in-game mail system. Items/gold can be sent to players in a mailbox no matter what server they’re in or if they’re offline. This is also a fallback in case they use gold to try and buy an auction that was delisted; it simply mails back their gold.
My approach to this:
I am using a DataStore for the auction data storage. It contains a dictionary of all the auctions, and the current JobId as well as a ping os.time() to determine the last time it was alive. On server close, it sets the JobId to nil.
- If the server’s JobId is equal to where it’s currently loaded and locked to, it processes the MemoryStoreService queue.
- If it does not, it simply updates the auction dictionary on the server to display items to the player.
- If the server’s JobId doesn’t exist (meaning it’s dead) or the last update time was several minutes, that means the server was closed or crashed, so the current server loads/takes over the auctions parsing.
Is this a good approach, and should I just be fully using MemoryStore service purely for this? I was a bit concerned of using MemoryStore purely due to all of the limitations, but if anyone could describe a way to do this better, or give feedback on any edge cases that’d be great.
As I said this is pseudo-code as I don’t need help coding what I described, I have it working properly as I described on a test place. I am mostly looking for review on the system design in general.