Monster_Info_Page.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. if ($monster->can_awaken == 0){
  31. // Silver star monster.
  32. $this->monster[0] = $monster;
  33. $this->monster[1] = null;
  34. $this->monster[2] = null;
  35. $title = $this->monster[0]->element . " " . $this->monster[0]->name;
  36. }
  37. elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && $monster->awakens_from == ""){
  38. // Default purple (Rainbowmon or King Angelmon)
  39. $this->monster[0] = null;
  40. $this->monster[1] = $monster;
  41. $this->monster[2] = null;
  42. $title = $this->monster[1]->name;
  43. }
  44. elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && $monster->awakens_from =! ""){
  45. // Normal monster, already awakened, no 2a.
  46. $this->monster[0] = new K_Monster($db, $monster->awakens_from);
  47. $this->monster[1] = $monster;
  48. $this->monster[2] = null;
  49. $title = $this->monster[1]->name . " - " .$this->monster[0]->element . " " . $this->monster[0]->name;
  50. }
  51. elseif ($monster->can_awaken == 1 && $monster->awakens_to != "" && $monster->awakens_from == ""){
  52. // Normal monster, not awakened, may have 2a.
  53. $this->monster[0] = $monster;
  54. $this->monster[1] = new K_Monster($db, $this->monster[0]->awakens_to);
  55. if ($this->monster[1]->awakens_to == ""){
  56. $this->monster[2] = null;
  57. }
  58. else{
  59. $this->monster[2] = new K_Monster($db, $this->monster[1]->awakens_to);
  60. }
  61. $title = $this->monster[1]->name . " - " .$this->monster[0]->element . " " . $this->monster[0]->name;
  62. }
  63. $this->title = $title ." - SWDB";
  64. $this->description = $title . " info - SWDB";
  65. $this->canonical = $root . "monster_info/" . $id;
  66. }
  67. }
  68. ?>