Monster_Info_Page.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Monster details page file.
  4. *
  5. * Provides a class with all the properties and methods to display the page.
  6. *
  7. * @category Page
  8. */
  9. /**
  10. * Require dependent files if not present.
  11. */
  12. require_once(PATH::PAGE . "Page.php");
  13. require_once(PATH::ENTITY . "K_Unit.php");
  14. /**
  15. * Monster details page model.
  16. *
  17. * @category Page
  18. */
  19. class Monster_Info_Page extends Page{
  20. /**
  21. * @var \K_Unit[] Selected unit array.
  22. *
  23. * [0]: Unawakened monster (null if default purple).
  24. * [1]: Awakened monster (null if silver).
  25. * [2]: Second awakened monster (null if unavailaable).
  26. */
  27. public $monster = [];
  28. /**
  29. * @var int[] IDs to other units of the family
  30. */
  31. public $family = [];
  32. /**
  33. * Constructor.
  34. *
  35. * Retrieves the data and initializes the variables.
  36. *
  37. * @param resource $db Connection to the database.
  38. * @param int $id Monster id. Can be any of the awakening stages
  39. */
  40. public function __construct($db, $id){
  41. parent::__construct($db);
  42. $this->view = PATH::VIEW . "monster_info.php";
  43. $title = "";
  44. $monster = new K_Unit($db, $id);
  45. if ($monster->can_awaken == 0){
  46. // Silver star monster.
  47. $this->monster[0] = $monster;
  48. $this->monster[1] = null;
  49. $this->monster[2] = null;
  50. $title = $this->monster[0]->element_name . " " . $this->monster[0]->name;
  51. }
  52. elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && $monster->awakens_from == ""){
  53. // Default purple (Rainbowmon or King Angelmon)
  54. $this->monster[0] = null;
  55. $this->monster[1] = $monster;
  56. $this->monster[2] = null;
  57. $title = $this->monster[1]->name;
  58. }
  59. elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && strlen($monster->awakens_from) > 0){
  60. // Normal monster, already awakened, no 2a.
  61. $this->monster[0] = new K_Unit($db, $monster->awakens_from);
  62. $this->monster[1] = $monster;
  63. $this->monster[2] = null;
  64. $title = $this->monster[1]->name . " - " .$this->monster[0]->element_name . " " . $this->monster[0]->name;
  65. $monster = $this->monster[0];
  66. }
  67. elseif ($monster->can_awaken == 1 && strlen($monster->awakens_to) > 0 && $monster->awakens_from == ""){
  68. // Normal monster, not awakened, may have 2a.
  69. $this->monster[0] = $monster;
  70. $this->monster[1] = new K_Unit($db, $this->monster[0]->awakens_to);
  71. if ($this->monster[1]->awakens_to == ""){
  72. $this->monster[2] = null;
  73. }
  74. else{
  75. $this->monster[2] = new K_Unit($db, $this->monster[1]->awakens_to);
  76. }
  77. $title = $this->monster[1]->name . " - " .$this->monster[0]->element_name . " " . $this->monster[0]->name;
  78. }
  79. $this->title = $title ." - SWDB";
  80. $this->description = $title . " info - SWDB";
  81. $this->canonical = URL::BASE . "monster_info/" . $id;
  82. }
  83. }
  84. ?>