Sign in to follow this  
Selacius

[.net] Downloadable RPG + Global Database

Recommended Posts

Im thinking of converting my PHP RPG to a C# windows form program. I am just curious what would be the most effective and efficient way to setup the databases. Currently the PHP version uses MYSQL. I was considering having the user uplink to the database when the program is initially run, and update the database when the program is exited. The only problem is, due to the nature of the game, the user needs to be connected to the database at all times.

Share this post


Link to post
Share on other sites
1. Build a remoting server which publishes a simple method that gets the data and keeps it in memory.
2. The remoting server app will only save the data of each client in the database when the client closes.
3. ...profit?


[Edit for clarity]

RPG Server DB

| ---load My data-----> | |
| | ---gimme his data----> |
| | <--there you go------- |
| <--your data--------- | |
| ---changes----------> | |
| ---changes----------> | |
| ---changes----------> | |
| ---changes----------> | |
| ---I'm going away---> | |
| | ---Save his data----> |

Share this post


Link to post
Share on other sites
I would like to do it that way, but there are certain aspects where the player needs to be in constant access to the database. I could in those situations just open the connection and keep it open for as long as necessary I guess.

Share this post


Link to post
Share on other sites
Quote:
Original post by Selacius
I would like to do it that way, but there are certain aspects where the player needs to be in constant access to the database.

Could you describe an example of such a situation?

[edit: (in case that sounded rude)]
The server never closes the connection, so it could send the player a response to any query, however in most cases this is not necessary. That's why I asked for the example.
[/edit]

[Edited by - Zanshibumi on May 24, 2007 6:57:47 AM]

Share this post


Link to post
Share on other sites
The battle system is turn based, so after every turn a row in a table is updated in the database. These values include the current tick, enemies current hp left, the enemies max hp, etc. The reason for this is a prevention measure so that if a player closes the window, or tries to get out of the battle, the next time they attempt to fight something, they get placed back into their previous battle. So there is no way for them to run without getting punished.

Basically why I ask which would be the best method to go about so i don't have to continually access the database is for speed. I find when I access the database now its quite laggy and takes a while for things to load and be displayed.

Share this post


Link to post
Share on other sites
Do you really need to use a database for this? I would think using a file would be much quicker and easier. If they close the window, simply save the gamestate as it exists. You could even keep the file open and write to it as needed.

Share this post


Link to post
Share on other sites
Quote:
Original post by Selacius
[...]The reason for this is a prevention measure so that if a player closes the window[...]

In the structure I suggested, the player has no access whatsoever to the application that's keeping the game's data. If he closes his window, the server waits a bit (1 hour for example) and then saves the data in the database and deletes it from memory.
When the player reconnects, if the server still has the data it sends it instantly, else it loads it from the DB and sends it.


Retaking the diagram:

RPG Server DB

| -Hi. Load My data---> | |
| | ---gimme his data----> |
| | <----his data--------- |
| <--your data--------- | |
| --tick, hp1, hp2----> | |
| --tick, hp1, hp2----> | |
| --tick, hp1, hp2----> | |
| --tick, hp1, hp2----> | |
... | |
disconnected | |
| |
| ---tick, hp1, hp2---> |
| <--data saved-------- |
| |
| -Hi. Load My data---> | |
| | ---gimme his data----> |
| | <---tick, hp1, hp2---- |
| <--tick, hp1, hp2---- | |


Share this post


Link to post
Share on other sites
Quote:
Original post by Machaira
Do you really need to use a database for this? I would think using a file would be much quicker and easier. If they close the window, simply save the gamestate as it exists. You could even keep the file open and write to it as needed.

For a hundred users, with their login info, current stats, last saved situation, etc... I'd use a database.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zanshibumi
Quote:
Original post by Machaira
Do you really need to use a database for this? I would think using a file would be much quicker and easier. If they close the window, simply save the gamestate as it exists. You could even keep the file open and write to it as needed.

For a hundred users, with their login info, current stats, last saved situation, etc... I'd use a database.


Didn't see this mentioned anywhere.

Share this post


Link to post
Share on other sites
Quote:
Original post by Machaira
Didn't see this mentioned anywhere.

Correct.

- I assumed it's a web game because of PHP.
- I assumed it would be directed towards at least a hundred players because he mentions it's a game (not B2B).
- I assumed it would need to save stats from this: "These values include the current tick, enemies current hp left, the enemies max hp, etc"
- I assumed it would need some kind of login procedure because the reentry procedure he mentions would need some way of identifying the player who disconnected previously.

But it's true that just by being wrong in the "he uses PHP wo it must be a web game" I'd be wrong in most of the rest.

Share this post


Link to post
Share on other sites
This is infact an online RPG. The databases are used to store player data (stats, equipment, quest completion, current battle information, accomplishments, stat modifiers), general game data (races, classes, skills, quests, equipment) and map information. Depending on the whereabouts of the player ingame, a connection to the database must be made. Now the remote connection has some merit to it and can be used for certain aspects (player information, map information), but when it comes to the general game settings area a connection must be made constantly. This is required mainly for the equipment portion. A system is in place where every 30minutes the stock of the shops gets restored with new weapons. So if a player buys a weapon, then the database and not the remote server must be updated to act as such. Im thinking of redoing the equipment though to get rid of this random equipment in stock, its too diabloesque, and make it so the shops have base weapons, and the random magical/rare weapons are found from enemies.

Share this post


Link to post
Share on other sites
Quote:
Original post by Selacius
[...]but when it comes to the general game settings area a connection must be made constantly. This is required mainly for the equipment portion. A system is in place where every 30minutes the stock of the shops gets restored with new weapons. So if a player buys a weapon, then the database and not the remote server must be updated to act as such.

Why?

You can save into the database whenever you want, but it's rarely needed.
You can save each and every change in a player's inventory, but keeping track of the equipment in the server and saving when he closes the connection is equally precise and reduces drastically the load on the db.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this