protected function weaponList($subtype) { $db = \ElementDatabase::GetInstance(); $weapons = $db->select(array("table" => "weapon_items", "where" => array("id_sub_type" => $subtype, "name" => array("", false)), "orderBy" => array("require_level", "name"))); $list = array(); foreach ($weapons as $weapon) { $list[] = Models\WeaponTemplate::getByRow($weapon, true); } return new \Json($list); }
protected function item() { if (func_num_args() != 1) { return $this->itemList(); } $id = func_get_arg(0); $db = \ElementDatabase::GetInstance(); if ($item = $db->getById("weapon_items", $id)) { $weapon = Models\WeaponTemplate::getByRow($item); return $this->view($weapon, "weapon", $weapon->name); } else { return new \NotFoundResponse(); } }