GameDesign: Difference between revisions

Content deleted Content added
imported>StephenIerodiaconou
No edit summary
imported>MiguelAngelBlanchLardin
No edit summary
Line 124:
Postcondition: The state is STATE_LOGIN_BEGIN and the content waiting for player is clear.
</pre>
 
= Basic idea behind Database storage =
==Database Tables and Relationships ==
 
The database table relationship schema is:
<pre>
Table PLAYER
{
PK(username)
password
}
 
Table CHARACTERS
{
PK(character)
content
}
 
Table LOGIN_EVENT
{
PK(id)
address
timedate
result
}
 
Table STATISTICS
(
PK(timedate)
 
bytes_send
bytes_recv
 
players_login
players_logout
players_timeout
players_online
)
 
Table RPOBJECT
(
PK(id)
slot_id
)
 
Table RPATTRIBUTE
(
PK(object_id)
PK(name)
value
)
 
Table RPSLOT
(
object_id
name
PK(slot_id)
)
</pre>
 
Relationships:
<pre>
Relationship PLAYER_CHARACTERS
{
PK(player_username)
PK(characters_character)
}
 
Relationship PLAYER_LOGIN_EVENT
{
PK(player_username)
PK(login_event_id)
}
</pre>
Translate this to SQL easily and you have the SQL schema of Marauroa
 
 
== JDBC Database HOWTO==
JDBC technology is an API that lets you access virtually any tabular data source from the Java programming language. It provides cross-DBMS connectivity to a wide range of SQL databases, and now, with the new JDBC API, it also provides access to other tabular data sources, such as spreadsheets or flat files.
 
JDBCPlayerDatabase is anyway not database independent; on the Player table we are using AUTOINCREMENT that is a unique keyword of MySQL that is not part of the SQL standard.
 
You need to download MySQL Connector/J in order to get it to run. <br>
http://www.mysql.com/downloads/api-jdbc-stable.html
 
To configure Marauroa to work with a JDBC source we need to modify the configuration of the JDBC Connection.
 
So open the configuration file '''marauroad.ini''' ''(or whatever you choose to name it)'' and edit the next fields
<pre>
marauroa_DATABASE=JDBCPlayerDatabase
 
jdbc_class=com.mysql.jdbc.Driver
jdbc_url=jdbc:mysql://localhost/marauroa
jdbc_user=marauroa_dbuser
jdbc_pwd=marauroa_dbpwd
</pre>
 
* ''jdbc_class'': This field tells the engine what Driver to use for database access. Please refer to your software manual to see the multiple options.
* ''jdbc_url'': This points to the type and source of the information, for MySQL the string must be as follows:
** '''jdbc:mysql://ip:database_name/'''
* ''jdbc_user'': This is the username for the database
* ''jdbc_pwd'': This is the password for that username in the database.
 
Now, simply save the changes and your configuration file is ready.
 
Before using the application with the database, you need to create the database itself. So, with MySQL just run MySQL and enter:
<pre>
create database marauroa;
grant all on marauroa.* to marauroa_dbuser@localhost identified by 'marauroa_dbpwd';
</pre>
 
The rest of code is handled by the server itself, and it will create the tables if they don't exist.
 
=PlayerContainer Explained=