diff --git a/common.php b/common.php index 415c3d1e..c740cd35 100644 --- a/common.php +++ b/common.php @@ -28,7 +28,7 @@ session_start(); define('MYAAC', true); define('MYAAC_VERSION', '0.9.0-dev'); -define('DATABASE_VERSION', 30); +define('DATABASE_VERSION', 31); define('TABLE_PREFIX', 'myaac_'); define('START_TIME', microtime(true)); define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX')); diff --git a/config.php b/config.php index 0d267083..d9f03874 100644 --- a/config.php +++ b/config.php @@ -84,12 +84,23 @@ $config = array( //'2' => 'Your Second World Name' ), + // loot + 'loot_show_percentage' => true, // to true to show tooltip percent + + // links + 'items_url' => 'https://tibia.fandom.com/wiki/', // set to website which shows details about items. + // images 'outfit_images_url' => 'https://outfit-images.ots.me/outfit.php', // set to animoutfit.php for animated outfit 'outfit_images_wrong_looktypes' => [75, 126, 127, 266, 302], // this looktypes needs to have different margin-top and margin-left because they are wrong positioned 'item_images_url' => 'https://item-images.ots.me/1092/', // set to images/items if you host your own items in images folder 'item_images_extension' => '.gif', + // creatures + 'creature_images_url' => 'images/monsters/', // set to images/monsters if you host your own creatures in images folder + 'creature_images_extension' => '.gif', + 'creature_images_preview' => false, // set to true to allow picture previews for creatures + // account 'account_management' => true, // disable if you're using other method to manage users (fe. tfs account manager) 'account_create_auto_login' => false, // auto login after creating account? diff --git a/index.php b/index.php index 56216169..3d7b9e51 100644 --- a/index.php +++ b/index.php @@ -102,6 +102,7 @@ else { '/^changelog\/[0-9]+\/?$/' => array('subtopic' => 'changelog', 'page' => '$1'), '/^commands\/add\/?$/' => array('subtopic' => 'commands', 'action' => 'add'), '/^commands\/edit\/?$/' => array('subtopic' => 'commands', 'action' => 'edit'), + '/^creatures\/[A-Za-z0-9-_%+\']+$/' => array('subtopic' => 'creatures', 'creature' => '$1'), '/^faq\/add\/?$/' => array('subtopic' => 'faq', 'action' => 'add'), '/^faq\/edit\/?$/' => array('subtopic' => 'faq', 'action' => 'edit'), '/^forum\/add_board\/?$/' => array('subtopic' => 'forum', 'action' => 'add_board'),# diff --git a/system/functions.php b/system/functions.php index 4a2e1a81..2437094f 100644 --- a/system/functions.php +++ b/system/functions.php @@ -95,6 +95,16 @@ function getPlayerLink($name, $generate = true) return generateLink($url, $name); } +function getMonsterLink($name, $generate = true) +{ + global $config; + + $url = BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'creatures/' . urlencode($name); + + if(!$generate) return $url; + return generateLink($url, $name); +} + function getHouseLink($name, $generate = true) { global $db, $config; @@ -154,6 +164,23 @@ function getItemImage($id, $count = 1) return '' .$id . ''; } +function getItemRarity($chance) { + if ($chance >= 21) { + return "common"; + } elseif (between($chance, 8, 21)) { + return "uncommon"; + } elseif (between($chance, 1.1, 8)) { + return "semi rare"; + } elseif (between($chance, 0.4, 1.1)) { + return "rare"; + } elseif (between($chance, 0.8, 0.4)) { + return "very rare"; + } elseif ($chance <= 0.8) { + return "extremely rare"; + } + return ''; +} + function getFlagImage($country) { if(!isset($country[0])) @@ -1309,6 +1336,7 @@ function getPlayerNameByAccount($id) return ''; } + function echo_success($message) { echo '
' . $message . '
'; @@ -1357,6 +1385,29 @@ function Outfits_loadfromXML() return array('id' => $looktype, 'type' => $type, 'name' => $lookname, 'premium' => $premium, 'unlocked' => $unlocked, 'enabled' => $enabled); } +function left($str, $length) { + return substr($str, 0, $length); +} + +function right($str, $length) { + return substr($str, -$length); +} + +function getCreatureImgPath($creature){ + $creature_path = config('creature_images_url'); + $creature_gfx_name = trim(strtolower($creature)) . config('creature_images_extension'); + if (!file_exists($creature_path . $creature_gfx_name)) { + $creature_gfx_name = str_replace(" ", "", $creature_gfx_name); + if (file_exists($creature_path . $creature_gfx_name)) { + return $creature_path . $creature_gfx_name; + } else { + return $creature_path . 'nophoto.png'; + } + } else { + return $creature_path . $creature_gfx_name; + } +} + // validator functions require_once LIBS . 'validator.php'; require_once SYSTEM . 'compat.php'; diff --git a/system/libs/creatures.php b/system/libs/creatures.php index 84f934d3..95657a58 100644 --- a/system/libs/creatures.php +++ b/system/libs/creatures.php @@ -79,6 +79,8 @@ class Creatures { //load race $race = $monster->getRace(); + $armor = $monster->getArmor(); + $defensev = $monster->getDefense(); //load monster flags $flags = $monster->getFlags(); @@ -87,6 +89,28 @@ class Creatures { if(!isset($flags['convinceable'])) $flags['convinceable'] = '0'; + if(!isset($flags['pushable'])) + $flags['pushable'] = '0'; + if(!isset($flags['canpushitems'])) + $flags['canpushitems'] = '0'; + if(!isset($flags['canpushcreatures'])) + $flags['canpushcreatures'] = '0'; + if(!isset($flags['runonhealth'])) + $flags['runonhealth'] = '0'; + if(!isset($flags['canwalkonenergy'])) + $flags['canwalkonenergy'] = '0'; + if(!isset($flags['canwalkonpoison'])) + $flags['canwalkonpoison'] = '0'; + if(!isset($flags['canwalkonfire'])) + $flags['canwalkonfire'] = '0'; + if(!isset($flags['hostile'])) + $flags['hostile'] = '0'; + if(!isset($flags['attackable'])) + $flags['attackable'] = '0'; + if(!isset($flags['rewardboss'])) + $flags['rewardboss'] = '0'; + + $summons = $monster->getSummons(); $loot = $monster->getLoot(); foreach($loot as &$item) { if(!Validator::number($item['id'])) { @@ -105,11 +129,25 @@ class Creatures { 'speed_lvl' => $speed_lvl, 'use_haste' => $use_haste, 'voices' => json_encode($monster->getVoices()), - 'immunities' => json_encode($monster->getImmunities()), + 'immunities' => json_encode($monster->getImmunities()), + 'elements' => json_encode($monster->getElements()), 'summonable' => $flags['summonable'] > 0 ? 1 : 0, 'convinceable' => $flags['convinceable'] > 0 ? 1 : 0, + 'pushable' => $flags['pushable'] > 0 ? 1 : 0, + 'canpushitems' => $flags['canpushitems'] > 0 ? 1 : 0, + 'canpushcreatures' => $flags['canpushcreatures'] > 0 ? 1 : 0, + 'runonhealth' => $flags['runonhealth'] > 0 ? 1 : 0, + 'canwalkonenergy' => $flags['canwalkonenergy'] > 0 ? 1 : 0, + 'canwalkonpoison' => $flags['canwalkonpoison'] > 0 ? 1 : 0, + 'canwalkonfire' => $flags['canwalkonfire'] > 0 ? 1 : 0, + 'hostile' => $flags['hostile'] > 0 ? 1 : 0, + 'attackable' => $flags['attackable'] > 0 ? 1 : 0, + 'rewardboss' => $flags['rewardboss'] > 0 ? 1 : 0, + 'defense' => $defensev, + 'armor' => $armor, 'race' => $race, - 'loot' => json_encode($loot) + 'loot' => json_encode($loot), + 'summons' => json_encode($summons) )); if($show) { @@ -136,4 +174,4 @@ class Creatures { public static function getLastError() { return self::$lastError; } -} \ No newline at end of file +} diff --git a/system/libs/pot/OTS_Monster.php b/system/libs/pot/OTS_Monster.php index d498714f..db35091f 100644 --- a/system/libs/pot/OTS_Monster.php +++ b/system/libs/pot/OTS_Monster.php @@ -15,11 +15,11 @@ /** * Wrapper for monsters files DOMDocument. - * + * *

* Note: as this class extends {@link http://www.php.net/manual/en/ref.dom.php DOMDocument class} and contains exacly file XML tree you can work on it as on normal DOM tree. *

- * + * * @package POT * @version 0.1.3 * @property-read string $name Monster name. @@ -44,14 +44,14 @@ class OTS_Monster extends DOMDocument { $this->loaded = parent::loadXML($source, $options); } - + public function loaded() { return $this->loaded; } /** * Returns monster name. - * + * * @return string Name. * @throws DOMException On DOM operation error. */ @@ -62,7 +62,7 @@ class OTS_Monster extends DOMDocument /** * Returns monster race. - * + * * @return string Race. * @throws DOMException On DOM operation error. */ @@ -73,7 +73,7 @@ class OTS_Monster extends DOMDocument /** * Returns amount of experience for killing this monster. - * + * * @return int Experience points. * @throws DOMException On DOM operation error. */ @@ -84,7 +84,7 @@ class OTS_Monster extends DOMDocument /** * Returns monster speed. - * + * * @return int Speed. * @throws DOMException On DOM operation error. */ @@ -95,7 +95,7 @@ class OTS_Monster extends DOMDocument /** * Returns amount of mana required to summon this monster. - * + * * @return int|bool Mana required (false if not possible). * @throws DOMException On DOM operation error. */ @@ -114,7 +114,7 @@ class OTS_Monster extends DOMDocument /** * Returns monster HP. - * + * * @return int Hit points. * @throws DOMException On DOM operation error. */ @@ -125,7 +125,7 @@ class OTS_Monster extends DOMDocument /** * Returns all monster flags (in format flagname => value). - * + * * @return array Flags. * @throws DOMException On DOM operation error. */ @@ -146,7 +146,7 @@ class OTS_Monster extends DOMDocument /** * Returns specified flag value. - * + * * @param string $flag Flag. * @return int|bool Flag value (false if not set). * @throws DOMException On DOM operation error. @@ -169,7 +169,7 @@ class OTS_Monster extends DOMDocument /** * Returns voices that monster can sound. - * + * * @return array List of voices. * @throws DOMException On DOM operation error. */ @@ -214,17 +214,17 @@ class OTS_Monster extends DOMDocument $chance = 100000; } } - + $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); } } @@ -234,11 +234,11 @@ class OTS_Monster extends DOMDocument /** * Returns all possible loot. - * + * *

* In order to use this method you have to have global items list loaded. *

- * + * * @version 0.1.0 * @since 0.1.0 * @return array List of item types. @@ -273,9 +273,95 @@ class OTS_Monster extends DOMDocument return $loot; } +/** + * Returns all monster summons. + * + * @return array elements. + * @throws DOMException On DOM operation error. + */ + + public function getSummons() + { + $summons = array(); + + $element = $this->documentElement->getElementsByTagName('summons')->item(0); + + // checks if it has any Summons + if( isset($element) ) + { + // adds all summons + foreach( $element->getElementsByTagName('summon') as $item) + { + $chance = $item->getAttribute('chance'); + $id = $item->getAttribute('name'); + $summons[] = array('name' => $id, 'chance' => $chance); + } + } + return $summons; + } + +/** + * Returns all monster elements. + * + * @return array elements. + * @throws DOMException On DOM operation error. + */ + public function getElements() + { + $elements = array(); + + $element = $this->documentElement->getElementsByTagName('elements')->item(0); + + // checks if it has any elements + if( isset($element) ) + { + // read all elements + foreach( $element->getElementsByTagName('element') as $elementv) + { + $elementv = $elementv->attributes->item(0); + + // checks if element is set + if($elementv->nodeValue > 0) + { + $elements[] = array('name' => ucfirst(str_replace('Percent', '', $elementv->nodeName)), 'percent' => $elementv->nodeValue); + } + } + } + + return $elements; + } + +/** + * Checks if monster has given element. + * + * @param string $name element to check. + * @return bool element state. + * @throws DOMException On DOM operation error. + */ + public function hasElement($name) + { + $element = $this->documentElement->getElementsByTagName('elements')->item(0); + + // if doesn't have any elements obviously doesn't have this one too + if( isset($element) ) + { + // read all elements + foreach( $element->getElementsByTagName('element') as $element) + { + // checks if this is what we are searching for + if( $element->hasAttribute($name) ) + { + return $element->getAttribute($name) > 0; + } + } + } + + return false; + } + /** * Returns all monster immunities. - * + * * @return array Immunities. * @throws DOMException On DOM operation error. */ @@ -306,7 +392,7 @@ class OTS_Monster extends DOMDocument /** * Checks if monster has given immunity. - * + * * @param string $name Immunity to check. * @return bool Immunity state. * @throws DOMException On DOM operation error. @@ -334,7 +420,7 @@ class OTS_Monster extends DOMDocument /** * Returns monster defense rate. - * + * * @return int Defense rate. * @throws DOMException On DOM operation error. */ @@ -353,7 +439,7 @@ class OTS_Monster extends DOMDocument /** * Returns monster armor. - * + * * @return int Armor rate. * @throws DOMException On DOM operation error. */ @@ -372,7 +458,7 @@ class OTS_Monster extends DOMDocument /** * Returns list of special defenses. - * + * * @return array List of defense effects. * @throws DOMException On DOM operation error. */ @@ -396,7 +482,7 @@ class OTS_Monster extends DOMDocument /** * Returns list of monster attacks. - * + * * @return array List of attafck effects. * @throws DOMException On DOM operation error. */ @@ -420,7 +506,7 @@ class OTS_Monster extends DOMDocument /** * Magic PHP5 method. - * + * * @version 0.1.0 * @since 0.1.0 * @param string $name Property name. @@ -481,11 +567,11 @@ class OTS_Monster extends DOMDocument /** * Returns string representation of XML. - * + * *

* If any display driver is currently loaded then it uses it's method. Otherwise just returns monster XML content. *

- * + * * @version 0.1.3 * @since 0.1.0 * @return string String representation of object. diff --git a/system/migrations/31.php b/system/migrations/31.php new file mode 100644 index 00000000..b51e7421 --- /dev/null +++ b/system/migrations/31.php @@ -0,0 +1,18 @@ +hasColumn(TABLE_PREFIX . 'monsters', 'elements')) { + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `elements` TEXT NOT NULL DEFAULT '' AFTER `immunities`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `pushable` TINYINT(1) NOT NULL DEFAULT '0' AFTER `convinceable`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `canpushitems` TINYINT(1) NOT NULL DEFAULT '0' AFTER `pushable`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `canpushcreatures` TINYINT(1) NOT NULL DEFAULT '0' AFTER `canpushitems`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `canwalkonenergy` TINYINT(1) NOT NULL DEFAULT '0' AFTER `canpushitems`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `canwalkonpoison` TINYINT(1) NOT NULL DEFAULT '0' AFTER `canwalkonenergy`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `canwalkonfire` TINYINT(1) NOT NULL DEFAULT '0' AFTER `canwalkonpoison`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `runonhealth` TINYINT(1) NOT NULL DEFAULT '0' AFTER `canwalkonfire`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `hostile` TINYINT(1) NOT NULL DEFAULT '0' AFTER `runonhealth`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `attackable` TINYINT(1) NOT NULL DEFAULT '0' AFTER `hostile`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `rewardboss` TINYINT(1) NOT NULL DEFAULT '0' AFTER `attackable`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `defense` INT(11) NOT NULL DEFAULT '0' AFTER `rewardboss`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `armor` INT(11) NOT NULL DEFAULT '0' AFTER `defense`;"); + $db->exec("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `summons` TEXT NOT NULL DEFAULT '' AFTER `loot`;"); +} diff --git a/system/pages/creatures.php b/system/pages/creatures.php index dc8b4514..3560ecc2 100644 --- a/system/pages/creatures.php +++ b/system/pages/creatures.php @@ -5,149 +5,71 @@ * @package MyAAC * @author Gesior * @author Slawkens - * @copyright 2019 MyAAC + * @author Lee + * @copyright 2020 MyAAC * @link https://my-aac.org */ defined('MYAAC') or die('Direct access not allowed!'); $title = "Creatures"; -?> - - - - - - -query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 ORDER BY name asc'); - echo ' - - -'; - - foreach ($monsters as $monster) { - echo ' - - - - - '; - } - echo '
NameHealthExperienceSummonable ManaConvinceable ManaRace
' . $monster['name'] . '' . $monster['health'] . '' . $monster['exp'] . '' . ($monster['summonable'] ? $monster['mana'] : "---") . '' . ($monster['convinceable'] ? $monster['mana'] : "---") . '' . ucwords($monster['race']) . '
'; + $creatures = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 '.(empty($_REQUEST['boss']) ? '': 'AND `rewardboss` = 1').' ORDER BY name asc'); + $twig->display('creatures.html.twig', array( + 'creatures' => $creatures->fetchAll(), + 'preview' => config('creature_images_preview'), + )); } else { - $monster_name = stripslashes(trim(ucwords($_REQUEST['creature']))); - $monster = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 AND `name` = ' . $db->quote($monster_name) . ';')->fetch(); - if (isset($monster['name'])) { - $title = $monster['name'] . " - Creatures"; + $creature_name = urldecode(stripslashes(ucwords(strtolower($_REQUEST['creature'])))); + $prep = $db->prepare('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 AND `name` = ? LIMIT 1;'); + $prep->execute([$creature_name]); + $creature = $prep->fetch(); - echo '

' . $monster['name'] . '

'; - echo ''; - - $loot = json_decode($monster['loot'], true); - if ($loot) { - echo '
- '; - $number_of_rows = 0; - echo ''; - $number_of_rows++; - echo ''; - $number_of_rows++; - echo ''; - - $number_of_rows++; - if ($monster['summonable'] == 1) - echo ''; - else { - echo ''; - } - - $number_of_rows++; - if ($monster['convinceable'] == 1) - echo ''; - else - echo ''; - - echo '
Health: ' . $monster['health'] . '
Experience: ' . $monster['exp'] . '
Speed like: ' . $monster['speed_lvl'] . ' level'; - $number_of_rows++; - if ($monster['use_haste']) - echo ' (Can use haste)'; - - echo '
Summon: ' . $monster['mana'] . ' mana
Summon: Impossible
Convince: ' . $monster['mana'] . ' mana
Convince: Impossible
- - -
'; - $monster['gfx_name'] = trim(strtolower($monster['name'])) . ".gif"; - if (!file_exists('images/monsters/' . $monster['gfx_name'])) { - $gfx_name = str_replace(" ", "", $monster['gfx_name']); - if (file_exists('images/monsters/' . $gfx_name)) - echo ''; - else - echo ''; - } else - echo ''; - - echo '
- '; - $immunities = json_decode($monster['immunities'], true); - if (count($immunities) > 0) { - $number_of_rows++; - echo ''; - } - - $voices = json_decode($monster['voices'], true); - if (count($voices) > 0) { - foreach ($voices as &$voice) { - $voice = '"' . $voice . '"'; + if (isset($creature['name'])) { + function sort_by_chance($a, $b) + { + if ($a['chance'] == $b['chance']) { + return 0; } - - $number_of_rows++; - echo ''; - } - echo '
Immunities: ' . implode(', ', $immunities) . '
Voices: ' . implode(', ', $voices) . '
'; - 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 . '
Chance: ' . round($item['chance'] / 1000, 2) . '%
Max count: ' . $item['count']; - - echo ' ' . $name . ''; - $i++; - } - - echo '
'; + return ($a['chance'] > $b['chance']) ? -1 : 1; } - echo ''; - echo ''; + $title = $creature['name'] . " - Creatures"; + + $creature['img_link']= getCreatureImgPath($creature_name); + + $voices = json_decode($creature['voices'], true); + $summons = json_decode($creature['summons'], true); + $elements = json_decode($creature['elements'], true); + $immunities = json_decode($creature['immunities'], true); + $loot = json_decode($creature['loot'], true); + usort($loot, 'sort_by_chance'); + + $loot_list = []; + foreach ($loot as $item) { + $item['name'] = getItemNameById($item['id']); + $item['rarity_chance'] = round($item['chance'] / 1000, 2); + $item['rarity'] = getItemRarity($item['chance']); + $item['tooltip'] = ucfirst($item['name']) . '
Chance: ' . $item['rarity'] . (config('loot_show_percentage') ? ' ('. $item['rarity_chance'] .'%)' : '') . '
Max count: ' . $item['count']; + $loot_list[] = $item; + } + + $creature['loot'] = isset($loot_list) ? $loot_list : null; + $creature['voices'] = isset($voices) ? $voices : null; + $creature['summons'] = isset($summons) ? $summons : null; + $creature['elements'] = isset($elements) ? $elements : null; + $creature['immunities'] = isset($immunities) ? $immunities : null; + + $twig->display('creature.html.twig', array( + 'creature' => $creature, + )); + } else { - echo "Monster with name " . $monster_name . " doesn't exist."; + echo "Creature with name " . $creature_name . " doesn't exist."; } //back button $twig->display('creatures.back_button.html.twig'); } ?> - - - diff --git a/system/templates/creature.html.twig b/system/templates/creature.html.twig new file mode 100644 index 00000000..21b1fb4a --- /dev/null +++ b/system/templates/creature.html.twig @@ -0,0 +1,164 @@ + + + + + + +
{{ creature.name }}
+ + + + + + + + + + + + + + +
General information
+
+
+ Health: {{ creature.health }}
+ Experience: {{ creature.exp }}
+ Speed: {{ creature.speed_lvl }} {{ (creature.use_haste) ? ' (+haste)' : '' }} +
+ Summonable: {{ (creature.summonable) ? creature.mana ~ ' mana' : 'Impossible' }}
+ Convinceable: {{ (creature.convinceable) ? creature.mana ~ ' mana' : 'Impossible' }} +
+ Armor: {{ creature.armor }}
+ Defense: {{ creature.defense }} +

+ +{% if ( creature.voices is not empty or creature.summons is not empty) %} + + + + {% if ( creature.summons is not empty) %} + + {% endif %} + {% if ( creature.voices is not empty) %} + + {% endif %} + + + + + {% if ( creature.summons is not empty) %} + + {% endif %} + {% if ( creature.voices is not empty) %} + + {% endif %} + + +
SummonsVoices
+ {% for summon in creature.summons %} + {{ summon.chance }}% chance to summon a {{ getMonsterLink(summon.name, true)|raw }}
+ {% endfor %} +
+ + {% for voice in creature.voices %} + "{{ voice }}"
+ {% endfor %} +
+

+{% endif %} + +{% if (creature.elements|length > 0 or creature.immunities|length > 0 ) %} + + + + + {% if (creature.elements|length > 0) %} + {% for element in creature.elements %} + + {% endfor %} + {% endif %} + {% if (creature.immunities|length > 0 ) %} + + + + {% endif %} +
Elements and Immunities
{{ element.name }}
{{ element.percent }}%
Immunities: {{ creature.immunities|join(' | ') }}

+{% endif %} + +{% if (not creature.loot is empty) %} + + + + + +
Loot
+ {% for item in creature.loot %} + + {% if (item.count > 1) %} + {{ item.count }} + {% endif %} + + + {% endfor %} +
+{% endif %} diff --git a/system/templates/creatures.html.twig b/system/templates/creatures.html.twig new file mode 100644 index 00000000..b99e4c3d --- /dev/null +++ b/system/templates/creatures.html.twig @@ -0,0 +1,97 @@ +{% if creatures is not empty %} + + {% if preview %} + + +
+
+
+ {% for creature in creatures %} + {% set i = i + 1 %} +
+ +
+ +
+
{{ creature.name }}
+
+ {% endfor %} +
+
+ {% else %} + + {{ generateLink('?creatures', 'All', false)|raw }} - Bosses +
+ + + + + + + + + + + + + + {% set i = 0 %} + {% for creature in creatures %} + {% set i = i + 1 %} + + + + + + + + + + {% endfor %} + +
NameBossHealthExperienceSummonable ManaConvinceable ManaRace
{{ getMonsterLink(creature.name, true)|raw }}{{ (creature.rewardboss) ? 'Yes' : '---' }}{{ creature.health|number_format(0, '.', ',') }}{{ creature.exp|number_format(0, '.', ',') }}{{ (creature.convinceable) ? creature.mana : '---' }} {{ (creature.summonable) ? creature.mana : '---' }} {{ creature.race|title }}
+ {% endif %} + +{% else %} + + + + + + + +
Creatures
No Creatures on the server.
+{% endif %} + diff --git a/system/twig.php b/system/twig.php index 9ab2e509..3a258843 100644 --- a/system/twig.php +++ b/system/twig.php @@ -24,16 +24,31 @@ $function = new TwigFunction('getStyle', function ($i) { }); $twig->addFunction($function); +$function = new TwigFunction('getCreatureImgPath', function ($i) { + return getCreatureImgPath($i); +}); +$twig->addFunction($function); + $function = new TwigFunction('getLink', function ($s) { return getLink($s); }); $twig->addFunction($function); +$function = new TwigFunction('generateLink', function ($s, $n, $b = false) { + return generateLink($s, $n, $b); +}); +$twig->addFunction($function); + $function = new TwigFunction('getPlayerLink', function ($s, $p) { return getPlayerLink($s, $p); }); $twig->addFunction($function); +$function = new TwigFunction('getMonsterLink', function ($s, $p) { + return getMonsterLink($s, $p); +}); +$twig->addFunction($function); + $function = new TwigFunction('getGuildLink', function ($s, $p) { return getGuildLink($s, $p); });