| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- require_once($path["frame"] . "Frame.php");
- require_once($path["entity"] . "Monster.php");
- /**
- * Monster catalog page.
- */
- class Catalog_Catalog_Frame extends Frame{
- /**
- * Selected {@see Monster}.
- */
- public $monster;
- public $id;
- public $name;
- public $name_aw;
- public $stars;
- public $awakeable;
- public $cur_img;
- public $img;
- public $img_aw;
- public $img_star;
- public $element;
- public $owned;
- public $skill;
- public $stat = [];
- public $stat_aw = [];
- public $location = [];
- public $essence = [];
- /**
- * Constructor.
- *
- * Retrieves the data and initializes the variables.
- *
- * @param SQLite3 $db Connection to the database.
- * @param Array $params Parameters array, containig at least 'id'.
- */
- public function __construct($db, $params){
- global $path;
- parent::__construct($db);
- $this->view = $path["view"] . "frame/catalog.php";
- $id = $params["id"];
- $s =
- "SELECT id, " .
- " ( " .
- " SELECT count(id) > 0 " .
- " FROM monster_collection " .
- " WHERE monster = monster.id " .
- " ) AS owned " .
- "FROM monster " .
- "WHERE id = " . $id . "; ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->monster = new Monster($this->db, $r["id"]);
- $this->id = $id;
- $this->name = $this->monster->name;
- $this->name_aw = $this->monster->name_aw;
- $this->stars = $this->monster->stars;
- $this->awakeable = $this->monster->awakeable;
- $this->skill = $this->monster->skill;
- $this->img = $this->monster->image;
- $this->img_aw = $this->monster->image_aw;
- $this->element = $this->monster->element;
- $this->owned = $r["owned"];
- }
- $s =
- "SELECT DISTINCT stars " .
- "FROM monster_stat " .
- "WHERE monster = " . $id . " " .
- "ORDER BY stars; ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- //error_log(" LOOP 1");
- $st = [
- "STARS" => $r["stars"],
- "HP" => [
- "MIN" => 0,
- "MAX" => 0,
- ],
- "ATK" => [
- "MIN" => 0,
- "MAX" => 0,
- ],
- "DEF" => [
- "MIN" => 0,
- "MAX" => 0,
- ],
- "SPD" => 0,
- "CRID" => 0,
- "CRIR" => 0,
- "RES" => 0,
- "ACC" => 0,
- ];
- $ss =
- "SELECT * " .
- "FROM monster_stat " .
- "WHERE " .
- " monster = " . $id . " AND " .
- " stars = " . $r["stars"] . " AND " .
- " awake = 0; ";
- $qq = $this->db->query($ss);
- while ($rr = $qq->fetchArray(SQLITE3_ASSOC)){
- error_log(" LOOP 2");
- if ($rr["stat"] == "HP" || $rr["stat"] == "ATK" || $rr["stat"] == "DEF"){
- $st[$rr["stat"]]["MAX"] = $rr["max"];
- $st[$rr["stat"]]["MIN"] = $rr["min"];
- }
- else{
- $st[$rr["stat"]] = $rr["min"];
- }
- }
- array_push($this->stat, $st);
- $ss =
- "SELECT * " .
- "FROM monster_stat " .
- "WHERE " .
- " monster = " . $id . " AND " .
- " stars = " . $r["stars"] . " AND " .
- " awake = 1; ";
- $qq = $this->db->query($ss);
- $rr = $qq->fetchArray(SQLITE3_ASSOC);
- while ($rr = $qq->fetchArray(SQLITE3_ASSOC)){
- if ($rr["stat"] == "HP" || $rr["stat"] == "ATK" || $rr["stat"] == "DEF"){
- $st[$rr["stat"]]["MAX"] = $rr["max"];
- $st[$rr["stat"]]["MIN"] = $rr["min"];
- }
- else{
- $st[$rr["stat"]] = $rr["min"];
- }
- }
- array_push($this->stat_aw, $st);
- }
- $s =
- "SELECT location " .
- "FROM monster_location " .
- "WHERE monster = " . $id . " ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->location, $r["location"]);
- }
- $s =
- "SELECT " .
- " element, " .
- " grade, " .
- " num " .
- "FROM monster_essence " .
- "WHERE monster = " . $id . " ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- $e = [
- "IMAGE" => $path["img"]["content"] . "essence/" . $r["element"] . "_" . $r["grade"] . ".png",
- "ELEMENT" => $r["element"],
- "GRADE" => $r["grade"],
- "NUM" => $r["num"],
- ];
- array_push($this->essence, $e);
- }
- }
- }
- ?>
|