<?php

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

    /**
     * Guild skill.
     *
     * Represents an object from the table 'k_guild_skill'.
     */
    class K_Guild_Skill extends Entity{

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

        /**
         * Skill group (id).
         */
        public $group;

        /**
         * Level at which the skill becames available.
         */
        public $level;

        /**
         * Skill description.
         */
        public $effect;

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

    }
?>
