mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
* PLEASE RELOAD YOUR ITEMS AND MONSTERS AFTER THIS UPDATE
* save monster loot in database in json format instead loading it every time from xml file * store monster voices and immunities in json format * removed useless monsters.gfx_name field from database * convert item name to item id in loot in monsters.xml loader * after changing template you will be redirected to latest viewed page * display gallery add image form only on main gallery page * fixed displaying monster loot when item.name in loot is used instead of item.id * (intern) added new function getItemNameById($id) * (intern) renamed database field monsters.hide_creature to hidden
This commit is contained in:
parent
d4900eac84
commit
c2678aa91f
@ -28,7 +28,7 @@ session_start();
|
|||||||
|
|
||||||
define('MYAAC', true);
|
define('MYAAC', true);
|
||||||
define('MYAAC_VERSION', '0.6.1');
|
define('MYAAC_VERSION', '0.6.1');
|
||||||
define('DATABASE_VERSION', 13);
|
define('DATABASE_VERSION', 14);
|
||||||
define('TABLE_PREFIX', 'myaac_');
|
define('TABLE_PREFIX', 'myaac_');
|
||||||
define('START_TIME', microtime(true));
|
define('START_TIME', microtime(true));
|
||||||
define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX'));
|
define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX'));
|
||||||
|
@ -155,9 +155,9 @@ define('PAGE', $page);
|
|||||||
$template_place_holders = array();
|
$template_place_holders = array();
|
||||||
|
|
||||||
require_once(SYSTEM . 'init.php');
|
require_once(SYSTEM . 'init.php');
|
||||||
|
require_once(SYSTEM . 'template.php');
|
||||||
require_once(SYSTEM . 'login.php');
|
require_once(SYSTEM . 'login.php');
|
||||||
require_once(SYSTEM . 'status.php');
|
require_once(SYSTEM . 'status.php');
|
||||||
require_once(SYSTEM . 'template.php');
|
|
||||||
|
|
||||||
$twig->addGlobal('config', $config);
|
$twig->addGlobal('config', $config);
|
||||||
$twig->addGlobal('status', $status);
|
$twig->addGlobal('status', $status);
|
||||||
|
@ -140,20 +140,19 @@ CREATE TABLE `myaac_items`
|
|||||||
|
|
||||||
CREATE TABLE `myaac_monsters` (
|
CREATE TABLE `myaac_monsters` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`hide_creature` tinyint(1) NOT NULL default '0',
|
`hidden` tinyint(1) NOT NULL default 0,
|
||||||
`name` varchar(255) NOT NULL,
|
`name` varchar(255) NOT NULL,
|
||||||
`mana` int(11) NOT NULL,
|
`mana` int(11) NOT NULL DEFAULT 0,
|
||||||
`exp` int(11) NOT NULL,
|
`exp` int(11) NOT NULL,
|
||||||
`health` int(11) NOT NULL,
|
`health` int(11) NOT NULL,
|
||||||
`speed_lvl` int(11) NOT NULL default '1',
|
`speed_lvl` int(11) NOT NULL default 1,
|
||||||
`use_haste` tinyint(1) NOT NULL,
|
`use_haste` tinyint(1) NOT NULL,
|
||||||
`voices` text NOT NULL,
|
`voices` text NOT NULL,
|
||||||
`immunities` varchar(255) NOT NULL,
|
`immunities` varchar(255) NOT NULL,
|
||||||
`summonable` tinyint(1) NOT NULL,
|
`summonable` tinyint(1) NOT NULL,
|
||||||
`convinceable` tinyint(1) NOT NULL,
|
`convinceable` tinyint(1) NOT NULL,
|
||||||
`race` varchar(255) NOT NULL,
|
`race` varchar(255) NOT NULL,
|
||||||
`gfx_name` varchar(255) NOT NULL,
|
`loot` varchar(500) NOT NULL,
|
||||||
`file_path` varchar(255) NOT NULL,
|
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE = MyISAM;
|
) ENGINE = MyISAM;
|
||||||
|
|
||||||
|
@ -117,15 +117,24 @@ function getGuildLink($name, $generate = true)
|
|||||||
return generateLink($url, $name);
|
return generateLink($url, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getItemImage($id, $count = 1)
|
function getItemNameById($id) {
|
||||||
{
|
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$tooltip = '';
|
|
||||||
$query = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'items` WHERE `id` = ' . $db->quote($id) . ' LIMIT 1;');
|
$query = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'items` WHERE `id` = ' . $db->quote($id) . ' LIMIT 1;');
|
||||||
if($query->rowCount() == 1) {
|
if($query->rowCount() == 1) {
|
||||||
$item = $query->fetch();
|
$item = $query->fetch();
|
||||||
$tooltip = ' class="tooltip" title="' . $item['name'] . '"';
|
return $item['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getItemImage($id, $count = 1)
|
||||||
|
{
|
||||||
|
$tooltip = '';
|
||||||
|
|
||||||
|
$name = getItemNameById($id);
|
||||||
|
if(!empty($name)) {
|
||||||
|
$tooltip = ' class="tooltip" title="' . $name . '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_name = $id;
|
$file_name = $id;
|
||||||
|
@ -33,6 +33,12 @@ class Creatures {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$items = array();
|
||||||
|
$items_db = $db->query('SELECT `id`, `name` FROM `' . TABLE_PREFIX . 'items`;');
|
||||||
|
foreach($items_db->fetchAll() as $item) {
|
||||||
|
$items[$item['name']] = $item['id'];
|
||||||
|
}
|
||||||
|
|
||||||
//$names_added must be an array
|
//$names_added must be an array
|
||||||
$names_added[] = '';
|
$names_added[] = '';
|
||||||
//add monsters
|
//add monsters
|
||||||
@ -44,10 +50,10 @@ class Creatures {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//load monster mana needed to summon/convince
|
//load monster mana needed to summon/convince
|
||||||
$mana = $monster->getManaCost();
|
$mana = $monster->getManaCost();
|
||||||
//load monster experience
|
|
||||||
$exp = $monster->getExperience();
|
|
||||||
//load monster name
|
//load monster name
|
||||||
$name = $monster->getName();
|
$name = $monster->getName();
|
||||||
//load monster health
|
//load monster health
|
||||||
@ -67,51 +73,44 @@ class Creatures {
|
|||||||
$use_haste = 1;
|
$use_haste = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//load monster flags
|
|
||||||
$flags = $monster->getFlags();
|
|
||||||
//create string with immunities
|
|
||||||
$immunities = $monster->getImmunities();
|
|
||||||
$imu_nr = 0;
|
|
||||||
$imu_count = count($immunities);
|
|
||||||
$immunities_string = '';
|
|
||||||
foreach($immunities as $immunitie) {
|
|
||||||
$immunities_string .= $immunitie;
|
|
||||||
$imu_nr++;
|
|
||||||
if($imu_count != $imu_nr) {
|
|
||||||
$immunities_string .= ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//create string with voices
|
|
||||||
$voices = $monster->getVoices();
|
|
||||||
$voice_nr = 0;
|
|
||||||
$voice_count = count($voices);
|
|
||||||
$voices_string = '';
|
|
||||||
foreach($voices as $voice) {
|
|
||||||
$voices_string .= '"'.$voice.'"';
|
|
||||||
$voice_nr++;
|
|
||||||
if($voice_count != $voice_nr) {
|
|
||||||
$voices_string .= ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//load race
|
//load race
|
||||||
$race = $monster->getRace();
|
$race = $monster->getRace();
|
||||||
//create monster gfx name
|
|
||||||
//$gfx_name = str_replace(" ", "", trim(mb_strtolower($name))).".gif";
|
|
||||||
$gfx_name = trim(mb_strtolower($name)).".gif";
|
|
||||||
//don't add 2 monsters with same name, like Butterfly
|
|
||||||
|
|
||||||
|
//load monster flags
|
||||||
|
$flags = $monster->getFlags();
|
||||||
if(!isset($flags['summonable']))
|
if(!isset($flags['summonable']))
|
||||||
$flags['summonable'] = '0';
|
$flags['summonable'] = '0';
|
||||||
if(!isset($flags['convinceable']))
|
if(!isset($flags['convinceable']))
|
||||||
$flags['convinceable'] = '0';
|
$flags['convinceable'] = '0';
|
||||||
|
|
||||||
|
$loot = $monster->getLoot();
|
||||||
|
foreach($loot as &$item) {
|
||||||
|
if(!Validator::number($item['id'])) {
|
||||||
|
if(isset($items[$item['id']])) {
|
||||||
|
$item['id'] = $items[$item['id']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if(!in_array($name, $names_added)) {
|
if(!in_array($name, $names_added)) {
|
||||||
try {
|
try {
|
||||||
$db->query("INSERT INTO `myaac_monsters` (`hide_creature`, `name`, `mana`, `exp`, `health`, `speed_lvl`, `use_haste`, `voices`, `immunities`, `summonable`, `convinceable`, `race`, `gfx_name`, `file_path`) VALUES (0, " . $db->quote($name) . ", " . $db->quote(empty($mana) ? 0 : $mana) . ", " . $db->quote($exp) . ", " . $db->quote($health) . ", " . $db->quote($speed_lvl) . ", " . $db->quote($use_haste) . ", " . $db->quote($voices_string) . ", " . $db->quote($immunities_string) . ", " . $db->quote($flags['summonable'] > 0 ? 1 : 0) . ", " . $db->quote($flags['convinceable'] > 0 ? 1 : 0) . ", ".$db->quote($race).", ".$db->quote($gfx_name).", " . $db->quote(self::$monstersList->currentFile()) . ")");
|
$db->insert(TABLE_PREFIX . 'monsters', array(
|
||||||
|
'name' => $name,
|
||||||
|
'mana' => empty($mana) ? 0 : $mana,
|
||||||
|
'exp' => $monster->getExperience(),
|
||||||
|
'health' => $health,
|
||||||
|
'speed_lvl' => $speed_lvl,
|
||||||
|
'use_haste' => $use_haste,
|
||||||
|
'voices' => json_encode($monster->getVoices()),
|
||||||
|
'immunities' => json_encode($monster->getImmunities()),
|
||||||
|
'summonable' => $flags['summonable'] > 0 ? 1 : 0,
|
||||||
|
'convinceable' => $flags['convinceable'] > 0 ? 1 : 0,
|
||||||
|
'race' => $race,
|
||||||
|
'loot' => json_encode($loot)
|
||||||
|
));
|
||||||
|
|
||||||
if($show) {
|
if($show) {
|
||||||
success("Added: ".$name."<br/>");
|
success('Added: ' . $name . '<br/>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(PDOException $error) {
|
catch(PDOException $error) {
|
||||||
|
@ -194,7 +194,6 @@ class OTS_Monster extends DOMDocument
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array List of item IDs.
|
* @return array List of item IDs.
|
||||||
* @deprecated 0.1.0 Use getItems().
|
|
||||||
*/
|
*/
|
||||||
public function getLoot()
|
public function getLoot()
|
||||||
{
|
{
|
||||||
@ -208,13 +207,25 @@ class OTS_Monster extends DOMDocument
|
|||||||
// adds all items
|
// adds all items
|
||||||
foreach( $element->getElementsByTagName('item') as $item)
|
foreach( $element->getElementsByTagName('item') as $item)
|
||||||
{
|
{
|
||||||
$id = $item->getAttribute('id');
|
$chance = $item->getAttribute('chance');
|
||||||
|
if(empty($chance)) {
|
||||||
// avoid redundancy
|
$chance = $item->getAttribute('chance1');
|
||||||
if( !in_array($id, $loot) )
|
if(empty($chance)) {
|
||||||
{
|
$chance = 100000;
|
||||||
$loot[] = $id;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$count = $item->getAttribute('countmax');
|
||||||
|
if(empty($count)) {
|
||||||
|
$count = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $item->getAttribute('id');
|
||||||
|
if(empty($id)) {
|
||||||
|
$id = $item->getAttribute('name');
|
||||||
|
}
|
||||||
|
|
||||||
|
$loot[] = array('id' => $id, 'count' => $count, 'chance' => $chance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
system/migrations/14.php
Normal file
18
system/migrations/14.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// change monsters.file_path field to loot
|
||||||
|
if(fieldExist('file_path', TABLE_PREFIX . 'monsters')) {
|
||||||
|
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` CHANGE `file_path` `loot` VARCHAR(5000);");
|
||||||
|
}
|
||||||
|
|
||||||
|
// update loot to empty string
|
||||||
|
$db->query("UPDATE `" . TABLE_PREFIX . "monsters` SET `loot` = '';");
|
||||||
|
|
||||||
|
// drop monsters.gfx_name field
|
||||||
|
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` DROP COLUMN `gfx_name`;");
|
||||||
|
|
||||||
|
// rename hide_creature to hidden
|
||||||
|
if(fieldExist('hide_creature', TABLE_PREFIX . 'monsters')) {
|
||||||
|
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` CHANGE `hide_creature` `hidden` TINYINT(1) NOT NULL DEFAULT 0;");
|
||||||
|
}
|
||||||
|
?>
|
@ -12,62 +12,24 @@
|
|||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
$title = "Creatures";
|
$title = "Creatures";
|
||||||
|
|
||||||
$rarity = array(
|
?>
|
||||||
'Not Rare' => 7,
|
<script type="text/javascript" src="tools/tipped.js"></script>
|
||||||
'Semi Rare' => 2,
|
<link rel="stylesheet" type="text/css" href="tools/tipped.css"/>
|
||||||
'Rare' => 0.5,
|
<script>
|
||||||
'Very Rare' => 0
|
$(document).ready(function() {
|
||||||
);
|
Tipped.create('.tooltip');
|
||||||
|
});
|
||||||
function addLoot($loot, $level=1)
|
</script>
|
||||||
{
|
|
||||||
foreach($loot as $test) {
|
|
||||||
$chance = $test['chance'];
|
|
||||||
if(!$chance)
|
|
||||||
$chance = $test['chance1'];
|
|
||||||
|
|
||||||
printLoot($level, $test['id'], $test['countmax'], $chance);
|
|
||||||
foreach($test as $k => $v)
|
|
||||||
addLoot($v->item, $level + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
function printLoot($level, $itemid, $count, $chance)
|
|
||||||
{
|
|
||||||
global $itemList, $rarity, $i;
|
|
||||||
|
|
||||||
$chance /= 1000;
|
|
||||||
if(isset($_GET['lootrate'])) {
|
|
||||||
global $lootRate;
|
|
||||||
$chance *= $lootRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($rarity as $lootRarity => $percent) {
|
|
||||||
if($chance >= $percent) {
|
|
||||||
if(isset($itemid))
|
|
||||||
echo str_repeat("... ", $level) . '<u>' . ($count ? $count : 1) . '</u> <span style="color: #7878FF; font-weight: bold;">' . $itemList[(int)$itemid] . '</span> ' . $itemid . ' <span style="color: #C45; font-weight: bold;">' . $lootRarity . '</span> (<span style="color: #FF9A9A;">' . $chance . '%</span>)<br />';
|
|
||||||
|
|
||||||
if($i % 6 == 0)
|
|
||||||
{
|
|
||||||
if($i != 0)
|
|
||||||
echo '</td></tr>';
|
|
||||||
echo '<tr bgcolor="'.getStyle(0).'"><td width="100">';
|
|
||||||
}
|
|
||||||
echo getItemImage($itemid);
|
|
||||||
$i++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
<?php
|
||||||
$canEdit = hasFlag(FLAG_CONTENT_MONSTERS) || admin();
|
$canEdit = hasFlag(FLAG_CONTENT_MONSTERS) || admin();
|
||||||
if(isset($_POST['reload_monsters']) && $canEdit)
|
if(isset($_POST['reload_monsters']) && $canEdit)
|
||||||
{
|
{
|
||||||
require LIBS . 'creatures.php';
|
require LIBS . 'creatures.php';
|
||||||
if(Creatures::loadFromXML(true))
|
if(Creatures::loadFromXML(true)) {
|
||||||
if(Creatures::getMonstersList()->hasErrors())
|
if (Creatures::getMonstersList()->hasErrors())
|
||||||
error('There were some problems loading your monsters.xml file. Please check system/logs/error.log for more info.');
|
error('There were some problems loading your monsters.xml file. Please check system/logs/error.log for more info.');
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
error(Creatures::getLastError());
|
error(Creatures::getLastError());
|
||||||
}
|
}
|
||||||
@ -114,7 +76,7 @@ if(empty($_REQUEST['creature']))
|
|||||||
$whereandorder = ' ORDER BY name';
|
$whereandorder = ' ORDER BY name';
|
||||||
}
|
}
|
||||||
//send query to database
|
//send query to database
|
||||||
$monsters = $db->query('SELECT * FROM '.$db->tableName(TABLE_PREFIX . 'monsters').' WHERE hide_creature != 1'.$whereandorder);
|
$monsters = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1'.$whereandorder);
|
||||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'>';
|
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'>';
|
||||||
if($order == 'name' && !isset($_REQUEST['desc'])) {
|
if($order == 'name' && !isset($_REQUEST['desc'])) {
|
||||||
echo '<TD class="white" width="200"><B><a href="?subtopic=creatures&order=name&desc=1"><font class="white">Name DESC</a></B></TD>';
|
echo '<TD class="white" width="200"><B><a href="?subtopic=creatures&order=name&desc=1"><font class="white">Name DESC</a></B></TD>';
|
||||||
@ -173,7 +135,7 @@ if(empty($_REQUEST['creature']))
|
|||||||
|
|
||||||
|
|
||||||
$monster_name = stripslashes(trim(ucwords($_REQUEST['creature'])));
|
$monster_name = stripslashes(trim(ucwords($_REQUEST['creature'])));
|
||||||
$monster = $db->query('SELECT * FROM '.$db->tableName(TABLE_PREFIX . 'monsters').' WHERE '.$db->fieldName('hide_creature').' != 1 AND '.$db->fieldName('name').' = '.$db->quote($monster_name).';')->fetch();
|
$monster = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 AND `name` = '.$db->quote($monster_name).';')->fetch();
|
||||||
if(isset($monster['name']))
|
if(isset($monster['name']))
|
||||||
{
|
{
|
||||||
$title = $monster['name'] . " - Creatures";
|
$title = $monster['name'] . " - Creatures";
|
||||||
@ -209,6 +171,7 @@ if(isset($monster['name']))
|
|||||||
echo '</TABLE></td><td align=left>
|
echo '</TABLE></td><td align=left>
|
||||||
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=40%>
|
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=40%>
|
||||||
<tr><td align=left>';
|
<tr><td align=left>';
|
||||||
|
$monster['gfx_name'] = trim(mb_strtolower($monster['name'])).".gif";
|
||||||
if(!file_exists('images/monsters/'.$monster['gfx_name'])) {
|
if(!file_exists('images/monsters/'.$monster['gfx_name'])) {
|
||||||
$gfx_name = str_replace(" ", "", $monster['gfx_name']);
|
$gfx_name = str_replace(" ", "", $monster['gfx_name']);
|
||||||
if(file_exists('images/monsters/' . $gfx_name))
|
if(file_exists('images/monsters/' . $gfx_name))
|
||||||
@ -222,33 +185,59 @@ if(isset($monster['name']))
|
|||||||
echo '</td></tr>
|
echo '</td></tr>
|
||||||
</TABLE></td></tr><tr><td>
|
</TABLE></td></tr><tr><td>
|
||||||
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>';
|
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>';
|
||||||
if(!empty($monster['immunities']))
|
$immunities = json_decode($monster['immunities'], true);
|
||||||
|
if(count($immunities) > 0)
|
||||||
{
|
{
|
||||||
$number_of_rows++;
|
$number_of_rows++;
|
||||||
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Immunities: </b></td><td width="100%">'.$monster['immunities'].'</td></tr>';
|
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Immunities: </b></td><td width="100%">'.implode(', ', $immunities).'</td></tr>';
|
||||||
}
|
}
|
||||||
if(!empty($monster['voices']))
|
|
||||||
|
$voices = json_decode($monster['voices'], true);
|
||||||
|
if(count($voices) > 0)
|
||||||
{
|
{
|
||||||
|
foreach($voices as &$voice) {
|
||||||
|
$voice = '"' . $voice . '"';
|
||||||
|
}
|
||||||
|
|
||||||
$number_of_rows++;
|
$number_of_rows++;
|
||||||
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Voices: </b></td><td width="100%">'.$monster['voices'].'</td></tr>';
|
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Voices: </b></td><td width="100%">'.implode(', ', $voices).'</td></tr>';
|
||||||
}
|
}
|
||||||
echo '</TABLE></td></tr>';
|
echo '</TABLE></td></tr>';
|
||||||
|
|
||||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>';
|
$loot = json_decode($monster['loot'], true);
|
||||||
$loot = simplexml_load_file($config['data_path'] . 'monster/' . $monster['file_path']);
|
|
||||||
if($loot)
|
if($loot)
|
||||||
{
|
{
|
||||||
if($item = $loot->loot->item)
|
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td style="display: block;">';
|
||||||
addLoot($item);
|
function sort_by_chance($a, $b)
|
||||||
|
{
|
||||||
|
if($a['chance'] == $b['chance']) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ($a['chance'] > $b['chance']) ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($loot, 'sort_by_chance');
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
foreach($loot as $item) {
|
||||||
|
$name = getItemNameById($item['id']);
|
||||||
|
$tooltip = $name . '<br/>Chance: ' . round($item['chance'] / 1000, 2) . '%<br/>Max count: ' . $item['count'];
|
||||||
|
|
||||||
|
echo '<img src="' . $config['item_images_url'] . $item['id'] . '.gif" class="tooltip" title="' . $tooltip . '" width="32" height="32" border="0" alt=" ' .$name . '" />';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</td></tr></TABLE>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</TABLE></td></tr>';
|
echo '</td></tr>';
|
||||||
echo '</TABLE>';
|
echo '</TABLE>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo 'Monster with name <b>'.$monster_name.'</b> doesn\'t exist.';
|
echo "Monster with name <b>" . $monster_name . "</b> doesn't exist.";
|
||||||
}
|
}
|
||||||
|
|
||||||
//back button
|
//back button
|
||||||
echo $twig->render('creatures.back_button.html.twig');
|
echo $twig->render('creatures.back_button.html.twig');
|
||||||
?>
|
?>
|
||||||
|
@ -56,14 +56,16 @@ if($canEdit) {
|
|||||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $twig->render('gallery.form.html.twig', array(
|
if(!isset($_GET['image'])) {
|
||||||
'link' => getLink('gallery/' . ($action == 'edit' ? 'edit' : 'add')),
|
echo $twig->render('gallery.form.html.twig', array(
|
||||||
'action' => $action,
|
'link' => getLink('gallery/' . ($action == 'edit' ? 'edit' : 'add')),
|
||||||
'id' => isset($id) ? $id : null,
|
'action' => $action,
|
||||||
'comment' => isset($comment) ? $comment : null,
|
'id' => isset($id) ? $id : null,
|
||||||
'image' => isset($image) ? $image : null,
|
'comment' => isset($comment) ? $comment : null,
|
||||||
'author' => isset($author) ? $author : null
|
'image' => isset($image) ? $image : null,
|
||||||
));
|
'author' => isset($author) ? $author : null
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
echo 'You cannot edit/add gallery items as it seems your PHP installation doesnt have GD support enabled. Visit <a href="http://be2.php.net/manual/en/image.installation.php">PHP Manual</a> for more info.';
|
echo 'You cannot edit/add gallery items as it seems your PHP installation doesnt have GD support enabled. Visit <a href="http://be2.php.net/manual/en/image.installation.php">PHP Manual</a> for more info.';
|
||||||
|
@ -20,6 +20,7 @@ if($config['template_allow_change'])
|
|||||||
if(!preg_match("/[^A-z0-9_\-]/", $template_name)) { // validate template
|
if(!preg_match("/[^A-z0-9_\-]/", $template_name)) { // validate template
|
||||||
//setcookie('template', $template_name, 0, BASE_DIR . '/', $_SERVER["SERVER_NAME"]);
|
//setcookie('template', $template_name, 0, BASE_DIR . '/', $_SERVER["SERVER_NAME"]);
|
||||||
setSession('template', $template_name);
|
setSession('template', $template_name);
|
||||||
|
header('Location:' . getSession('last_uri'));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$template_name = $config['template'];
|
$template_name = $config['template'];
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<script type="text/javascript" src="tools/tipped.js"></script>
|
<script type="text/javascript" src="tools/tipped.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="tools/tipped.css"/>
|
<link rel="stylesheet" type="text/css" href="tools/tipped.css"/>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
Tipped.create('.tooltip');
|
Tipped.create('.tooltip');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% set rows = 0 %}
|
{% set rows = 0 %}
|
||||||
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>
|
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user