| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <?php
- require_once($path["frame"] . "Frame.php");
- require_once($path["entity"] . "Monster_Collection.php");
- /**
- * Collection page model.
- */
- class Collection_Portrait_Frame extends Frame{
- public $id;
- public $cur_name;
- public $name;
- public $name_aw;
- public $stars;
- public $default_stars;
- public $level;
- public $max_level;
- public $awaken;
- public $cur_img;
- public $img;
- public $img_aw;
- public $img_star;
- public $element;
- public $owned;
- public $skill;
- public $hp = 0;
- public $atk = 0;
- public $def = 0;
- public $spd = 0;
- public $crir = 0;
- public $crid = 0;
- public $res = 0;
- public $acc = 0;
- /**
- * Owned {@see Monster_Collection} of owned monsters.
- */
- public $collection;
- /**
- * 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/portrait.php";
- $id = $params["id"];
- $s =
- "SELECT id " .
- "FROM monster_collection " .
- "WHERE id = " . $id . "; ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->collection = new Monster_Collection($this->db, $r["id"]);
- $this->id = $id;
- $this->name = $this->collection->monster->name;
- $this->name_aw = $this->collection->monster->name_aw;
- $this->stars = $this->collection->stars;
- $this->default_stars = $this->collection->monster->stars;
- $this->skill = $this->collection->monster->skill;
- $this->level = $this->collection->level;
- $this->max_level = 10 + (5 * $this->stars);
- $this->awaken = $this->collection->awaken;
- $this->img = $this->collection->monster->image;
- $this->img_aw = $this->collection->monster->image_aw;
- $this->element = $this->collection->monster->element;
- if ($this->level == 0 || $this->stars == 0){
- $this->owned = false;
- }
- if ($this->awaken == 1){
- $this->cur_name = $this->name_aw;
- $this->cur_img = $this->img_aw;
- $this->img_star = $star_src = $path["img"]["layout"] . "icon/star_aw.png";
- }
- else{
- $this->cur_name = $this->element . " " . $this->name;
- $this->cur_img = $this->img;
- $this->img_star = $star_src = $path["img"]["layout"] . "icon/star.png";
- }
- // Get stats
- $l = $this->level;
- $t = $this->stars;
- $i = $this->collection->monster->id;
- $w = $this->awaken;
- $s =
- "SELECT min + (((max - min) / ((stars + 2) * 5)) * ($l + $l / ((stars + 2) * 5))) AS stat " .
- "FROM monster_stat " .
- "WHERE " .
- " monster = $i AND " .
- " stars = $t AND " .
- " awake = $w AND " .
- " stat = 'HP'; ";
- error_log($s);
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->hp = $r["stat"];
- }
- $s =
- "SELECT min + (((max - min) / ((stars + 2) * 5)) * ($l + $l / ((stars + 2) * 5))) AS stat " .
- "FROM monster_stat " .
- "WHERE " .
- " monster = $i AND " .
- " stars = $t AND " .
- " awake = $w AND " .
- " stat = 'ATK'; ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->atk = $r["stat"];
- }
- $s =
- "SELECT min + (((max - min) / ((stars + 2) * 5)) * ($l + $l / ((stars + 2) * 5))) AS stat " .
- "FROM monster_stat " .
- "WHERE " .
- " monster = $i AND " .
- " stars = $t AND " .
- " awake = $w AND " .
- " stat = 'DEF'; ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->def = $r["stat"];
- }
- $s =
- "SELECT min AS stat " .
- "FROM monster_stat " .
- "WHERE " .
- " monster = $i AND " .
- " stars = $t AND " .
- " awake = $w AND " .
- " stat = 'SPD'; ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->spd = $r["stat"];
- }
- $s =
- "SELECT min AS stat " .
- "FROM monster_stat " .
- "WHERE " .
- " monster = $i AND " .
- " stars = $t AND " .
- " awake = $w AND " .
- " stat = 'CRIR'; ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->crir = $r["stat"];
- }
- $s =
- "SELECT min AS stat " .
- "FROM monster_stat " .
- "WHERE " .
- " monster = $i AND " .
- " stars = $t AND " .
- " awake = $w AND " .
- " stat = 'CRID'; ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->crid = $r["stat"];
- }
- $s =
- "SELECT min AS stat " .
- "FROM monster_stat " .
- "WHERE " .
- " monster = $i AND " .
- " stars = $t AND " .
- " awake = $w AND " .
- " stat = 'RES'; ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->res = $r["stat"];
- }
- $s =
- "SELECT min AS stat " .
- "FROM monster_stat " .
- "WHERE " .
- " monster = $i AND " .
- " stars = $t AND " .
- " awake = $w AND " .
- " stat = 'ACC'; ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->acc = $r["stat"];
- }
- }
- }
- }
- ?>
|