Tuesday, August 18, 2009

Status Report: ReXML

So far, I have successfully created a system that uses XML pseudofiles (which I will explain and document in a later post) to store data in a database, and the code to read the XML data and turn it into something meaningful for PHP is finished. Tonight, I work on the system that turns everything back into XML data and updates the database. I'm using a system of flags in an array called $REXML to assist in this process. It should be fun to program.

One of the biggest obstacles in picking this project back up is remembering the syntax. For example, dungeon data is stored in $GCHAR["d_data"]. Player data is $GCHAR["d_data"]->player, and the player's current HP is stored in $GCHAR["d_data"]->player->hp. Remembering the differences between arrays and SimpleXML objects is a bit of a pain.

Incidentally, one of my characters has a $GCHAR["d_data"] that looks like this:
<?xml version="1.0"?>
<ddata>
<player>
<hp>7</hp>
<sp>12</sp>
<encounter>0</encounter>
<initiative>0</initiative>
<x>0</x>
<y>0</y>
<dungeon>0</dungeon>
</player>
</ddata>


While another's looks like this:

<?xml version="1.0"?>
<ddata>
<player>
<hp>17</hp>
<sp>2</sp>
<encounter>0</encounter>
<initiative>16</initiative>
<x>0</x>
<y>2</y>
<dungeon>1</dungeon>
</player>
<cohort>
<id>1</id>
<name>Generic</name>
<type>human</type>
<hp>30</hp>
<sp>10</sp>
<initiative>11</initiative>
<attack>
<min>1</min>
<max>4</max>
<properties>
<prop>martial</prop>
</properties>
<closerange>1</closerange>
<midrange>0</midrange>
<farrange>0</farrange>
</attack>
<xpdrop>100</xpdrop>
<gpdrop>300</gpdrop>
<itemdrops>
<item>
<id>1</id>
<rate>20</rate>
</item>
<item>
<id>2</id>
<rate>1</rate>
</item>
</itemdrops>
<stats>
<str>14</str>
<dex>10</dex>
<con>12</con>
<int>10</int>
<wis>10</wis>
<cha>10</cha>
</stats>
</cohort>
<monster>
<id>3</id>
<name>Zombah!</name>
<type>undead</type>
<type>human</type>
<range>1</range>
<hp>2</hp>
<sp>10</sp>
<initiative>12</initiative>
<attack>
<min>1</min>
<max>4</max>
<properties>
<prop>martial</prop>
</properties>
<closerange>1</closerange>
<midrange>0</midrange>
<farrange>0</farrange>
</attack>
<attack>
<min>2</min>
<max>6</max>
<spcost>2</spcost>
<properties>
<prop>fire</prop>
</properties>
<spcost>0</spcost>
<closerange>0</closerange>
<midrange>1</midrange>
<farrange>1</farrange>
</attack>
<xpdrop>100</xpdrop>
<gpdrop>30</gpdrop>
<itemdrops>
<item>
<id>1</id>
<rate>20</rate>
</item>
<item>
<id>2</id>
<rate>1</rate>
</item>
<item>
<id>4</id>
<rate>1000</rate>
</item>
</itemdrops>
<stats>
<str>10</str>
<dex>6</dex>
<con>0</con>
<int>12</int>
<wis>8</wis>
<cha>9</cha>
</stats>
</monster>
</ddata>


Things can get messy, but everything you see should be auto-generated by the server.

No comments:

Post a Comment