* @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3 * @package SWDB */ require_once(PATH::ENTITY . "Entity.php"); /** * Monster source. * * Represesnts a source where a monster can be obtained. * * @category Entity */ class Source extends Entity{ /** * @var int Source identifier. */ private $id; /** * @var string Source name. */ private $name; /** * @var string Source description. */ private $description; /** * @var bool Indicates if the source is farmable. */ private $farmable; /** * Constructor. * * Searches the database and retrieves the information about the * source, populating it and it's items. * * @param int $id Surce identifier. */ public function __construct($id){ $statement = get_context()->get_db()->prepare(" SELECT id, name, description, farmable FROM source WHERE id = :id; "); $statement->bindValue(':id', $id, SQLITE3_TEXT); $r = $statement->execute()->fetchArray(SQLITE3_ASSOC); if ($r){ $this->id = $r["id"]; $this->name = HTML::e($r["name"]); $this->description = HTML::e($r["description"]); $this->farmable = filter_var($r["farmable"], FILTER_VALIDATE_BOOLEAN); } } /** * Retrieves the source identifier. * * @return int Source ID. */ public function get_id(){ return $this->id; } /** * Retrieves the source name. * * @return string Source name. */ public function get_name(){ return $this->name; } /** * Retrieves the source description. * * @return string Source description. */ public function get_description(){ return $this->description; } /** * Checks if the osurce is farmable. * * @return bool True if the source is farmable, false otherwise. */ public function is_farmable(){ return $this->farmable; } /** * Gets the path to the source image. * * @return string Image URL, or a fixed unknown image. */ public function get_image(){ return APPLICATION::img("SOURCE", $this->id); } }