Monster_Info_Page.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. require_once($path["page"] . "Page.php");
  3. require_once($path["entity"] . "K_Monster.php");
  4. /**
  5. * Monster details page.
  6. */
  7. class Monster_Info_Page extends Page{
  8. /**
  9. * Selected @{see Monster}0
  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. * Constructor.
  17. *
  18. * Retrieves the data and initializes the variables.
  19. *
  20. * @param SQLite3 $db Connection to the database.
  21. * @param string $id Monster id. Can be any of the awakening stages
  22. */
  23. public function __construct($db, $id){
  24. global $path;
  25. global $root;
  26. parent::__construct($db);
  27. $this->view = $path["view"] . "monster_info.php";
  28. $title = "";
  29. $monster = new K_Monster($db, $id);
  30. error_log("ID : " . $monster->id);
  31. error_log("FROM: " . $monster->awakens_from);
  32. error_log("TO : " . $monster->awakens_to);
  33. if ($monster->can_awaken == 0){
  34. error_log("CAN_AWAKEN 0 -> SILVER");
  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 . " " . $this->monster[0]->name;
  40. }
  41. elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && $monster->awakens_from == ""){
  42. error_log(" -> DEGFAULT PURPLE");
  43. // Default purple (Rainbowmon or King Angelmon)
  44. $this->monster[0] = null;
  45. $this->monster[1] = $monster;
  46. $this->monster[2] = null;
  47. $title = $this->monster[1]->name;
  48. }
  49. elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && strlen($monster->awakens_from) > 0){
  50. error_log("NORMAL MONSTER AWAKEN, no 2a. FROM: " . $monster->awakens_from);
  51. // Normal monster, already awakened, no 2a.
  52. $this->monster[0] = new K_Monster($db, $monster->awakens_from);
  53. $this->monster[1] = $monster;
  54. $this->monster[2] = null;
  55. $title = $this->monster[1]->name . " - " .$this->monster[0]->element . " " . $this->monster[0]->name;
  56. }
  57. elseif ($monster->can_awaken == 1 && strlen($monster->awakens_to) > 0 && $monster->awakens_from == ""){
  58. // Normal monster, not awakened, may have 2a.
  59. $this->monster[0] = $monster;
  60. $this->monster[1] = new K_Monster($db, $this->monster[0]->awakens_to);
  61. if ($this->monster[1]->awakens_to == ""){
  62. error_log("NORMAL MONSTER, GOLD, NO 2a");
  63. $this->monster[2] = null;
  64. }
  65. else{
  66. error_log("NORMAL MONSTER, GOLD, WITH 2a");
  67. $this->monster[2] = new K_Monster($db, $this->monster[1]->awakens_to);
  68. }
  69. $title = $this->monster[1]->name . " - " .$this->monster[0]->element . " " . $this->monster[0]->name;
  70. }
  71. else{
  72. error_log("UNKNOWN");
  73. }
  74. $this->title = $title ." - SWDB";
  75. $this->description = $title . " info - SWDB";
  76. $this->canonical = $root . "monster_info/" . $id;
  77. }
  78. }
  79. ?>