POT
POT
POT
Main menu

Download

Forum

SVN

Prev Next

Creating framework

This is short description about how to prepare complete OTServ framework using POT.

Table of Contents

The toolkit and the framework

Probably many of you have heard both about toolkits abd frameworks. What are they and thats the different?

Toolkit is set of routines (functions, classes, objects, variables etc.) defined and oriented for some problem. However toolkit provides only particular mechanisms. For example POT contains classes for many different resources of OTServ but it just gives you some abstraction for them, without defining any detailed way you should handle them. Framework, on the other hand, gives you entire enviroment. It defines connections between some parts of system and defines particular way you should follow developing software with given framework.

If you plan to use POT in your framework you should initialise it and load all required resources so it would be fully functional within your framework scope.

Initialisation

First of all your POT should be function - most important part is database handle. You should pre-load main POT file to make POT interface available and also make it's instance connected to database.

Resource handlers

After that you should load all data/ directory resource handlers to make your POT enviroment complete - many features can't be used before all resources won't be loaded:

  1. <?php
  2.  
  3. // includes POT main file
  4. include_once('classes/OTS.php');
  5.  
  6. $ots POT::getInstance();
  7.  
  8. // connects to database
  9. $ots->connect(POT::DB_MYSQLarray('host' => 'localhost''user' => 'wrzasq''database' => 'otserv') );
  10.  
  11. // load all resources
  12. $ots->loadVocations('/home/wrzasq/.otserv/data/vocations.xml');
  13. $ots->loadMonsters('/home/wrzasq/.otserv/data/monster/');
  14. $ots->loadSpells('/home/wrzasq/.otserv/data/spells/spells.xml');
  15. $ots->loadItems('/home/wrzasq/.otserv/data/items/');
  16. $ots->loadMap('/home/wrzasq/.otserv/data/world/map.otbm');
  17.  
  18. /*
  19.     Invites handling driver.
  20. */
  21.  
  22. class InvitesDriver implements IOTS_GuildAction
  23. {
  24. /* implement IOTS_GuildAction here */
  25. }
  26.  
  27. /*
  28.     Membership requests handling driver.
  29. */
  30.  
  31. class RequestsDriver implements IOTS_GuildAction
  32. {
  33. /* implement IOTS_GuildAction here */
  34. }
  35.  
  36. /*
  37.     Standard binary format cache.
  38. */
  39.  
  40. class FileCache implements IOTS_FileCache
  41. {
  42. /* implement IOTS_FileCache here */
  43. }
  44.  
  45. /*
  46.     Items cache driver.
  47. */
  48.  
  49. class ItemsCache implements IOTS_ItemsCache
  50. {
  51. /* implement IOTS_ItemsCache here */
  52. }
  53.  
  54. /*
  55.     Database objects display driver.
  56. */
  57.  
  58. class DisplayDriver implements IOTS_Display
  59. {
  60. /* implement IOTS_Display here */
  61. }
  62.  
  63. /*
  64.     Display driver for data/ directory resources.
  65. */
  66.  
  67. class DataDisplayDriver implements IOTS_DataDisplay
  68. {
  69. /* implement IOTS_DataDisplay here */
  70. }
  71.  
  72. // sets display drivers for current enviroment
  73. $ots->setDisplayDrivernew DisplayDriver() );
  74. $ots->setDataDisplayDrivernew DataDisplayDriver() );
  75.  
  76. ?>

Interface drivers

Last thing is to provide full features by creating drivers that implements interfaces for POT classes. Those are cache drivers, guild action drivers and display drivers. Display drivers are assigned to POT instance so you can somehow hide it since they will just reside inside POT class object.

Prev Up Next
Deprecations Additional info AAC scripts