Monster_Info_Page.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. require_once($path["page"] . "Page.php");
  3. require_once($path["entity"] . "K_Unit.php");
  4. /**
  5. * Monster details page.
  6. */
  7. class Monster_Info_Page extends Page{
  8. /**
  9. * Selected @{see K_Unit} array.
  10. * [0]: Unawakened monster (null if default purple).
  11. * [1]: Awakened monster (null if silver).
  12. * [2]: Second awakened monster (null if unavailaable).
  13. */
  14. public $monster = [];
  15. /**
  16. * IDs to other monsters of the family
  17. */
  18. public $family = [];
  19. /**
  20. * Constructor.
  21. *
  22. * Retrieves the data and initializes the variables.
  23. *
  24. * @param SQLite3 $db Connection to the database.
  25. * @param string $id Monster id. Can be any of the awakening stages
  26. */
  27. public function __construct($db, $id){
  28. global $path;
  29. global $root;
  30. parent::__construct($db);
  31. $this->view = $path["view"] . "monster_info.php";
  32. $title = "";
  33. $monster = new K_Unit($db, $id);
  34. if ($monster->can_awaken == 0){
  35. // Silver star monster.
  36. $this->monster[0] = $monster;
  37. $this->monster[1] = null;
  38. $this->monster[2] = null;
  39. $title = $this->monster[0]->element_name . " " . $this->monster[0]->name;
  40. }
  41. elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && $monster->awakens_from == ""){
  42. // Default purple (Rainbowmon or King Angelmon)
  43. $this->monster[0] = null;
  44. $this->monster[1] = $monster;
  45. $this->monster[2] = null;
  46. $title = $this->monster[1]->name;
  47. }
  48. elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && strlen($monster->awakens_from) > 0){
  49. // Normal monster, already awakened, no 2a.
  50. $this->monster[0] = new K_Unit($db, $monster->awakens_from);
  51. $this->monster[1] = $monster;
  52. $this->monster[2] = null;
  53. $title = $this->monster[1]->name . " - " .$this->monster[0]->element_name . " " . $this->monster[0]->name;
  54. $monster = $this->monster[0];
  55. }
  56. elseif ($monster->can_awaken == 1 && strlen($monster->awakens_to) > 0 && $monster->awakens_from == ""){
  57. // Normal monster, not awakened, may have 2a.
  58. $this->monster[0] = $monster;
  59. $this->monster[1] = new K_Unit($db, $this->monster[0]->awakens_to);
  60. if ($this->monster[1]->awakens_to == ""){
  61. $this->monster[2] = null;
  62. }
  63. else{
  64. $this->monster[2] = new K_Unit($db, $this->monster[1]->awakens_to);
  65. }
  66. $title = $this->monster[1]->name . " - " .$this->monster[0]->element_name . " " . $this->monster[0]->name;
  67. }
  68. // TODO REWORK
  69. /*$s = "
  70. SELECT
  71. id,
  72. element
  73. FROM k_unit
  74. WHERE
  75. family = " . $monster->family . " AND
  76. base_stars
  77. element <> " . $monster->element . ";
  78. ";
  79. $q_mon = $this->db->query($s);
  80. while ($r = $q_mon->fetchArray(SQLITE3_ASSOC)){
  81. $this->family[$r["element"]] = $r["id"];
  82. }*/
  83. $this->title = $title ." - SWDB";
  84. $this->description = $title . " info - SWDB";
  85. $this->canonical = $root . "monster_info/" . $id;
  86. }
  87. }
  88. ?>