From 80e2bc42c69d9f70f1a78b064c539a76290ebe8c Mon Sep 17 00:00:00 2001 From: Cydh Ramdh Date: Wed, 20 Jun 2018 11:49:14 +0700 Subject: [PATCH] Moved card0 check to config & Flux lib * Fixed #190 * The card0 values are defined in config file (application.php) in `ItemSpecial`. By default, using rAthena's card0 values. * The usage will be `Flux::itemIsSpecial($item)`. Returns `true` if item's card0 is special, `false` otherwise * For control checking (ifs) for item is forged * `if ($item->card0 == $this->itemIsForged)` * `if ($item->card0 == $this->itemIsCreation)` * `if ($item->card0 == $this->itemIsPetEgg)` --- config/application.php | 7 +++++++ lib/Flux.php | 14 ++++++++++++++ lib/Flux/Template.php | 20 ++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/config/application.php b/config/application.php index 6ab595e1..fb72cf31 100644 --- a/config/application.php +++ b/config/application.php @@ -407,6 +407,13 @@ array('module' => 'guild', 'action' => 'emblem') ), + // Card0 special flag. Older rAthena the values are 254,255,-256 + 'ItemSpecial' => array( + 'forge' => 0x00FF, + 'create' => 0x00FE, + 'pet' => 0x0100, + ), + // Job classes, loaded from another file to avoid cluttering this one. // There isn't normally a need to modify this file, unless it's been // modified in an update. (In English: DON'T TOUCH THIS.) diff --git a/lib/Flux.php b/lib/Flux.php index 329dc1b3..f1eb75c6 100644 --- a/lib/Flux.php +++ b/lib/Flux.php @@ -934,5 +934,19 @@ public static function monsterSizeName($size) $size = Flux::config("MonsterSizes.$size"); return $size; } + + /** + * Check if item is special + * @param $item Item object fetched from table + * @return True if item's card0 is special, false otherwise + */ + public static function itemIsSpecial($item) { + $special = Flux::config('ItemSpecial'); + if (!$special) + return false; + if ($item->card0 && ($item->card0 == $special->get('forge') || $item->card0 == $special->get('create') || $item->card0 == $special->get('pet'))) + return true; + return false; + } } ?> diff --git a/lib/Flux/Template.php b/lib/Flux/Template.php index fadfd78b..a3324bf4 100644 --- a/lib/Flux/Template.php +++ b/lib/Flux/Template.php @@ -165,6 +165,21 @@ class Flux_Template { protected $urlWithQs; protected $urlWithQS; // compatibility. + /** + * CARD0_FORGE value for checking + */ + protected $itemIsForged; + + /** + * CARD0_CREATE value for checking + */ + protected $itemIsCreation; + + /** + * CARD0_PET value for checking + */ + protected $itemIsPetEgg; + /** * Module/action for missing action's event. * @@ -228,6 +243,11 @@ public function __construct(Flux_Config $config) $this->missingViewModuleAction = $config->get('missingViewModuleAction', false); $this->referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; + $special = Flux::config('ItemSpecial'); + $this->itemIsForged = $special->get('forge'); + $this->itemIsCreation = $special->get('create'); + $this->itemIsPetEgg = $special->get('pet'); + // Read manifest file if exists if (file_exists($this->themePath.'/'.$this->themeName.'/manifest.php')) { $manifest = include($this->themePath.'/'.$this->themeName.'/manifest.php');