Collection_Portrait_Frame.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. require_once($path["frame"] . "Frame.php");
  3. require_once($path["entity"] . "Monster_Collection.php");
  4. /**
  5. * Collection page model.
  6. */
  7. class Collection_Portrait_Frame extends Frame{
  8. public $id;
  9. public $cur_name;
  10. public $name;
  11. public $name_aw;
  12. public $stars;
  13. public $default_stars;
  14. public $level;
  15. public $max_level;
  16. public $awaken;
  17. public $cur_img;
  18. public $img;
  19. public $img_aw;
  20. public $img_star;
  21. public $element;
  22. public $owned;
  23. /**
  24. * Owned {@see Monster_Collection} of owned monsters.
  25. */
  26. public $collection;
  27. /**
  28. * Constructor.
  29. *
  30. * Retrieves the data and initializes the variables.
  31. *
  32. * @param MySQL_connection $db Connection to the database.
  33. * @param Array $params Parameters array, containig at least 'id'.
  34. */
  35. public function __construct($db, $params){
  36. global $path;
  37. parent::__construct($db);
  38. $this->view = $path["view"] . "frame/portrait.php";
  39. $id = $params["id"];
  40. $s =
  41. "SELECT id " .
  42. "FROM monster_collection " .
  43. "WHERE id = " . $id . "; ";
  44. $q = mysqli_query($this->db, $s);
  45. if (mysqli_num_rows($q) > 0){
  46. $r = mysqli_fetch_array($q);
  47. $this->collection = new Monster_Collection($this->db, $r["id"]);
  48. $this->id = $id;
  49. $this->name = $this->collection->monster->name;
  50. $this->name_aw = $this->collection->monster->name_aw;
  51. $this->stars = $this->collection->stars;
  52. $this->default_stars = $this->collection->monster->stars;
  53. $this->level = $this->collection->level;
  54. $this->max_level = 10 + (5 * $this->stars);
  55. $this->awaken = $this->collection->awaken;
  56. $this->img = $this->collection->monster->image;
  57. $this->img_aw = $this->collection->monster->image_aw;
  58. $this->element = $this->collection->monster->element;
  59. if ($this->level == 0 || $this->stars == 0){
  60. $this->owned = false;
  61. }
  62. if ($this->awaken == 1){
  63. $this->cur_name = $this->name_aw;
  64. $this->cur_img = $this->img_aw;
  65. $this->img_star = $star_src = $path["img"]["layout"] . "icon/star_aw.png";
  66. }
  67. else{
  68. $this->cur_name = $this->element . " " . $this->name;
  69. $this->cur_img = $this->img;
  70. $this->img_star = $star_src = $path["img"]["layout"] . "icon/star.png";
  71. }
  72. }
  73. }
  74. }
  75. ?>