The game-class manages all game-specific information. It can be called by "global $game;". The information about the game are stored in the games-folder. For e.g. WoW: "games/WoW/WoW.class.php". Additionally there are the language files (e.g. english.php) and the images in their folders.
Contents |
In many functions $type is used. $type is a string and for e.g. WoW you have the following types: 'classes', 'races', 'factions', 'filters', 'realmlist'.
| filtername | Description |
|---|---|
| id_0 | remove dataset for id=0 |
Every Game has its own class where all information are saved. The file has to be named <gamename>.class.php (e.g. wow.class.php) and must lie in the games/<gamename> folder. The gamename should only be in small letters! The first lines should be this: So it is not possible to access that file directly. It should only be included.
<?php if ( !defined('EQDKP_INC') ) { header('HTTP/1.0 404 Not Found'); exit; }
Afterwards we start the definition of our class: The class is named after the game!
if(!class_exists('wow')) { class wow extends game_generic {
The next thing we have to do is to define which information the class holds:
private $this_game = 'wow'; private $types = array('classes', 'races', 'factions', 'filters', 'realmlist'); // which information are stored? private $classes = array(); // private $races = array(); // for each type there must be the according var private $factions = array(); // and the according function: load_$type private $filters = array(); // private $realmlist = array(); // public $objects = array('wow_modelviewer'); // eventually there are some objects (php-classes) in this game (stored in objects. e.g. // wow_modelviewer.class.php) public $langs = array('english', 'german', 'french', 'russian'); // in which languages do we have information? public $icons = array('classes', 'races', 'ranks', 'events', 'talents', '3dmodel'); // which icons do we have?
The first must-have-function is the function "get_OnChangeInfos":
/** * Returns Information to change the game * * @param bool $install * @return array */ public function get_OnChangeInfos($install=false) { //if there exist class_colors add them here $info['class_color'] = array( $class_id => #hex_code, //e.g.: 6 => '#FFFFFF', ); //here we add sql-queries, which shall be done on every game-change $info['aq'] = array( //for e.g. WoW we have special logos in some templates, so change the logo_path "UPDATE __style_config SET logo_path='/logo/logo_wow.gif' WHERE style_id = 14 ;", // [...] "UPDATE __style_config SET logo_path='wowlogo3.png' WHERE style_id = 35 ;", //Itemstats exists for WoW, so we ensure, that there will be correct information for itemstats "UPDATE __config SET config_value = 'armory_wowhead' WHERE config_name = 'pk_is_webdb' ;", "UPDATE __config SET config_value = 'http://wowdata.buffed.de/img/icons/wow/32/' WHERE config_name = 'pk_is_icon_loc' ;", "UPDATE __config SET config_value = '1' WHERE config_name = 'pk_itemstats' ;", "UPDATE __config SET config_value = '0' WHERE config_name = 'pk_is_autosearch' ;", ); //here we add sql-queries which shall only be done on the first install of eqdkp if($install) { //for WoW we have some events, most one want: array_push($info['aq'], "INSERT INTO __events VALUES (1, 'Ulduar (10)', 0.00, 'default', NULL, 'ulduar3.png'); "); // [...] array_push($info['aq'], "INSERT INTO __events VALUES (8, 'Sartharion (25)', 0.00, 'default', NULL, 'wotlk-raid-obsidian_sanctum_25.gif'); "); //default links array_push($info['aq'], "INSERT INTO __plus_links (`link_url`, `link_name`, `link_window`, `link_menu`) VALUES ('eu.wowarmory.com', 'Armory', 1, 0);"); array_push($info['aq'], "INSERT INTO __plus_links (`link_url`, `link_name`, `link_window`, `link_menu`) VALUES ('www.wow-europe.com', 'WoW-Europe', 1, 0);"); } return $info; }
Afterwards you have to write a load_filters function. Here you have to define which filters shall be selectable. Each filter is an array with $name => $value. The $name is what you want to have displayed. The $value is what shall be selected. (e.g.: classes with the ids 1 and 4 => 'class:1,4').
/** * Initialises filters * * @param array $langs */ private function load_filters($langs) { global $user; //we want to display class_names so we need to load them, if they are not already loaded if(!$this->classes) { $this->load_classes($langs); } foreach($langs as $lang) { //here we store the class_names $names = $this->classes[$this->lang]; $this->filters[$lang] = array( //the first entry should have a false value array('name' => '-----------', 'value' => false), array('name' => $names[0], 'value' => 'class:0'), // [...] array('name' => $names[10], 'value' => 'class:10'), array('name' => '-----------', 'value' => false), //here we load the name of the filter from the game_language array('name' => $this->glang('plate', $lang), 'value' => 'class:1,5,10'), array('name' => $this->glang('mail', $lang), 'value' => 'class:3,8'), // [...] ); } }
It is possible to create a load function foreach type. The function name must be load_$type.
Now all the "must-have" functions are there. If you want you can define here custom decorate functions or custom functions, which are game-specific. They can be called via $game->callFunc('funcname', array $params);
Now we have finished the wow.class.php! Don't forget to add ?>Next we have to create our language files. For each language we specified in the WoW.class.php we need an extra file. So in this case: english.php, german.php, french.php, russian.php. Because the language files also shall only be included, we add
<?php if ( !defined('EQDKP_INC') ) { header('HTTP/1.0 404 Not Found'); exit; }
at the beginning of the file. What follows now is one array with all the "language" information about the game. german.php of WoW:
//The array is named <languagename>_array! $german_array = array( // the index 'classes' can be chosen freely, but if it differs from the 'type', you need a load function for that type! // First we define our classes: class_id => class_name. The ID's must be the same in the other languages! // For the first language you create you can choose the ID freely, but the ID "0" always should belong to "Unknown" 'classes' => array( 0 => 'Unbekannt', 1 => 'Todesritter', 2 => 'Druide', // [...] ), //same for the races 'races' => array( 'Unknown', 'Gnom', 'Mensch', // [...] ), //and same for the factions 'factions' => array('Allianz', 'Horde'), //here we define all game specific language-vars 'lang' => array( 'plate' => 'Platte', 'cloth' => 'Stoff', // [...] // in WoW we have names for talent-trees they are stored in the lang_var 'talents'. // each class has 3 talent-trees so we have an assignment: $class_id => array('talent_tree0', 'talent_tree1', 'talent_tree2') 'talents' => array( 1 => array('Blut','Frost','Unheilig'), // [...] ), ), //here follow the realms 'realmlist' => array( "Aegwynn", "Alexstrasza", // [...] ), );
Now the file is complete. End it with "?>"! Now you only have to add the images into their folders, and you have successfully added a new Game to EQDKP-Plus!