mirror of
https://github.com/slawkens/myaac.git
synced 2025-06-13 08:14:31 +02:00
fixed #87
This commit is contained in:
parent
f5374e8ce7
commit
49fe7a4b38
@ -11,21 +11,21 @@
|
|||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
|
|
||||||
class Creatures {
|
class Creatures {
|
||||||
private static $monstersList = null;
|
private static $monstersList;
|
||||||
private static $lastError = '';
|
private static $lastError = '';
|
||||||
|
|
||||||
public static function loadFromXML($show = false) {
|
public static function loadFromXML($show = false) {
|
||||||
global $config, $db;
|
global $db;
|
||||||
|
|
||||||
try { $db->query("DELETE FROM `myaac_monsters`;"); } catch(PDOException $error) {}
|
try { $db->exec('DELETE FROM `' . TABLE_PREFIX . 'monsters`;'); } catch(PDOException $error) {}
|
||||||
|
|
||||||
if($show) {
|
if($show) {
|
||||||
echo '<h2>Reload monsters.</h2>';
|
echo '<h2>Reload monsters.</h2>';
|
||||||
echo "<h2>All records deleted from table 'myaac_monsters' in database.</h2>";
|
echo "<h2>All records deleted from table '" . TABLE_PREFIX . "monsters' in database.</h2>";
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
self::$monstersList = new OTS_MonstersList($config['data_path'].'monster/');
|
self::$monstersList = new OTS_MonstersList(config('data_path') . 'monster/');
|
||||||
}
|
}
|
||||||
catch(Exception $e) {
|
catch(Exception $e) {
|
||||||
self::$lastError = $e->getMessage();
|
self::$lastError = $e->getMessage();
|
||||||
@ -33,9 +33,9 @@ class Creatures {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$items = array();
|
$items = array();
|
||||||
$items_db = $db->query('SELECT `id`, `name` FROM `' . TABLE_PREFIX . 'items`;');
|
Items::load();
|
||||||
foreach($items_db->fetchAll() as $item) {
|
foreach((array)Items::$items as $id => $item) {
|
||||||
$items[$item['name']] = $item['id'];
|
$items[$item['name']] = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$names_added must be an array
|
//$names_added must be an array
|
||||||
|
@ -13,7 +13,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
|||||||
class Items
|
class Items
|
||||||
{
|
{
|
||||||
private static $error = '';
|
private static $error = '';
|
||||||
private static $items;
|
public static $items;
|
||||||
|
|
||||||
public static function loadFromXML($show = false)
|
public static function loadFromXML($show = false)
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@ class Items
|
|||||||
} else {
|
} else {
|
||||||
$tmp = self::parseNode($item->getAttribute('id'), $item, $show);
|
$tmp = self::parseNode($item->getAttribute('id'), $item, $show);
|
||||||
$items[$tmp['id']] = $tmp['content'];
|
$items[$tmp['id']] = $tmp['content'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once LIBS . 'cache_php.php';
|
require_once LIBS . 'cache_php.php';
|
||||||
@ -62,7 +62,7 @@ class Items
|
|||||||
return self::$error;
|
return self::$error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function loadItems() {
|
public static function load() {
|
||||||
if(self::$items) {
|
if(self::$items) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -72,15 +72,15 @@ class Items
|
|||||||
self::$items = $cache_php->get('items');
|
self::$items = $cache_php->get('items');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getItem($id) {
|
public static function get($id) {
|
||||||
self::loadItems();
|
self::load();
|
||||||
return self::$items[$id];
|
return self::$items[$id];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDescription($id, $count = 1) {
|
public static function getDescription($id, $count = 1) {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$item = self::getItem($id);
|
$item = self::get($id);
|
||||||
|
|
||||||
$attr = $item['attributes'];
|
$attr = $item['attributes'];
|
||||||
$s = '';
|
$s = '';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user