Monster_Info_Page.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 int $id Monster id. Can be any of the awakening stages
  38. */
  39. public function __construct($id){
  40. $this->view = PATH::VIEW . "monster_info.php";
  41. $title = "";
  42. $monster = new K_Unit($id);
  43. if ($monster->can_awaken == 0){
  44. // Silver star monster.
  45. $this->monster[0] = $monster;
  46. $this->monster[1] = null;
  47. $this->monster[2] = null;
  48. $title = $this->monster[0]->element_name . " " . $this->monster[0]->name;
  49. }
  50. elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && $monster->awakens_from == ""){
  51. // Default purple (Rainbowmon or King Angelmon)
  52. $this->monster[0] = null;
  53. $this->monster[1] = $monster;
  54. $this->monster[2] = null;
  55. $title = $this->monster[1]->name;
  56. }
  57. elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && strlen($monster->awakens_from) > 0){
  58. // Normal monster, already awakened, no 2a.
  59. $this->monster[0] = new K_Unit($monster->awakens_from);
  60. $this->monster[1] = $monster;
  61. $this->monster[2] = null;
  62. $title = $this->monster[1]->name . " - " .$this->monster[0]->element_name . " " . $this->monster[0]->name;
  63. $monster = $this->monster[0];
  64. }
  65. elseif ($monster->can_awaken == 1 && strlen($monster->awakens_to) > 0 && $monster->awakens_from == ""){
  66. // Normal monster, not awakened, may have 2a.
  67. $this->monster[0] = $monster;
  68. $this->monster[1] = new K_Unit($this->monster[0]->awakens_to);
  69. if ($this->monster[1]->awakens_to == ""){
  70. $this->monster[2] = null;
  71. }
  72. else{
  73. $this->monster[2] = new K_Unit($this->monster[1]->awakens_to);
  74. }
  75. $title = $this->monster[1]->name . " - " .$this->monster[0]->element_name . " " . $this->monster[0]->name;
  76. }
  77. $this->title = $title ." - SWDB";
  78. $this->description = $title . " info - SWDB";
  79. $this->canonical = URL::BASE . "monster_info/" . $id;
  80. }
  81. }
  82. ?>