<?php

    require_once($path["entity"] . "Entity.php");

    /**
     * Monster skill level.
     *
     * Represents an object from the table 'k_monster_skill_upgrade'.
     */
    class K_Skill_Level extends Entity{

        /**
         * Skill identifier.
         */
        public $skill;

        /**
         * Skill level.
         */
        public $level;

        /**
         * Upgrade description.
         */
        public $description;

        /**
         * Constructor.
         *
         * Searches the database and retrieves the information about the
         * skill level, populating it and it's items.
         *
         * @param SQLite3 $db Connection to the database.
         * @param int $skill Skill identifier.
         * @param int $level Skill level.
         */
        public function __construct($db, $skill, $level){
            global $path;
            parent::__construct($db);
            $s =
              "SELECT " .
              "  skill, " .
              "  level, " .
              "  description " .
              "FROM k_skill_level " .
              "WHERE " .
              "  skill = $skill AND " .
              "  level = $level;";
            $q = $this->db->query($s);
            $r = $q->fetchArray(SQLITE3_ASSOC);
            if ($r){
                $this->skill = $r["skill"];
                $this->level = $r["level"];
                $this->description = $r["description"];
            }
        }
    }
?>
